An open API service indexing awesome lists of open source software.

https://github.com/tosuke/pline

pipeline for TS
https://github.com/tosuke/pline

Last synced: 5 months ago
JSON representation

pipeline for TS

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