
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
pipeline-async
Advanced tools
This package emulates proposed functionality of pipelines in https://github.com/tc39/proposal-pipeline-operator
Some languages offer bash-like pipelines straight out of the box. This allows you to simplify complex operation as you can write
5 | firstFn | secondFn | thirdFn
instead of the typical
thirdFn(secondFn(firstFn(5)))
The first example is arguably more natural to read, since the logic goes from left to right.
While there are many other packages that add pipeline functionality for JS apps, this one is different:
You can call up to 9 pipings at once, but can call the resulting pipeline again with more params for unlimited and/or conditional piping!
import pipe from "pipeline-async";
const basicPipe = pipe(5, x => x + 2, x => x + 1);
const extendedPipe = basicPipe(x => x + 3, x => x + 4); // Does not mutate the original pipe!
You have synchronous pipeline packages, you have asynchronous pipeline packages, but this package supports both.
It has a configurable interface for when you use non-Promise class based promises (import { setConfig }
),
and you never have to deal with it returning a promise, unless one of the pipes returns one!
This behavior is fully supported by the used TS-typing with conditional types.
Works especially well when you're trying to evaluate request, or requests, to server.
const basicPipe = pipe(5, x => x + 2);
console.log(basicPipe()) // prints 7
// You can have multiple asynchronous functions and need only 1 await
const asyncPipe = await basicPipe(async x => x + 4, x => x + 1 /* Does NOT need await/async! */);
console.log(await asyncPipe()) // prints 12
Normally, most libraries will simply evaluate a pipeline, which is fine for most cases, but delayed evaluation may be important for optimization or advanced chaining.
const basicPipe = pipe(5, x => x + 5);
// Does not evaluate yet
console.log(basicPipe) // prints a function
console.log(basicPipe()) // prints 10
If you encounter any bugs, or have ideas for improvement, do not hesitate to add a task or a pull request.
FAQs
Allows for both sync and async pipelines with TS support
The npm package pipeline-async receives a total of 4 weekly downloads. As such, pipeline-async popularity was classified as not popular.
We found that pipeline-async 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.