Wednesday, February 17, 2010

XPages: Use MooTools in Server Side JS

I wanted to filter/extract values from an array of objects today. Before I started reinventing the wheel, I took a look at MooTools' server side library. It contains a lot of syntactical sugar.

The code needed to extract email addresses from an array of JS-objects, using MooTools (data is an array of objects):
var emailAddresses = data.map(function(item){
return item.email || null;
}).clean();

Download here.
General MooTools documentation here.

6 comments:

Vitor Pereira said...

You gotta love the simplicity.

Tommy Valand said...

I've loved MooTools for it's syntax/structure since the first time I discovered it.

Being able to use part of the framework on the server is fantastic! :)

Bjørn Cintra said...

Here I was, thinking that nah, I'll stick with jQuery, thank you very much, until the phrase "server-side" struck me... guess I'll be implementing this first thing tomorrow :D

Thank you!

Tommy Valand said...

You're welcome!

Give it time, and you soon you'll convert to the church of MooTools.. :P

Anonymous said...

what about the plugin ecosystem on JQuery?

Tommy Valand said...

@Quintessens: I have no idea what you're talking about. I never joined the jQuery movement.. :)