Comparing version 0.7.0 to 0.8.0-build
107
build/fn.js
(function(root, factory) { | ||
if(typeof exports === 'object') { | ||
module.exports = factory(); | ||
} | ||
else if(typeof define === 'function' && define.amd) { | ||
define([], factory); | ||
} | ||
else { | ||
root.fn = factory(); | ||
} | ||
}(this, function() { | ||
if (typeof define === 'function' && define.amd) { | ||
define(factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(require, exports, module); | ||
} else { | ||
root.fn = factory(); | ||
} | ||
}(this, function(require, exports, module) { | ||
'use strict'; | ||
var fn = {}; | ||
var fn = { }; | ||
fn.toArray = function (collection) { | ||
return [].slice.call(collection); | ||
return [ ].slice.call(collection); | ||
}; | ||
@@ -36,3 +34,5 @@ | ||
'==': function (value1, value2) { | ||
/*eslint-disable eqeqeq */ | ||
return value1 == value2; | ||
/*eslint-enable eqeqeq */ | ||
}, | ||
@@ -49,3 +49,3 @@ '===': function (value1, value2) { | ||
'' + value : | ||
({}).toString.call(value).slice(8, -1).toLowerCase(); | ||
{ }.toString.call(value).slice(8, -1).toLowerCase(); | ||
}; | ||
@@ -64,3 +64,3 @@ | ||
return args[0].concat.apply(args[0], args.slice(1)); | ||
return args[ 0 ].concat.apply(args[ 0 ], args.slice(1)); | ||
}; | ||
@@ -70,3 +70,3 @@ | ||
var args = fn.toArray(arguments); | ||
var handler = args[0]; | ||
var handler = args[ 0 ]; | ||
var partialArgs = args.slice(1); | ||
@@ -79,32 +79,43 @@ | ||
fn.curry = function (handler, arity) { | ||
if (handler.curried) { | ||
return handler; | ||
} | ||
fn.identity = function (arg) { | ||
return arg; | ||
}; | ||
arity = arity || handler.length; | ||
var currier = function makeCurry(rightward) { | ||
return function (handler, arity) { | ||
if (handler.curried) { | ||
return handler; | ||
} | ||
var curry = function curry() { | ||
var args = fn.toArray(arguments); | ||
arity = arity || handler.length; | ||
if (args.length >= arity) { | ||
return handler.apply(null, args); | ||
} | ||
var curry = function curry() { | ||
var args = fn.toArray(arguments); | ||
var inner = function () { | ||
return curry.apply(null, args.concat(fn.toArray(arguments))); | ||
if (args.length >= arity) { | ||
var transform = rightward ? 'reverse' : 'identity'; | ||
return fn.apply(handler, fn[ transform ](args)); | ||
} | ||
var inner = function () { | ||
return fn.apply(curry, args.concat(fn.toArray(arguments))); | ||
}; | ||
inner.curried = true; | ||
return inner; | ||
}; | ||
inner.curried = true; | ||
curry.curried = true; | ||
return inner; | ||
return curry; | ||
}; | ||
}; | ||
curry.curried = true; | ||
fn.curry = currier(false); | ||
return curry; | ||
}; | ||
fn.curryRight = currier(true); | ||
fn.properties = function (object) { | ||
var accumulator = []; | ||
var accumulator = [ ]; | ||
@@ -122,3 +133,3 @@ for (var property in object) { | ||
for (var index = 0, collectionLength = collection.length; index < collectionLength; index++) { | ||
fn.apply(handler, fn.concat([ collection[index], index, collection ], params)); | ||
fn.apply(handler, fn.concat([ collection[ index ], index, collection ], params)); | ||
} | ||
@@ -139,7 +150,7 @@ }; | ||
return accumulator; | ||
}, [], collection); | ||
}, [ ], collection); | ||
}; | ||
fn.op['++'] = fn.partial(fn.op['+'], 1); | ||
fn.op['--'] = fn.partial(fn.op['+'], -1); | ||
fn.op[ '++' ] = fn.partial(fn.op[ '+' ], 1); | ||
fn.op[ '--' ] = fn.partial(fn.op[ '+' ], -1); | ||
@@ -150,3 +161,3 @@ fn.map = function (handler, collection, params) { | ||
return accumulator; | ||
}, [], collection); | ||
}, [ ], collection); | ||
}; | ||
@@ -164,3 +175,3 @@ | ||
return [ fn.apply(func, args) ]; | ||
}, fn.toArray(arguments), functions)[0]; | ||
}, fn.toArray(arguments), functions)[ 0 ]; | ||
}; | ||
@@ -174,3 +185,3 @@ }; | ||
fn.prop = fn.curry(function (name, object) { | ||
return object[name]; | ||
return object[ name ]; | ||
}); | ||
@@ -181,11 +192,11 @@ | ||
fn.each(function (property) { | ||
accumulator[property] = value[property]; | ||
accumulator[ property ] = value[ property ]; | ||
}, fn.properties(value)); | ||
return accumulator; | ||
}, {}, fn.toArray(arguments)); | ||
}, { }, fn.toArray(arguments)); | ||
}; | ||
fn.memoize = function memoize(handler, serializer) { | ||
var cache = {}; | ||
var cache = { }; | ||
@@ -197,4 +208,4 @@ return function () { | ||
return key in cache ? | ||
cache[key] : | ||
cache[key] = fn.apply(handler, args); | ||
cache[ key ] : | ||
cache[ key ] = fn.apply(handler, args); | ||
}; | ||
@@ -204,3 +215,3 @@ }; | ||
fn.memoize.serialize = function (values) { | ||
return fn.type(values[0]) + '|' + JSON.stringify(values[0]); | ||
return fn.type(values[ 0 ]) + '|' + JSON.stringify(values[ 0 ]); | ||
}; | ||
@@ -266,3 +277,3 @@ | ||
return fn; | ||
})); | ||
return fn; | ||
})); |
{ | ||
"name": "fn.js", | ||
"version": "0.7.0", | ||
"version": "0.8.0-build", | ||
"description": "Functional programming strategy library for JavaScript", | ||
@@ -24,10 +24,15 @@ "main": "build/fn.js", | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt-bump": "0.0.11", | ||
"grunt-umd": "~1.1.0", | ||
"grunt-contrib-jshint": "~0.6.2", | ||
"grunt-cafe-mocha": "~0.1.8", | ||
"chai": "~1.7.2" | ||
"gulp": "^3.6.2", | ||
"gulp-load-plugins": "^0.5.1", | ||
"gulp-bump": "^0.1.8", | ||
"gulp-git": "^0.4.2", | ||
"yargs": "^1.2.2", | ||
"gulp-wrap-umd": "^0.2.0", | ||
"gulp-mocha": "^0.4.1", | ||
"chai": "^1.9.1", | ||
"eslint": "^0.6.2", | ||
"gulp-eslint": "^0.1.7", | ||
"gulp-rename": "^1.2.0" | ||
}, | ||
"dependencies": {} | ||
} |
'use strict'; | ||
var fn = {}; | ||
var fn = { }; | ||
fn.toArray = function (collection) { | ||
return [].slice.call(collection); | ||
return [ ].slice.call(collection); | ||
}; | ||
@@ -25,3 +25,5 @@ | ||
'==': function (value1, value2) { | ||
/*eslint-disable eqeqeq */ | ||
return value1 == value2; | ||
/*eslint-enable eqeqeq */ | ||
}, | ||
@@ -38,3 +40,3 @@ '===': function (value1, value2) { | ||
'' + value : | ||
({}).toString.call(value).slice(8, -1).toLowerCase(); | ||
{ }.toString.call(value).slice(8, -1).toLowerCase(); | ||
}; | ||
@@ -53,3 +55,3 @@ | ||
return args[0].concat.apply(args[0], args.slice(1)); | ||
return args[ 0 ].concat.apply(args[ 0 ], args.slice(1)); | ||
}; | ||
@@ -59,3 +61,3 @@ | ||
var args = fn.toArray(arguments); | ||
var handler = args[0]; | ||
var handler = args[ 0 ]; | ||
var partialArgs = args.slice(1); | ||
@@ -68,32 +70,43 @@ | ||
fn.curry = function (handler, arity) { | ||
if (handler.curried) { | ||
return handler; | ||
} | ||
fn.identity = function (arg) { | ||
return arg; | ||
}; | ||
arity = arity || handler.length; | ||
var currier = function makeCurry(rightward) { | ||
return function (handler, arity) { | ||
if (handler.curried) { | ||
return handler; | ||
} | ||
var curry = function curry() { | ||
var args = fn.toArray(arguments); | ||
arity = arity || handler.length; | ||
if (args.length >= arity) { | ||
return handler.apply(null, args); | ||
} | ||
var curry = function curry() { | ||
var args = fn.toArray(arguments); | ||
var inner = function () { | ||
return curry.apply(null, args.concat(fn.toArray(arguments))); | ||
if (args.length >= arity) { | ||
var transform = rightward ? 'reverse' : 'identity'; | ||
return fn.apply(handler, fn[ transform ](args)); | ||
} | ||
var inner = function () { | ||
return fn.apply(curry, args.concat(fn.toArray(arguments))); | ||
}; | ||
inner.curried = true; | ||
return inner; | ||
}; | ||
inner.curried = true; | ||
curry.curried = true; | ||
return inner; | ||
return curry; | ||
}; | ||
}; | ||
curry.curried = true; | ||
fn.curry = currier(false); | ||
return curry; | ||
}; | ||
fn.curryRight = currier(true); | ||
fn.properties = function (object) { | ||
var accumulator = []; | ||
var accumulator = [ ]; | ||
@@ -111,3 +124,3 @@ for (var property in object) { | ||
for (var index = 0, collectionLength = collection.length; index < collectionLength; index++) { | ||
fn.apply(handler, fn.concat([ collection[index], index, collection ], params)); | ||
fn.apply(handler, fn.concat([ collection[ index ], index, collection ], params)); | ||
} | ||
@@ -128,7 +141,7 @@ }; | ||
return accumulator; | ||
}, [], collection); | ||
}, [ ], collection); | ||
}; | ||
fn.op['++'] = fn.partial(fn.op['+'], 1); | ||
fn.op['--'] = fn.partial(fn.op['+'], -1); | ||
fn.op[ '++' ] = fn.partial(fn.op[ '+' ], 1); | ||
fn.op[ '--' ] = fn.partial(fn.op[ '+' ], -1); | ||
@@ -139,3 +152,3 @@ fn.map = function (handler, collection, params) { | ||
return accumulator; | ||
}, [], collection); | ||
}, [ ], collection); | ||
}; | ||
@@ -153,3 +166,3 @@ | ||
return [ fn.apply(func, args) ]; | ||
}, fn.toArray(arguments), functions)[0]; | ||
}, fn.toArray(arguments), functions)[ 0 ]; | ||
}; | ||
@@ -163,3 +176,3 @@ }; | ||
fn.prop = fn.curry(function (name, object) { | ||
return object[name]; | ||
return object[ name ]; | ||
}); | ||
@@ -170,11 +183,11 @@ | ||
fn.each(function (property) { | ||
accumulator[property] = value[property]; | ||
accumulator[ property ] = value[ property ]; | ||
}, fn.properties(value)); | ||
return accumulator; | ||
}, {}, fn.toArray(arguments)); | ||
}, { }, fn.toArray(arguments)); | ||
}; | ||
fn.memoize = function memoize(handler, serializer) { | ||
var cache = {}; | ||
var cache = { }; | ||
@@ -186,4 +199,4 @@ return function () { | ||
return key in cache ? | ||
cache[key] : | ||
cache[key] = fn.apply(handler, args); | ||
cache[ key ] : | ||
cache[ key ] = fn.apply(handler, args); | ||
}; | ||
@@ -193,3 +206,3 @@ }; | ||
fn.memoize.serialize = function (values) { | ||
return fn.type(values[0]) + '|' + JSON.stringify(values[0]); | ||
return fn.type(values[ 0 ]) + '|' + JSON.stringify(values[ 0 ]); | ||
}; | ||
@@ -196,0 +209,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42452
39
1211
11
1
1