包详细信息

@kysley/js-pipe

kysley14MIT1.0.1

Compose N sequence of operations, giving the output as an input for the next operation.

compose, function-composition, pipe, pipeline

自述文件

js-pipe

Compose over functions to help create negative code

Compose N sequence of operations, giving the output as an input for the next operation.

Install

$ npm install @kysley/js-pipe
$ yarn add @kysley/js-pipe

Usage

import pipe from '@kysley/js-pipe'

const capatalize = txt => txt.toUpperCase()
const addNum = txt => `${txt}1`
const res = pipe(capatalize, addNum)

console.log(res('Hello World')) //Hello World1

API

pipe(fn1, fn2, fn3, ...)

Returns the final value from the sequence of functions, using the output for the input of the next operation until finished.

fnx

Type: Function

Iterated over sequentially until the sequence is finished.

License

MIT © Evan Kysley