Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Functional composition helpers.
yarn add funcom
compose
Sequential composition of functions invoked in reverse order. Passes return value of the previous function as an argument to the next one.
import { compose } from 'funcom'
const add4 = (a: number) => a + 4
const mult2 = (a: number) => a * 2
const composed = compose(mult2, add4)
console.log(
composed(2)
)
// (2 + 4) * 2 => 12
composeAsync
import { composeAsync } from 'funcom'
const add4Async= (arg: number) => Promise.resolve(arg + 40)
const mult2 = (a: number) => a * 2
const composed = composeAsync(mult2, add4Async)
console.log(
await composed(2)
)
// (2 + 4) * 2 => 12
pipe
Sequential composition of functions invoked in direct order. Passes return value of the previous function as an argument to the next one.
import { pipe } from 'funcom'
const add4 = (a: number) => a + 4
const mult2 = (a: number) => a * 2
const piped = pipe(mult2, add4)
console.log(
piped(2)
)
// (2 * 2) + 4 => 8
pipeAsync
import { pipeAsync } from 'funcom'
const mult2Async = (a: number) => Promise.resolve(a * 2)
const add4 = (a: number) => a + 4
const piped = pipeAsync(mult2Async, add4)
console.log(
await piped(2)
)
// (2 * 2) + 4 => 8
all
Composition of multiple functions invoked with same initial value. Returns an array of results.
import { all } from 'funcom'
const mult2 = (a: number) => a * 2
const add4 = (a: number) => a + 4
const toString = (a: number) => `${a}`
const piped = all(mult2, add4, toString)
console.log(
piped(2)
)
// [8, 6, '2']
allAsync
import { allAsync } from 'funcom'
const mult2 = (a: number) => a * 2
const add4 = (a: number) => a + 4
const toStringAsync = (a: number) => Promise.resolve(`${a}`)
const piped = allAsync(mult2Async, add4, toStringAsync)
console.log(
await piped(2)
)
// [8, 6, '2']
FAQs
Functional composition helpers
The npm package funcom receives a total of 50,453 weekly downloads. As such, funcom popularity was classified as popular.
We found that funcom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.