Sugar v1.3 Release Notes

  • API Changes

    • ๐Ÿ“ฆ Sugar modules are now further split up and can easily be customized and repackaged. Aside from "core" there is the "es5" module that can be opted out of if <= IE8 support isn't an issue. DateRanges (below) are now their own module, as are inflections.
    • Date locales are now a separate module, only English is included in the base "date" module.
    • Enumerable methods are now available as class methods on Object, and instance methods on extended objects. This includes: map, any, all, none, count, sum, average, find, findAll, min, max, least, most, and reduce.
    • โž• Added Object.size (also available to extended objects)
    • 0๏ธโƒฃ Array#min, Array#max, Array#least, and Array#most now return a single element by default with the option to return multiple elements.
    • Object.equals now considers identical objects vs. extended objects to be the same
    • ๐Ÿ”จ Refactored Object.isEmpty to be an enumerable method in the Array module. This means that it will error on non-objects now.
    • โž• Added "language" module.
    • ๐Ÿšš String#normalize moved from Inflections to Language module
    • ๐Ÿšš String#has[Script] moved from String to Language module
    • ๐Ÿšš String#hankaku and String#zenkaku moved from String to Language module
    • ๐Ÿšš String#hiragana and String#katakana moved from String to Language module
    • ๐Ÿšš String#namespace moved from Inflections to String module
    • String#parameterize now checks for normalize and also uses encodeURI for final output
    • ๐Ÿšš String#split patching for regexes is now removed from the String module and is on its own in /lib/extra. It can be dropped in anywhere after Sugar is loaded.

    • ๐Ÿ—„ Array#has is deprecated

    • Array#groupBy no longer returns extended objects

    • Array#groupBy no longer corrupts array length (Issue 142)

    • Enumerable methods now allow fuzzy matching of instances of classes (Issue 157)

    • All Math methods are now mapped onto Number and are accessible as instance methods

    • String#capitalize all will capitalize any letter after a letter that could not be capitalized.

    • String#insert, and Array#insert now treat negative indexes like String#slice

    • ๐Ÿ›  Fixed issue with decodeBase64 shim (Issue 145)

    • ๐Ÿ—„ String#toDate is now deprecated.

    • ๐Ÿ“œ Date parsing formats are now scoped by locale. This means that if the current locale is set to English, only English formats will be parsed when Date#create does not specify a locale, even if a different locale was initialized previously. Numeric and common formats are available in all locales.

    • โž• Added output formats Date#long and Date#full which now included the time. Date#long (mm dd, yyyy hh:mm) is now the default for Date#format, and the previous default (no time) is now Date#short. Date#full includes milliseconds and weekday.

    • ๐Ÿ‘ Date format "just now" now supported

    • ๐Ÿ‘ Date#reset now supports resetting a unit based on a string.

    • Date#advance and other advance methods can now reset the time.

    • Date#advance now accepts string input like "4 days" (Issue 161)

    • ๐Ÿ“œ Date.past and Date.future added which allow date parsing that prefers the past or future when the specified date is ambiguous ("Sunday", etc.)

    • ๐Ÿ“œ Date parsing now allows time to be in front of the date string as well

    • ๐Ÿ›  Fixed various issues with timezones, DST, and date parsing (Issue 146), (Issue 138)

    • โž• Added "in 3 days", etc. as a parsable format

    • โž• Added "the 2nd Tuesday of November", etc. as a parsable format

    • โž• Added more parsable formats with weekdays (such as "last monday", etc) in various locales

    • โž• Added time parsing in non-English date formats

    • Fully qualified ISO language codes will now match more generic codes. This means passing "it_IT" will correctly find "it" if the more specific locale is not available.

    • Unknown languages codes will now simply return an invalid date instead of throwing an error.

    • โž• Added support for full kanji numerals in date parsing

    • โž• Added support for time suffixes in Asian time strings (ๆ™‚ etc)

    • โž• Added support for various relative formats in CKJ dates (ๅ…ˆ้€ฑๆฐดๆ›œๆ—ฅ etc)

    • ๐Ÿ›  Fixed inconsistently not allowing spaces before am/pm (Issue 144)

    • โž• Added DateRange, accessed through Date.range