Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blakek/compose

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blakek/compose - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

16

dist/compose.cjs.js

@@ -14,4 +14,18 @@ 'use strict';

}
function pipe(...[fn, ...fns]) {
// All arguments have been exhausted
if (fns.length === 0) {
return fn;
} // Reduce arguments
return async (...args) => compose(...fns)(await fn(...args));
}
var index = {
compose,
pipe
};
exports.compose = compose;
exports.default = compose;
exports.default = index;
exports.pipe = pipe;

@@ -10,4 +10,17 @@ function compose(...[fn, ...fns]) {

}
function pipe(...[fn, ...fns]) {
// All arguments have been exhausted
if (fns.length === 0) {
return fn;
} // Reduce arguments
export default compose;
export { compose };
return async (...args) => compose(...fns)(await fn(...args));
}
var index = {
compose,
pipe
};
export default index;
export { compose, pipe };

@@ -18,2 +18,3 @@ (function (global, factory) {

_exports.compose = compose;
_exports.pipe = pipe;
_exports["default"] = void 0;

@@ -62,4 +63,45 @@

var _default = compose;
function pipe() {
for (var _len2 = arguments.length, _ref3 = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
_ref3[_key2] = arguments[_key2];
}
var fn = _ref3[0],
fns = _ref3.slice(1);
// All arguments have been exhausted
if (fns.length === 0) {
return fn;
} // Reduce arguments
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var _args2 = arguments;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.t0 = compose.apply(void 0, fns);
_context2.next = 3;
return fn.apply(void 0, _args2);
case 3:
_context2.t1 = _context2.sent;
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
case 5:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
}
var index = {
compose: compose,
pipe: pipe
};
var _default = index;
_exports["default"] = _default;
});
export declare function compose(...[fn, ...fns]: Function[]): Function;
export default compose;
export declare function pipe(...[fn, ...fns]: Function[]): Function;
declare const _default: {
compose: typeof compose;
pipe: typeof pipe;
};
export default _default;

2

package.json
{
"name": "@blakek/compose",
"version": "2.0.0",
"version": "3.0.0",
"main": "dist/compose.cjs.js",

@@ -5,0 +5,0 @@ "module": "dist/compose.esm.js",

@@ -8,4 +8,5 @@ # compose

This is an alternative that allows composing a pipeline of functions. It calls
each right-to-left and passes the output from the previous to the next.
This allows composing a pipeline of functions. `compose` calls each function
from right-to-left and passes the output from the previous to the next. `pipe`
is the same, but works from left-to-right.

@@ -29,3 +30,3 @@ ## Install

```js
import { compose } from '@blakek/compose';
import { compose, pipe } from '@blakek/compose';

@@ -39,2 +40,3 @@ const fetchUsers = () =>

// using `compose`
const getUsers = compose(

@@ -45,2 +47,8 @@ users => users.map(user => user.sites.github.username),

// using `pipe`
const getUsersPipe = pipe(
fetchUsers,
users => users.map(user => user.sites.github.username)
);
getUsers().then(console.log); //» [ 'blakek', 'gsandf', 'google' ]

@@ -57,2 +65,8 @@ ```

### `pipe`
```ts
function pipe(...[fn, ...fns]: Function[]): Function;
```
## Contributing

@@ -59,0 +73,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc