![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@k88/pipe-compose
Advanced tools
ES6-like pipe, compose, p-pipe, and p-compose in JavaScript, inspired by this Medium post.
This library exports 6 functions: pipe
, compose
, cPipe
, cCompose
, pPipe
, and pCompose
.
To paraphrase the Medium post, image you want to pipe the output of n-functions together. You'll end up with something like:
reverse(get3Chars(uppercase('the-argument')));
// EHT
In this example, you first uppercase
to get THE-ARGUMENT
, then you get3Chars
and have THE
and finally you reverse
it to get EHT
.
With pipe
you can accomplish the same thing using:
pipe('the-argument', uppercase, get3Chars, reverse);
It helps to read this similar to bash's pipe |
:
echo 'the-argument' | uppercase | get3Chars | reverse;
compose
is the reverse of pipe
. For example these two would return the same result.
pipe('the-argument', uppercase, get3Chars, reverse);
compose('the-argument', reverse, get3Chars, uppercase);
These are composable versions of pipe
and compose
, i.e.:
const textModifier = cPipe(uppercase, get3Chars, reverse);
textModifier('the-argument');
// EHT
textModifier('another-argument');
// ONA
There are also composable promise version of the pipe and compose.
const calc = pPipe(add1, multiply2, divide3);
await calc(2);
// 2
In this example, we are creating a calculation function that takes in an number, and performs basic math operation on it. In this case, we are passing 2
and first adding 1 to it (giving us 3), then multiplying by 2 (giving us 6) and finally dividing by 3 (giving us back 2).
As before, pCompose
would work in the reverse:
const calc = pCompose(add1, multiply2, divide3);
await calc(6);
// 5
Install from npm:
npm install @k88/pipe-compose
and use it:
import { pipe, compose } from '@k88/pipe-compose';
All of these auxiliary functions are one-liner, so you can also just copy/paste them into your application:
const pipe = (x, ...fns) => fns.reduce((v, f) => f(v), x);
const compose = (x, ...fns) => fns.reduceRight((v, f) => f(v), x);
const cPipe = (...fns) => (x) => => fns.reduce((v, f) => f(v), x);
const cCompose = (...fns) => (x) => fns.reduceRight((v, f) => f(v), x);
const pPipe = (...fns) => async (x) => fns.reduce(async (v, f) => f(await v), x);
const pCompose = (...fns) => async (x) => fns.reduceRight(async (v, f) => f(await v), x);
FAQs
ES6 pipe and compose in JavScript
The npm package @k88/pipe-compose receives a total of 12,579 weekly downloads. As such, @k88/pipe-compose popularity was classified as popular.
We found that @k88/pipe-compose 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.