lambda-jam
lambda-jam is a sweet.js macro, λ
, which is used to create shorthand, anonymous functions with special argument identifiers. Its functionality is inspired by clojure's shorthand function macro, #()
.
npm install lambda-jam
Examples
lambda-jam's real power is derived from its special argument identifiers and the fact that it returns the last expression for you. _1
references the first argument, _2
references the second argument and so on up until _9
. Though, the hope is that you're not passing 9 arguments to a function.
var square = ;console; // 16 var sum = 1 2 3;console; // 6 var tweets = viewed: true msg: "kjadf" viewed: false msg: "sweet" viewed: false msg: "js"; var joinedMsg = tweets;console; // sweet.js
Check the test suite for a few more examples.
Tests
make test