Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@priestine/pipeline
Advanced tools
@priestine/pipeline
is a set of inverted monoids which are built from a composition of handlers called middleware and a data entry point called process.
The main goal of this package is a proof of concept that simplified representation of functional composition can lower the functional programming entry level. It also abstracts asynchrony by resolving Promises passed from one middleware to another.
The Pipeline can be concatenated with other Pipelines with concat
which enables multiple sets of middleware to be composed together.
concat
undefined
or null
, result of previous computation is passed to the next middlewarep.concat(o)
p.empty()
and P.empty()
npm i -S @priestine/pipeline
import { Pipeline } from "@priestine/pipeline";
import * as readline from "readline";
const addSpaceIfMissing = question => (question.charAt(question.length - 1) == " " ? question : question.concat(" "));
const transformToContextObject = question => ({ question });
const createReadlineInterface = ctx => ({
...ctx,
rl: readline.createInterface(process.stdin, process.stdout),
});
const askQuestionAsync = ({ rl, question }) =>
new Promise(res => rl.question(question, (answer: string) => res(answer)));
const makeAnswerGreen = (answer: string) => `\x1b[32m${answer}\x1b[0m`;
const logToConsole = (answer: string) => console.log(answer);
const exit = () => process.exit(0);
Pipeline.from([
addSpaceIfMissing,
transformToContextObject,
createReadlineInterface,
askQuestionAsync,
makeAnswerGreen,
logToConsole,
])
.process("What is the answer to life, the universe and everything?")
.then(exit);
import { Pipeline } from "@priestine/pipeline";
const isOdd = (num: number) => num % 2 == 0;
const negate = (f: Function) => (x: any) => !f(x);
const mockFetch = (x: string): Promise<number[]> => new Promise(resolve => resolve([1, 2, 3, 4, 5]));
const filterOutOddNumbers = (nums: number[]): number[] => nums.filter(negate(isOdd));
const logToConsole = (answer: number[]): void => console.log(answer);
Pipeline.of(mockFetch)
.pipe(filterOutOddNumbers)
.pipe(logToConsole)
.process("https://example.com/arbitrary-numbers")
.catch(console.error);
FAQs
Simple and reusable pipelines with abstracted asynchrony
The npm package @priestine/pipeline receives a total of 9 weekly downloads. As such, @priestine/pipeline popularity was classified as not popular.
We found that @priestine/pipeline 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
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.