Comparing version
21
index.js
"use strict"; | ||
var pipe = exports.pipe = function () { | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var compose = _interopRequire(require("fj-compose")); | ||
var pipe = function () { | ||
for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -8,14 +12,5 @@ fns[_key] = arguments[_key]; | ||
return fns.reduce(function (f, g) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return compose.apply(null, fns.reverse()); | ||
}; | ||
return f(g.apply(null, args)); | ||
}; | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
module.exports = pipe; |
{ | ||
"name": "fj-pipe", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Pipe functions, FP style.", | ||
@@ -35,3 +35,6 @@ "main": "index.js", | ||
"mochify": "^2.2.0" | ||
}, | ||
"dependencies": { | ||
"fj-compose": "^1.1.0" | ||
} | ||
} |
23
test.js
"use strict"; | ||
var _interopRequire = function (obj) { | ||
return obj && (obj["default"] || obj); | ||
}; | ||
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; }; | ||
var assert = _interopRequire(require("assert")); | ||
var pipe = require("./").pipe; | ||
var pipe = _interopRequire(require("./")); | ||
var add1 = function (x) { | ||
return x + 1; | ||
}, mult2 = function (x) { | ||
}, | ||
mult2 = function (x) { | ||
return x * 2; | ||
}, square = function (x) { | ||
}, | ||
square = function (x) { | ||
return x * x; | ||
}; | ||
var pipe1 = pipe(add1), pipe2 = pipe(add1, mult2), pipe3 = pipe(add1, mult2, square); | ||
var pipe1 = pipe(add1), | ||
pipe2 = pipe(add1, mult2), | ||
pipe3 = pipe(add1, mult2, square); | ||
@@ -25,4 +26,4 @@ | ||
assert.equal(pipe1(0), 1); | ||
assert.equal(pipe2(1), 3); | ||
assert.equal(pipe3(1), 3); | ||
}); | ||
assert.equal(pipe2(1), 4); | ||
assert.equal(pipe3(1), 16); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6846
0.9%33
10%1
Infinity%57
-9.52%1
Infinity%+ Added
+ Added