Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@raini/pipes
Advanced tools
@raini/pipes
is a set of composable blocks called Pipelines. Pipelines are lazy and do not get invoked until they are forked with process
method.
Pipelines are Monoids and can be concatenated with other Pipelines using p.concat
which allows joining separate sets of composed functions.
pipe
pipeTap
or extendPipe
p.concat
p.concat
and P.empty
promisePipeline.process
returns the only Promise to work withnpm i -S @raini/pipes
import { PromisePipeline } from "@raini/pipes"
import * as rl from "readline"
const addSpaceIfMissing = (q: string): string => (q.endsWith(" ") ? q : q.concat(" "))
const toObject = (q: string) => ({ q })
const createReadLine = () => ({ rl: rl.createInterface(process.stdin, process.stdout) })
const askQuestionAsync = ({ rl, q }) => new Promise((res) => rl.question(q, (a: string) => res(a)))
const applyGreenColor = (x: string) => `\x1b[32m${x}\x1b[0m`
const log = console.log
const exit = () => process.exit(0)
PromisePipeline.of(addSpaceIfMissing)
.pipe(toObject)
.pipeExtend(createReadLine) // Extend argument object with return value
.pipe(askQuestionAsync)
.pipe(applyGreenColor)
.pipeTap(log) // Execute function on the argument and return the argument
.process(() => "What is the answer to life, the universe and everything?")
.then(exit)
PromisePipeline.empty().pipe
PromisePipeline.empty().pipeExtend
PromisePipeline.empty().pipeTap
import { SyncPipeline } from "@raini/pipes"
const isOdd = (num: number) => num % 2 == 0
const negate = <T>(f: (x: T) => any) => (x: T) => !f(x)
const filterOutOddNumbers = (nums: number[]) => nums.filter(negate(isOdd))
const multiplyBy2 = (num: number) => num * 2
const multiplyItemsBy2 = (nums: number[]) => nums.map(multiplyBy2)
const log = console.log
const result = SyncPipeline.of(filterOutOddNumbers)
.pipeTap(log) // [ 1, 3, 5 ]
.pipe(multiplyItemsBy2)
.process(() => [1, 2, 3, 4, 5])
log(result) // [ 2, 6, 10 ]
// A fun thing using pipeExtend (instead of pipe) for multiplying items by 2
const result2 = SyncPipeline.of(filterOutOddNumbers)
.pipeTap(log) // [ 1, 3, 5 ]
.pipeExtend(multiplyItemsBy2)
.process(() => [1, 2, 3, 4, 5])
log(result2) // [ 1, 3, 5, 2, 6, 10 ]
SyncPipeline.empty().pipe
SyncPipeline.empty().pipeExtend
SyncPipeline.empty().pipeTap
FAQs
Simple and reusable pipelines for function composition.
The npm package @raini/pipes receives a total of 6 weekly downloads. As such, @raini/pipes popularity was classified as not popular.
We found that @raini/pipes 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.