Sugar v0.9.3 Release Notes
-
API Changes
- Array.isArray polyfill added and aliased by Object.isArray (es5)
- Array#every/some/map/filter now throws a TypeError if no arguments passed (es5)
- Array#every/some/map/filter now defers to native if available and no arguments passed (es5)
- Array#none/any/all/has aliases similarly throw TypeErrors if no arguments passed (es5)
- Array#indexOf/lastIndexOf now performs a simple strict equality check. Added to v0.9.2 but separately here (es5)
- ๐จ Array#indexOf/lastIndexOf refactored to defer to String#indexOf/lastIndexOf if a string is passed as the scope (es5)
- Array#forEach/reduce/reduceRight now all throw a TypeError if callback is not callable (es5)
- Array#reduce/reduceRight now throw a TypeError if the array is empty and no initial value passed (es5)
- Array#each is now no longer an alias of forEach and has different behavior:
- second parameter is the index to start from
- third parameter is a boolean that runs the loop from the beginning if true
- returns the array
- fn returning false will break out of the loop
- will throw a TypeError if fn is not callable (same as forEach)
- array is now passed as the scope
- now detects sparse arrays and switches to a different algorithm to handle them
- ๐จ Array#find refactored to use an internal method insted of Array#findAll to avoid collisions
- Array#find now breaks as soon as it finds an element
- ๐ Array#eachFromIndex removed
- ๐ Array#removeAtIndex renamed to Array#removeAt
- ๐จ Array#unique refactored to use an internal method instead of Array#find to avoid collisions
- ๐จ Array#subtract/intersect refactored to use an internal method instead of Array#find to avoid collisions
- ๐จ Array#subtract/intersect refactored to use Array.isArray instead of Object.isArray
- ๐จ Array#union refactored to use an internal method instead of Array#unique to avoid collisions
- ๐จ Array#min/max refactored to use an internal method instead of Array#unique to avoid collisions
- Array#least/most will now throw a TypeError if the first argument exists, but is not a string or function
- ๐จ Array#least/most refactored to use an internal method instead of Array#unique to avoid collisions
- Array#groupBy will now throw a TypeError if the first argument exists, but is not a string or function
- Array#sortBy will now throw a TypeError if the first argument exists, but is not a string or function
- Array#compact/flatten now internally uses Array.isArray instead of Object.isArray
- ๐ Array#collect alias removed
- ๐ Array#shuffle alias removed
- ๐จ String#hankaku/zenkaku/hiragana/katakana refactored to shift char codes instead of using a hash table
- ๐จ String#hankaku/zenkaku refactored to be much more accurate & strictly defined
- String#shift added
- ๐จ String#trim refactored to handle all characters covered in es5/unicode (es5)
- ๐จ String#trim refactored to check for support and polyfill as needed (es5)
- ๐ String#titleize removed
- ๐จ String#capitalize refactored to allow capitalization of all letters
- ๐จ String#pad/padLeft/padRight refactored to accept the number as the second param and padding as the first
- ๐จ String#repeat refactored to return a blank string on num < 1
- ๐จ String#add refactored to act in parallel with Array#add
- ๐ String#remove added as a reciprocal of String#add and a parallel of Array#remove
- ๐จ String#dasherize/underscore refactored to strip whitespace
- ๐จ Object.keys refactored to defer to native if < 2 arguments instead of == 1
- Object.keys will now throw a TypeError if non-object passed (es5)
- ๐ Number.random fixed which had implied globals min & max
- Date.now polyfill added (es5)
- ๐จ Date#toISOString refactored polyfill to check for native browser support (es5)
- Date#toJSON added as a polyfill alias to Date#toISOString with similar native checks (es5)
- ๐จ Date#format/relative refactored to point to an internal method to avoid collisions
- ๐ fixed date methods in ambiguous situations such as "5 months ago" when the target month does not have enough days
- ๐จ Function#bind refactored to check for native support and behave much more closely to spec (es5)
- โ added documentation for unicode block methods
- โ added devanagari and ethiopic scripts
Internal Changes
- ๐จ refactored unicode script methods to use .test instead of .match
- ๐จ extendWithNativeCondition refactored to allow a "supported" flag
- ๐จ getMinOrMax refactored to use iterateOverObject
- getFromIndexes renamed to getAtIndexes
- 0๏ธโฃ toIntegerWithDefault added
- arrayFind added
- arrayEach added
- arrayUnique added
- isArrayIndex added (es5)
- toUint32 added (es5)
- checkCallback added (es5)
- checkFirstArgumentExists added (es5)
- ๐จ buildObject refactored to be less invasive