functional.js
Advanced tools
Comparing version
/*! | ||
functional.js (v0.1.6) 14-08-2013 | ||
functional.js (v0.1.7) 14-08-2013 | ||
(c) Lee Crossley <leee@hotmail.co.uk> (http://ilee.co.uk/) | ||
*/ | ||
var λ=function(){var a={};return a.curry=function(b){if(!b||"function"!=typeof b)throw"λ Error: No function to curry";return function c(){var d=arguments.length>=1?[].slice.call(arguments,0):[];if(d.length===b.length)return b.apply(null,d);if(d.length>b.length){var e=b.apply(null,d);return a.reduce(b,e,d.slice(b.length))}return function(){var a=arguments.length>=1?[].slice.call(arguments,0):[];return c.apply(null,d.concat(a))}}},a.each=a.curry(function(a,b){if(b&&"function"==typeof a)for(var c=0;c<b.length;c++)a(b[c])}),a.map=a.curry(function(b,c){var d,e=[];if(c&&"function"==typeof b)return d=a.each(function(){e.push(b.apply(null,arguments))}),d(c),e}),a.reduce=a.reducel=a.curry(function(b,c,d){var e,f=c;if(d&&"function"==typeof b)return e=a.each(function(a){f=b.call(null,f,a)}),e(d),f}),a.any=a.curry(function(b,c){var d,e=!1;if("function"!=typeof b)throw"λ Error: Invalid function";return d=a.each(function(a){return b.call(null,a)?(e=!0,void 0):void 0}),d(c),e}),a.select=a.curry(function(b,c){var d,e=[];if("function"!=typeof b)throw"λ Error: Invalid function";return d=a.each(function(a){b.call(null,a)&&e.push(a)}),d(c),e}),a.compose=function(b){var c=a.any(function(a){return"function"!=typeof a});if(b=arguments.length>=1?[].slice.call(arguments,0):[],c(b))throw"λ Error: Invalid function to compose";return function(){var c=arguments,d=a.each(function(a){c=[a.apply(null,c)]});return d(b.reverse()),c[0]}},a}();"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=λ),exports.λ=λ); |
@@ -5,3 +5,4 @@ { | ||
"description": "functional.js is (go on, guess) a functional js library. It facilitates currying and point-free / tacit programming in JavaScript. Minified version here: http://bit.ly/funcmin", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"main": "functional.min.js", | ||
"keywords": [ | ||
@@ -8,0 +9,0 @@ "functional", |
17484
0.19%