https://github.com/jamen/babel-plugin-pull
Transform pipeline operator into pull(...) calls
https://github.com/jamen/babel-plugin-pull
Last synced: 12 months ago
JSON representation
Transform pipeline operator into pull(...) calls
- Host: GitHub
- URL: https://github.com/jamen/babel-plugin-pull
- Owner: jamen
- License: mit
- Created: 2017-05-02T02:05:25.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-02T02:06:50.000Z (about 9 years ago)
- Last Synced: 2025-02-08T02:23:56.250Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-pull
> Transform pipeline operator into `pull(...)` calls
This inspired from similar [pipe](https://github.com/miraks/babel-plugin-pipe-operator) [operator](https://github.com/Swizz/babel-plugin-pipe-operator-curry) [plugins](https://github.com/michaelmitchell/babel-plugin-pipe-composition) to use [`pull-stream`](https://github.com/pull-stream/pull-stream), which provides you a whole ecosystem + [composing them together](#composition)!
## Install
```sh
npm install --save-dev babel-plugin-pull
# with yarn:
yarn add --dev babel-plugin-pull
```
Then load it in your Babel config:
```js
{
"plugins": ["pull"]
}
```
## Usage
It takes input as such:
```js
source()
| through()
| sink()
```
And transforms to:
```js
pull(
source(),
through(),
sink()
)
```
This allows you to use duplex streams, and compose them!
### Composition
You can create streams from other streams:
```js
// Create a source:
var foo = source() | through()
// Create a through:
var bar = through() | through()
// Create a sink:
var qux = through() | through() | sink()
// Reuse any of them in another pipeline:
foo | bar | qux
```
This would transform to:
```js
var foo = pull(source(), through())
var bar = pull(through(), through())
var qux = pull(through(), through(), sink())
pull(foo, bar, qux)
```