https://github.com/jcoreio/pipeline
pure-js alternative to pipeline operator, with type defs
https://github.com/jcoreio/pipeline
Last synced: 8 months ago
JSON representation
pure-js alternative to pipeline operator, with type defs
- Host: GitHub
- URL: https://github.com/jcoreio/pipeline
- Owner: jcoreio
- License: mit
- Created: 2020-01-26T17:27:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T16:07:03.000Z (over 3 years ago)
- Last Synced: 2025-07-03T22:42:51.041Z (11 months ago)
- Language: JavaScript
- Size: 2.46 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @jcoreio/pipeline
[](https://circleci.com/gh/jcoreio/pipeline)
[](https://codecov.io/gh/jcoreio/pipeline)
[](https://github.com/semantic-release/semantic-release)
[](http://commitizen.github.io/cz-cli/)
[](https://badge.fury.io/js/%40jcoreio%2Fpipeline)
Pure JS alternative to pipeline operator, for use until the competing proposals have been settled/TypeScript supports it.
TypeScript and Flow type defs are included with overloads for up to 30 operator functions.
```
import pipeline from '@jcoreio/pipeline'
console.log(
pipeline(
'{"foo": "34.567"}',
JSON.parse,
x => x.foo,
parseFloat,
Math.ceil
)
)
// prints 35
```
You can use `lodash/flow` for the same purpose, but it doesn't have the same ergonomics as the pipeline operator,
because the input comes at the end instead of the beginning:
```
import flow from 'lodash/flow'
flow(
JSON.parse,
x => x.foo,
parseFloat,
Math.ceil
)('{"foo": "34.567"}')
```