@sullux/fp-light-spread

0.0.1 • Public • Published

home

fp-light-spread

npm i @sullux/fp-light-spread source test

The spread utility creates a function that accepts an array and spreads the array elements as arguments to the wrapped function.

spread

spread<T>(fn: (...Array<mixed>) => T): (args: Array<mixed>) => T

While this utility doesn't do a complex job, it can help make some functional programming more readable as in the following example.

const { pipe } = require('@sullux/fp-light-pipe')
const { range } = require('@sullux/fp-light-range')
const { spread } = require('@sullux/fp-light-spread')

const print1ToN = pipe(
  range(1),
  spread(console.log)
)

print1ToN(5)
// 1 2 3 4 5

Readme

Keywords

Package Sidebar

Install

npm i @sullux/fp-light-spread

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

1.51 kB

Total Files

3

Last publish

Collaborators

  • sullux