functional.js
Advanced tools
Comparing version 0.4.9 to 0.4.10
@@ -7,3 +7,3 @@ { | ||
"homepage": "http://functionaljs.com", | ||
"version": "0.4.8", | ||
"version": "0.4.10", | ||
"keywords": [ | ||
@@ -15,2 +15,3 @@ "functional", | ||
"iterator", | ||
"collection", | ||
"lambda", | ||
@@ -17,0 +18,0 @@ "underscore" |
@@ -9,4 +9,8 @@ var λ = (function () { | ||
λ.isFunction = function (obj) { | ||
return typeof (obj) === "function"; | ||
}; | ||
var checkFunction = function (func) { | ||
if (!func || typeof (func) !== "function") { | ||
if (!λ.isFunction(func)) { | ||
throw "λ Error: Invalid function"; | ||
@@ -13,0 +17,0 @@ } |
/*! | ||
functional.js (v0.4.9) 03-08-2014 | ||
functional.js (v0.4.10) 04-08-2014 | ||
(c) Lee Crossley <leee@hotmail.co.uk> (http://ilee.co.uk/) | ||
*/ | ||
var lambda=function(){"use strict";var a={},b="hardReturn;",c=function(a){return a.length>0?[].slice.call(a,0):[]},d=function(a){if(!a||"function"!=typeof a)throw"lambda Error: Invalid function"};return a.curry=function(b){return d(b),function e(){var d=c(arguments);if(d.length===b.length)return b.apply(null,d);if(d.length>b.length){var f=b.apply(null,d);return a.fold(b,f,d.slice(b.length))}return function(){var a=c(arguments);return e.apply(null,d.concat(a))}}},a.each=a.curry(function(c,e){if(d(c),a.exists(e)&&a.isArray(e))for(var f=0;f<e.length;f+=1)if(c.call(null,e[f],f)===b)return}),a.map=a.curry(function(b,c){d(b);var e=[];return a.each(function(){e.push(b.apply(null,arguments))},c),e}),a.fold=a.foldl=a.curry(function(b,c,e){return d(b),a.each(function(a){c=b.call(null,c,a)},e),c}),a.reduce=a.reducel=a.foldll=a.curry(function(b,c){d(b);var e=c[0];return c.shift(),a.fold(b,e,c)}),a.clone=function(b){var c=[];return a.each(function(a){c.push(a)},b),c},a.first=a.curry(function(c,e){d(c);var f;return a.each(function(a){return c.call(null,a)?(f=a,b):void 0},e),f}),a.last=a.curry(function(b,c){var d=a.clone(c);return a.first(b,d.reverse())}),a.every=a.all=a.curry(function(c,e){d(c);var f=!0;return a.each(function(a){return c.call(null,a)?void 0:(f=!1,b)},e),f}),a.any=a.contains=a.curry(function(c,e){d(c);var f=!1;return a.each(function(a){return c.call(null,a)?(f=!0,b):void 0},e),f}),a.select=a.filter=a.curry(function(b,c){d(b);var e=[];return a.each(function(a){b.call(null,a)&&e.push(a)},c),e}),a.best=a.curry(function(b,c){d(b);var e=function(a,c){return b.call(this,a,c)?a:c};return a.reduce(e,c)}),a.while=a.curry(function(c,e){d(c);var f=[];return a.each(function(a){return c.call(null,a)?void f.push(a):b},e),f}),a.compose=function(b){var d=a.any(function(a){return"function"!=typeof a});if(b=c(arguments),d(b))throw"lambda 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.partition=a.curry(function(b,c){d(b);var e,f=[],g=[];return e=a.each(function(a){(b.call(null,a)?f:g).push(a)}),e(c),[f,g]}),a.group=a.curry(function(b,c){d(b);var e,f={};return a.each(function(a){e=b.call(null,a),f[e]=f[e]||[],f[e].push(a)},c),f}),a.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.toArray=function(b){return a.map(function(a){return[a,b[a]]},Object.keys(b))},a.apply=a.curry(function(b,c){var d=[];return a.isArray(b)&&(d=[].slice.call(b,1),b=b[0]),a.map(function(a){return a[b].apply(a,d)},c)}),a.assign=a.extend=a.curry(function(b,c){return a.each(function(a){c[a]=b[a]},Object.keys(b)),c}),a.prop=function(a){return function(b){return b[a]}},a.pluck=a.curry(function(b,c){return a.map(a.prop(b),c)}),a.exists=function(a){return null!=a},a.truthy=function(b){return a.exists(b)&&b!==!1},a.falsy=function(b){return!a.truthy(b)},a}();"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=lambda),exports.lambda=lambda); | ||
var lambda=function(){"use strict";var a={},b="hardReturn;",c=function(a){return a.length>0?[].slice.call(a,0):[]};a.isFunction=function(a){return"function"==typeof a};var d=function(b){if(!a.isFunction(b))throw"lambda Error: Invalid function"};return a.curry=function(b){return d(b),function e(){var d=c(arguments);if(d.length===b.length)return b.apply(null,d);if(d.length>b.length){var f=b.apply(null,d);return a.fold(b,f,d.slice(b.length))}return function(){var a=c(arguments);return e.apply(null,d.concat(a))}}},a.each=a.curry(function(c,e){if(d(c),a.exists(e)&&a.isArray(e))for(var f=0;f<e.length;f+=1)if(c.call(null,e[f],f)===b)return}),a.map=a.curry(function(b,c){d(b);var e=[];return a.each(function(){e.push(b.apply(null,arguments))},c),e}),a.fold=a.foldl=a.curry(function(b,c,e){return d(b),a.each(function(a){c=b.call(null,c,a)},e),c}),a.reduce=a.reducel=a.foldll=a.curry(function(b,c){d(b);var e=c[0];return c.shift(),a.fold(b,e,c)}),a.clone=function(b){var c=[];return a.each(function(a){c.push(a)},b),c},a.first=a.curry(function(c,e){d(c);var f;return a.each(function(a){return c.call(null,a)?(f=a,b):void 0},e),f}),a.last=a.curry(function(b,c){var d=a.clone(c);return a.first(b,d.reverse())}),a.every=a.all=a.curry(function(c,e){d(c);var f=!0;return a.each(function(a){return c.call(null,a)?void 0:(f=!1,b)},e),f}),a.any=a.contains=a.curry(function(c,e){d(c);var f=!1;return a.each(function(a){return c.call(null,a)?(f=!0,b):void 0},e),f}),a.select=a.filter=a.curry(function(b,c){d(b);var e=[];return a.each(function(a){b.call(null,a)&&e.push(a)},c),e}),a.best=a.curry(function(b,c){d(b);var e=function(a,c){return b.call(this,a,c)?a:c};return a.reduce(e,c)}),a.while=a.curry(function(c,e){d(c);var f=[];return a.each(function(a){return c.call(null,a)?void f.push(a):b},e),f}),a.compose=function(b){var d=a.any(function(a){return"function"!=typeof a});if(b=c(arguments),d(b))throw"lambda 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.partition=a.curry(function(b,c){d(b);var e,f=[],g=[];return e=a.each(function(a){(b.call(null,a)?f:g).push(a)}),e(c),[f,g]}),a.group=a.curry(function(b,c){d(b);var e,f={};return a.each(function(a){e=b.call(null,a),f[e]=f[e]||[],f[e].push(a)},c),f}),a.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.toArray=function(b){return a.map(function(a){return[a,b[a]]},Object.keys(b))},a.apply=a.curry(function(b,c){var d=[];return a.isArray(b)&&(d=[].slice.call(b,1),b=b[0]),a.map(function(a){return a[b].apply(a,d)},c)}),a.assign=a.extend=a.curry(function(b,c){return a.each(function(a){c[a]=b[a]},Object.keys(b)),c}),a.prop=function(a){return function(b){return b[a]}},a.pluck=a.curry(function(b,c){return a.map(a.prop(b),c)}),a.exists=function(a){return null!=a},a.truthy=function(b){return a.exists(b)&&b!==!1},a.falsy=function(b){return!a.truthy(b)},a}();"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=lambda),exports.lambda=lambda); |
/*! | ||
functional.js (v0.4.9) 03-08-2014 | ||
functional.js (v0.4.10) 04-08-2014 | ||
(c) Lee Crossley <leee@hotmail.co.uk> (http://ilee.co.uk/) | ||
*/ | ||
var λ=function(){"use strict";var a={},b="hardReturn;",c=function(a){return a.length>0?[].slice.call(a,0):[]},d=function(a){if(!a||"function"!=typeof a)throw"λ Error: Invalid function"};return a.curry=function(b){return d(b),function e(){var d=c(arguments);if(d.length===b.length)return b.apply(null,d);if(d.length>b.length){var f=b.apply(null,d);return a.fold(b,f,d.slice(b.length))}return function(){var a=c(arguments);return e.apply(null,d.concat(a))}}},a.each=a.curry(function(c,e){if(d(c),a.exists(e)&&a.isArray(e))for(var f=0;f<e.length;f+=1)if(c.call(null,e[f],f)===b)return}),a.map=a.curry(function(b,c){d(b);var e=[];return a.each(function(){e.push(b.apply(null,arguments))},c),e}),a.fold=a.foldl=a.curry(function(b,c,e){return d(b),a.each(function(a){c=b.call(null,c,a)},e),c}),a.reduce=a.reducel=a.foldll=a.curry(function(b,c){d(b);var e=c[0];return c.shift(),a.fold(b,e,c)}),a.clone=function(b){var c=[];return a.each(function(a){c.push(a)},b),c},a.first=a.curry(function(c,e){d(c);var f;return a.each(function(a){return c.call(null,a)?(f=a,b):void 0},e),f}),a.last=a.curry(function(b,c){var d=a.clone(c);return a.first(b,d.reverse())}),a.every=a.all=a.curry(function(c,e){d(c);var f=!0;return a.each(function(a){return c.call(null,a)?void 0:(f=!1,b)},e),f}),a.any=a.contains=a.curry(function(c,e){d(c);var f=!1;return a.each(function(a){return c.call(null,a)?(f=!0,b):void 0},e),f}),a.select=a.filter=a.curry(function(b,c){d(b);var e=[];return a.each(function(a){b.call(null,a)&&e.push(a)},c),e}),a.best=a.curry(function(b,c){d(b);var e=function(a,c){return b.call(this,a,c)?a:c};return a.reduce(e,c)}),a.while=a.curry(function(c,e){d(c);var f=[];return a.each(function(a){return c.call(null,a)?void f.push(a):b},e),f}),a.compose=function(b){var d=a.any(function(a){return"function"!=typeof a});if(b=c(arguments),d(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.partition=a.curry(function(b,c){d(b);var e,f=[],g=[];return e=a.each(function(a){(b.call(null,a)?f:g).push(a)}),e(c),[f,g]}),a.group=a.curry(function(b,c){d(b);var e,f={};return a.each(function(a){e=b.call(null,a),f[e]=f[e]||[],f[e].push(a)},c),f}),a.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.toArray=function(b){return a.map(function(a){return[a,b[a]]},Object.keys(b))},a.apply=a.curry(function(b,c){var d=[];return a.isArray(b)&&(d=[].slice.call(b,1),b=b[0]),a.map(function(a){return a[b].apply(a,d)},c)}),a.assign=a.extend=a.curry(function(b,c){return a.each(function(a){c[a]=b[a]},Object.keys(b)),c}),a.prop=function(a){return function(b){return b[a]}},a.pluck=a.curry(function(b,c){return a.map(a.prop(b),c)}),a.exists=function(a){return null!=a},a.truthy=function(b){return a.exists(b)&&b!==!1},a.falsy=function(b){return!a.truthy(b)},a}();"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=λ),exports.λ=λ); | ||
var λ=function(){"use strict";var a={},b="hardReturn;",c=function(a){return a.length>0?[].slice.call(a,0):[]};a.isFunction=function(a){return"function"==typeof a};var d=function(b){if(!a.isFunction(b))throw"λ Error: Invalid function"};return a.curry=function(b){return d(b),function e(){var d=c(arguments);if(d.length===b.length)return b.apply(null,d);if(d.length>b.length){var f=b.apply(null,d);return a.fold(b,f,d.slice(b.length))}return function(){var a=c(arguments);return e.apply(null,d.concat(a))}}},a.each=a.curry(function(c,e){if(d(c),a.exists(e)&&a.isArray(e))for(var f=0;f<e.length;f+=1)if(c.call(null,e[f],f)===b)return}),a.map=a.curry(function(b,c){d(b);var e=[];return a.each(function(){e.push(b.apply(null,arguments))},c),e}),a.fold=a.foldl=a.curry(function(b,c,e){return d(b),a.each(function(a){c=b.call(null,c,a)},e),c}),a.reduce=a.reducel=a.foldll=a.curry(function(b,c){d(b);var e=c[0];return c.shift(),a.fold(b,e,c)}),a.clone=function(b){var c=[];return a.each(function(a){c.push(a)},b),c},a.first=a.curry(function(c,e){d(c);var f;return a.each(function(a){return c.call(null,a)?(f=a,b):void 0},e),f}),a.last=a.curry(function(b,c){var d=a.clone(c);return a.first(b,d.reverse())}),a.every=a.all=a.curry(function(c,e){d(c);var f=!0;return a.each(function(a){return c.call(null,a)?void 0:(f=!1,b)},e),f}),a.any=a.contains=a.curry(function(c,e){d(c);var f=!1;return a.each(function(a){return c.call(null,a)?(f=!0,b):void 0},e),f}),a.select=a.filter=a.curry(function(b,c){d(b);var e=[];return a.each(function(a){b.call(null,a)&&e.push(a)},c),e}),a.best=a.curry(function(b,c){d(b);var e=function(a,c){return b.call(this,a,c)?a:c};return a.reduce(e,c)}),a.while=a.curry(function(c,e){d(c);var f=[];return a.each(function(a){return c.call(null,a)?void f.push(a):b},e),f}),a.compose=function(b){var d=a.any(function(a){return"function"!=typeof a});if(b=c(arguments),d(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.partition=a.curry(function(b,c){d(b);var e,f=[],g=[];return e=a.each(function(a){(b.call(null,a)?f:g).push(a)}),e(c),[f,g]}),a.group=a.curry(function(b,c){d(b);var e,f={};return a.each(function(a){e=b.call(null,a),f[e]=f[e]||[],f[e].push(a)},c),f}),a.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.toArray=function(b){return a.map(function(a){return[a,b[a]]},Object.keys(b))},a.apply=a.curry(function(b,c){var d=[];return a.isArray(b)&&(d=[].slice.call(b,1),b=b[0]),a.map(function(a){return a[b].apply(a,d)},c)}),a.assign=a.extend=a.curry(function(b,c){return a.each(function(a){c[a]=b[a]},Object.keys(b)),c}),a.prop=function(a){return function(b){return b[a]}},a.pluck=a.curry(function(b,c){return a.map(a.prop(b),c)}),a.exists=function(a){return null!=a},a.truthy=function(b){return a.exists(b)&&b!==!1},a.falsy=function(b){return!a.truthy(b)},a}();"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=λ),exports.λ=λ); |
@@ -6,3 +6,3 @@ { | ||
"homepage": "http://functionaljs.com", | ||
"version": "0.4.9", | ||
"version": "0.4.10", | ||
"main": "functional.min.js", | ||
@@ -15,2 +15,3 @@ "keywords": [ | ||
"iterator", | ||
"collection", | ||
"lambda", | ||
@@ -43,3 +44,3 @@ "underscore" | ||
"grunt-contrib-jshint": "~0.10.x", | ||
"grunt-contrib-jasmine": "~0.7.0", | ||
"grunt-contrib-jasmine": "~0.7.x", | ||
"grunt-contrib-uglify": "~0.5.x", | ||
@@ -46,0 +47,0 @@ "grunt-cli": "~0.1.x", |
16
spec.js
@@ -0,1 +1,3 @@ | ||
/*global λ*/ | ||
describe("functional", function() { | ||
@@ -77,3 +79,3 @@ | ||
var addToResult = λ.each(addTo); | ||
expect(typeof (addToResult)).toEqual("function"); | ||
expect(λ.isFunction(addToResult)).toBeTruthy(); | ||
@@ -118,3 +120,3 @@ addToResult(items); | ||
var doubleMap = λ.map(doubleUp); | ||
expect(typeof (doubleMap)).toEqual("function"); | ||
expect(λ.isFunction(doubleUp)).toBeTruthy(); | ||
@@ -160,3 +162,3 @@ var result = doubleMap(items); | ||
var multiplyReduce = λ.reduce(multiply); | ||
expect(typeof (multiplyReduce)).toEqual("function"); | ||
expect(λ.isFunction(multiplyReduce)).toBeTruthy(); | ||
@@ -179,3 +181,3 @@ var result = multiplyReduce(items); | ||
var multiplyFoldFrom10 = λ.fold(multiply, 10); | ||
expect(typeof (multiplyFoldFrom10)).toEqual("function"); | ||
expect(λ.isFunction(multiplyFoldFrom10)).toBeTruthy(); | ||
@@ -200,4 +202,4 @@ var result = multiplyFoldFrom10(items); | ||
expect(typeof (biggestAndBest)).toEqual("function"); | ||
expect(typeof (bestSmallest)).toEqual("function"); | ||
expect(λ.isFunction(biggestAndBest)).toBeTruthy(); | ||
expect(λ.isFunction(bestSmallest)).toBeTruthy(); | ||
@@ -215,3 +217,3 @@ expect(biggestAndBest(items)).toEqual(3); | ||
expect(typeof (longest)).toEqual("function"); | ||
expect(λ.isFunction(longest)).toBeTruthy(); | ||
@@ -218,0 +220,0 @@ expect(longest(words)).toEqual("simply"); |
Sorry, the diff of this file is not supported yet
42714
804