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