
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
fish-operator
Advanced tools
The (>=>) and (<=<) operators in JavaScript. Kinda.
npm install fish-operator
The first parameter of these functions is the string or Symbol key of the bind method for the objects returned by the functions to compose. A bind method will have the signature bind :: (A -> m<B>) -> m<B> for a given m<A>. For Promises, this will be the then method so you will pass in 'then' as the first parameter. The following examples show this idea using Promise-returning functions:
const { compose, pipe } = require('fish-operator');
const f = x => Promise.resolve(x + 1);
const g = x => Promise.resolve(x * 2);
const h = compose('then')(f, g);
await h(10);
// <- 21
const j = pipe('then')(f, g);
await h(10);
// <- 22
In the real world, you would probably use these functions like this:
const { pipe } = require('fish-operator');
const pipeP = pipe('then');
const prop = key => obj => obj[key];
// Fictitious Promise-returning API functions...
const getUserById = _id => Promise.resolve({ _id, name: 'Susan', jobId: 2 });
const getJobById = _id => Promise.resolve({ _id, name: 'Rattlesnake Groomer' });
const getJobByUserId = pipeP(getUserById, prop('jobId'), getJobById, prop('name'));
await getJobByUserId(10);
// <- 'Rattlesnake Groomer'
Each function accepts any number of functions that return either a value or an object with a method that matches the bindKey parameter given.
WTFPL
FAQs
Kleisli composition in JS
We found that fish-operator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.