Sugar provides methods on strings like from, to, first, last, add, and remove to make modifying strings intuitive and readable, as well as others like each, chars, words, lines, paragraphs which allow iterating over chunks of text. Common escaping methods like escapeURL, escapeHTML, and escapeRegExp provide quick shortcuts for string escaping. Multilingual support is also enhanced with shortcut methods to Unicode script blocks, such as Kanji (Chinese and Japanese), Hiragana (Japanese), Hangul (Korean), Greek, Hebrew, and more. Full list of methods.
Basic methods on the Math object exist in Sugar on numbers as shortcut methods. Additional conveniences include number rounding to a specific precison, number padding, and number formatting. Suger also includes methods that bridge the Date class, helping to quickly convert numbers to dates. Full list of methods.
Sugar gives the Date class much love starting with the Date.create method which can understand dates in just about any format in 11 major languages, including relative formats like "1 hour ago". Dates can also be output in any format or language using an easy to understand syntax, with shortcuts to commonly used date formats. Complex date comparison is also possible with methods like is, which understand any format and apply built in precision. More about dates | Full list of methods.
Although Sugar does not interfere with the Object prototype directly, it does provide many shortcuts accessed as Object class methods. One is Object.extended, which creates a hash-like object extended with methods you would expect to find in hashes in other languages. If you prefer not to use these, all methods are also accessible directly on the Object class itself. Also available are type checking methods such as isString, isFunction, etc. More about objects | Full list of methods.
Sugar provides a basic shim for bind to bind scope to functions. Quickly set delays or non-blocking operations with delay and cancel timed operations with cancel. Also included are functions that help with throttling operations: throttle will only fire once for a given duration, lazy will fire all calls to itself, but no more than once for a given duration, and debounce will fire once after a delay when there are many calls in rapid succession. Full list of methods.
Sugar adds a handful of methods to the RegExp class, and additionally fixes native inconsistencies in splitting on regexes as part of the string class. Full list of methods.
In trying to extend natives as safely as possible, Sugar will never overwrite methods that have been added by other code. This makes Sugar safe to use alongside other frameworks such as Prototype. However, it may be desirable to override this behavior and allow Sugar to regain control.
For such cases, each built-in class has a sugarRestore() method that will allow any number of methods to revert to Sugar's control. If no method names are passed Sugar will regain control of all methods in that class. Likewise, classes also have a method sugarRevert which will revert (or delete) the methods to restore them to their original state.
Additionally, each built-in class also has an extend() method that allows you to extend built-in types with your own methods!
Finally, calling Object.extend() with no parameters will additionally map all object related methods to the Object.prototype, which is disabled by default. See objects for more about this.