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