@blakek/compose
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -8,7 +8,7 @@ 'use strict'; | ||
if (fns.length === 0) { | ||
return async (...args) => fn(...args); | ||
return fn; | ||
} // Reduce arguments | ||
return async (...args) => compose(...fns)(await fn(...args)); | ||
return async (...args) => fn(await compose(...fns)(...args)); | ||
} | ||
@@ -15,0 +15,0 @@ |
function compose(...[fn, ...fns]) { | ||
// All arguments have been exhausted | ||
if (fns.length === 0) { | ||
return async (...args) => fn(...args); | ||
return fn; | ||
} // Reduce arguments | ||
return async (...args) => compose(...fns)(await fn(...args)); | ||
return async (...args) => fn(await compose(...fns)(...args)); | ||
} | ||
@@ -10,0 +10,0 @@ |
@@ -34,40 +34,26 @@ (function (global, factory) { | ||
if (fns.length === 0) { | ||
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var _args = arguments; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", fn.apply(void 0, _args)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return fn; | ||
} // Reduce arguments | ||
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { | ||
var _args2 = arguments; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var _args = arguments; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context2.t0 = compose.apply(void 0, fns); | ||
_context2.next = 3; | ||
return fn.apply(void 0, _args2); | ||
_context.t0 = fn; | ||
_context.next = 3; | ||
return compose.apply(void 0, fns).apply(void 0, _args); | ||
case 3: | ||
_context2.t1 = _context2.sent; | ||
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1)); | ||
_context.t1 = _context.sent; | ||
return _context.abrupt("return", (0, _context.t0)(_context.t1)); | ||
case 5: | ||
case "end": | ||
return _context2.stop(); | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
}, _callee); | ||
})); | ||
@@ -74,0 +60,0 @@ } |
{ | ||
"name": "@blakek/compose", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"main": "dist/compose.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/compose.esm.js", |
@@ -9,3 +9,3 @@ # compose | ||
This is an alternative that allows composing a pipeline of functions. It calls | ||
each in order and passes the output from the previous to the next. | ||
each right-to-left and passes the output from the previous to the next. | ||
@@ -39,4 +39,4 @@ ## Install | ||
const getUsers = compose( | ||
fetchUsers, | ||
users => users.map(user => user.sites.github.username) | ||
users => users.map(user => user.sites.github.username), | ||
fetchUsers | ||
); | ||
@@ -43,0 +43,0 @@ |
Sorry, the diff of this file is not supported yet
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
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
101520
75