Sugar. Javascript, sweetened.

Sugar on Github Download Sugar

What is Sugar?

Sugar is a Javascript library that extends native objects with helpful methods. It is designed to be intuitive, unobtrusive, and let you do more with less code.

What is Sugar not?

Sugar is a not a framework for AJAX, animation, or DOM manipulation. In fact, Sugar is not tied to the browser in any way.

getLatestTweets(function(t) { var users = t.map('user').unique(); var total = users.sum('statuses_count').format(); var top = users.max('followers_count').first(); var count = top.followers_count.format(); var since = Date.create(top.created_at); return users.length + ' users with a total of ' + total + ' tweets.\n' + top.screen_name + ' is the top with ' + count + ' followers\n' + 'and started tweeting ' + since.relative() + '.'; });

Sugar...

So it's like Prototype.js...?
Sugar is similar to Prototype in that it adds methods to native Javascript objects. However, it doesn't carry any of the weight of classic browser-oriented frameworks (ajax, DOM manipulation, inheritance, etc.). Sugar is also not interested in adhering to a Ruby based syntax, nor does it have anything to do with Rails. Sugar is Javascript for Javascript developers.
Okay, so it's like Underscore.js, then...?
Sugar is similar to Underscore.js in that it is intended as a support library for "functional" programming. However, it takes a very different tack with what and how it chooses to implement. Sugar modifies native objects, and is more concerned with intuitive syntax, whereas Underscore.js leaves native objects alone, and is more oriented toward performance.
Then surely it must have something to do with jQuery...?!
Sugar was written with jQuery very much in mind, and finds its niche working side by side with jQuery, especially in data-heavy applications. However it is entirely standalone, and in no way dependent on jQuery, or even on the browsing environment.
Will Sugar break my existing code?
Sugar will never overwrite methods that already exist, and so is safe to include in any of your pages. It can be opted in over existing frameworks like Prototype, YUI, and MooTools, adding in only the extra bits of sweetness.
How does Sugar compare to plain Javascript or other languages?
Check out the library comparison page, which is a nice reference that shows Sugar syntax compared to plain Javascript as well as Python and Ruby (ActiveSupport).
But Sugar modifies native objects! Isn't that Evil™?
Augmenting native objects is only as bad as the method in which it's done. If you're still unsettled however, you're probably not alone. Read more.
Is Sugar available for Node.js?
Yes!