
Writing JavaScript used to be painful. You should expect that much from a language that has such an anemic standard library. Coming from Ruby I sure missed ActiveSupport.
There’s Underscore.js which makes some of that pain go away, especially when dealing with collections.
Then there’s Sugar.js.
I got the chance to use Sugar.js on a side project and it’s been heck of an improvement over anything else I used. I no longer miss ActiveSupport.
You get JavaScript 1.6 support in lesser browsers (indexOf, forEach, reduce, etc) along with useful Array methods like groupBy, average, first(n), etc.
You can camelize, capitalize, base64 encode, pad and split a String into words.
You can count from the Number 0.upto(10), find out that 10.isEven() and format it into a readable string.
You can create a lazy Function, delay, defer and cancel it.
You can easily check if an Object is empty, a string or date. And just as easily clone or merge it.
And then … then, there’s Date. If ever you want to punish someone on the team, make them use JavaScript’s stock Date library.
Sugar.js will parse “Tuesday May 25th, 2010″ and just as easily “one day before yesterday”. And you can format that date anyway you like, including relative time (“2 hours ago” and such).
You can advance a date by a minute, rewind by an hour, set to beginningOfWeek(). You can check if isBefore(another), or isYesterday() or just isThisWeek(). You can do time arithmetic by adding 5.minutes() + 2.hours().
It will work in your browser, yes even that which we don’t call by name. You can also npm install sugar.
If that’s not kick-ass, I don’t know what.