version 0.2.0 is out, with inject -> reduce, JS standard methodname aliases, a compose(), and a lastIndexOf()

This commit is contained in:
Jeremy Ashkenas
2009-10-28 18:49:50 -04:00
parent 6d52832a73
commit 4a83fcdd26
8 changed files with 294 additions and 158 deletions

View File

@@ -48,4 +48,14 @@ $(document).ready(function() {
equals(backwards('moe'), 'hi: moe eom', 'wrapped the saluation function');
});
test("functions: compose", function() {
var greet = function(name){ return "hi: " + name; };
var exclaim = function(sentence){ return sentence + '!'; };
var composed = _.compose(exclaim, greet);
equals(composed('moe'), 'hi: moe!', 'can compose a function that takes another');
composed = _.compose(greet, exclaim);
equals(composed('moe'), 'hi: moe!', 'in this case, the functions are also commutative');
});
});