https://github.com/tosuke/pline
pipeline for TS
https://github.com/tosuke/pline
Last synced: 5 months ago
JSON representation
pipeline for TS
- Host: GitHub
- URL: https://github.com/tosuke/pline
- Owner: tosuke
- License: mit
- Created: 2019-03-15T02:52:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-15T07:27:09.000Z (over 7 years ago)
- Last Synced: 2025-10-08T20:40:40.991Z (9 months ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pline - pipelining for TS/JS
## Example
```typescript
import { pipe, pipeline } from 'pline'
function flatMap(f: (x: T) => Array): (array: Array) => Array {
return (array: Array) => {
let result = []
array.forEach(x => {
result = [...result, ...f(x)]
})
return result
}
}
function map(f: (x: T) => U): (array: Array) => Array {
return (array: Array) => array.map(f)
}
const result = [1, 2, 3][pipe](
flatMap(x => [x, x * 10]),
map(x => `${x}`)
) // ["1", "10", "2", "20", "3", "30"]
// also
const func = pipeline(
flatMap(x => [x, x * 10]),
map(x => `${x}`)
)
const result = func([1, 2, 3])
```
## Features
- Chain functions like ["|>" Pipeline operator](https://github.com/tc39/proposal-pipeline-operator)
- Compose functions
## How to install
```sh
$ npm install pline
// yarn add pline
```
## Documentation
### `pipe`
chain functions
### `pipeline`
compose functions