Sugar v2.0.0 Release Notes

Release Date: 2016-11-05 // over 7 years ago
  • API Changes

    • โž• Added global objects. All methods will also be defined here.
    • โœ‚ Removed String#escapeRegExp. Use RegExp.escape instead.
    • ๐Ÿ”„ Changed String#escapeHTML to double-escape entities.
    • Date#utc is now Date#setUTC.
    • Date.SugarNewDate is now an option accessor Sugar.Date.setOption('newDateInternal', fn)
    • ๐Ÿ‘€ Modified String#startsWith and String#endsWith to be more in compliance with ES6. See CAUTION.md for details.
    • โœ‚ Removed String#has in favor of String#includes to be more in compliance with ES6. See CAUTION.md for details.
    • โž• Added Number.isNaN shim. Removed Object.isNaN in favor of this.
    • Alphanumeric array options are now on the global object.
    • ๐Ÿšš Moved Object.map, Object.each, and Object.size to the object module.
    • โž• Added Object.isArguments.
    • ๐Ÿ”„ Changed String#each (renamed to String#forEach) to allow breaking the loop with false.
    • โž• Added ability for String#stripTags and Strip#removeTags to pass a callback.
    • ๐Ÿšš Made String#stripTags and String#removeTags much more robust.
    • โœ‚ Removed String#normalize and will put into its own plugin module as String#toAscii later.
    • โšก๏ธ Updated Array#sortBy to handle sorting on multiple properties (Issue #386, thanks to @eric-weiser).
    • ๐Ÿ›  Fixed String#unescapeHTML to handle HTML (and hex) codes. Also now handling  
    • โž• Added a third argument to Number#bytes to allow normal SI units.
    • โšก๏ธ Object.merge updated to take an options object. Non-enumerable property support is now an option, as well as property descriptors. Resolver function now will not traverse further into a deep merge if it has been resolved with a function. Sugar global object continues the merge.
    • ๐Ÿ‘ Allowing a global thousands and decimal marker to be set.
    • String#hankaku now makes a hyphen from hyphen-like fullwidth chars in number mode.
    • ๐Ÿ›  Fixed issue with the digit ten in date creation (Issue #431).
    • ๐Ÿ›  Fixed issue with the Date#[unit]Since improperly applying error margins.
    • ๐Ÿ”จ Refactored the since and fromNow methods to traverse using internal date methods instead of applying an error margin. This makes them much more accurate in dicey situations like DST traversal, leap years, etc.
    • ๐Ÿ›  Fixed issue with dates shifting in "monthsFromNow" (and consequently "relative") when traversing into a month that doesn't have enough days.
    • ๐Ÿ›  Fixed issue with advance/rewind using an object with both a "week" and "day" parameter (Issue #492).
    • ๐Ÿ›  Fixed issue Function#every not being able to cancel itself (Issue #488).
    • ๐Ÿ›  Fixed issue with German dates not allowing abbreviated weekdays with 2 characters.
    • โž• Added Date#get allowing date creation with a context date that can be used as a starting point for relative dates.
    • โž• Added Function#memoize (Issue #486)
    • ๐Ÿ”€ Async functions are now synchronous with Sinon.
    • ๐Ÿ“‡ Renamed Object.equal and Object#equals to isEqual for parity.
    • โœ‚ Removed Date.utc object as well as Date.past and Date.future in favor of an options object on Date#create.
    • โœ… Renamed Function#fill to Function#partial. Tests from Underscore and Lodash brought in to confirm conformitive behavior.
    • ๐Ÿ›  null now no longer acts as a placeholder in Function#partial. Other bugs fixed around this including using partial on constructors.
    • Date#create options object now uses fromUTC instead of just utc. A new option setUTC is also added which will set the internal utc flag on creation.
    • ๐Ÿ”จ String#assign refactored and renamed to String#format. Tokens are zero based and a few other changes.
    • โž• Added Object.get and Object.set, allowed them to use dot, bracket, range, and push syntax, and allowed deep object transforms on Array#map, and other methods.
    • ๐Ÿ›  Fixed many issues with DST and simplified month traversal.
    • ๐Ÿ“‡ Renamed Array#randomize to Array#shuffle
    • โž• Added Array#sample ability to remove sampled elements and performance optimization.
    • โž• Added String#replaceAll and String#removeAll.
    • โž• Added polyfill for Array.from and modified Array.create to return a reference by default.
    • ๐Ÿ”„ Changed behavior of Function#after to more closely match that of Underscore/Lodash.
    • ๐Ÿ”„ Changed behavior of Number#times to return an array of return values.
    • ๐Ÿ”„ Changed Object.fromQueryString to return a plain object.
    • โœ‚ Removed Object.watch and Object.unwatch.
    • โœ‚ Removed ability for Date.create to accept enumerated arguments.
    • Modified Object.toQueryString to accept an options object.
    • Modified Object.fromQueryString to accept an options object.
    • โž• Added support for Sets in isEqual.
    • โž• Added Array#median.
    • Modified Number#metric to use a more flexible system of defining units.
    • โž• Added strf tokens to Date#format as well as a number of new standard tokens. Aligned tokens more with moment/ldml and renamed to ldml in the code.
    • Modified Array#at and String#at to use arrays instead of enumerated arguments.
    • โœ‚ Removed mixed modes for String#hankaku and String#zenkaku.
    • ๐ŸŽ Modified String#replaceTags and String#stripTags to simplify argument signature and small performance boost.
    • โž• Added Array#isEqual.
    • ๐Ÿšš Renamed RegExp#addFlag and RegExp#removeFlag to RegExp#addFlags and RegExp#removeFlags, and ensured they work on multiple flags.
    • Created new module enumerable, and split out array methods.
    • โœ‚ Removed Array#findAll in favor of Array#filter and Array#filterFromIndex.
    • Replaced Object.findAll with Object.filter.
    • Array#isEmpty now only checks for zero length.
    • โšก๏ธ Moved Object.select and Object.reject to enumerable module and updated to match objects on key existence.
    • โž• Added Object.remove and Object.exclude.
    • โž• Added Array#append to take the place of Array#add. Array#add now is non-destructive. Array#insert now aliases append instead of add.
    • โœ‚ Removed Array#include (now is identical to Array#add).
    • โž• Added Object.invert.
    • ๐Ÿšš Moved String#titleize to String module from Inflections.
    • Modified Object.has to allow deep keys. Also added a flag to allow properties in the prototype.
    • โœ‚ Removed Object.extended and all trace of Hashes in favor of Sugar chainables.
    • โž• Added date unit methods to ranges.
    • ๐Ÿ‘ Allowed excepting and allowing entire namespaces.
    • Flipped "si" argument to Number#bytes to instead be "binary".
    • Modified String#capitalize to have an extra parameter for downcasing.
    • ๐Ÿ”จ Refactored inflections module to have a more straightforward API.
    • โšก๏ธ Updated Array#sortBy to not clone the array by default.
    • Modified Date#reset to use higher units to make more semantic sense.
    • Reversed arguments in Date#relative.
    • โœ‚ Removed Array#each in favor of Array#forEachFromIndex in cases where the index is needed.
    • โž• Added fromIndex methods. Moved findFrom and findIndexFrom to be inline with these.
    • ๐Ÿ“‡ Renamed Object.each to Object.forEach to bring it in line with other methods.
    • ๐Ÿ”„ Changed Array#subtract, Array#intersect, and Array#union to only accept a single argument to follow other methods more closely.
    • โœ‚ Removed String#add, which on its own is largely useless in favor of String#insert which was previously an alias.
    • โœ‚ Removed all and any aliases.
    • ๐Ÿšš Moved the step argument in Number#upto and Number#downto to be an optional 2nd argument.
    • โœ‚ Removed callbacks in Object.keys and Object.values. Object.forEach should be preferred method of iteration.
    • ๐Ÿ”„ Changed object iteration callbacks to be value first.
    • ๐Ÿ“‡ Renamed String#each to String#forEach.
    • ๐Ÿ”„ Changed min/max/least/most args to put the callback at the end.
    • โœ‚ Removed String#paragraphs.
    • โž• Added Object.addAll.