Skip to content

Commit

Permalink
fix!: do not create unnecessary async work (#66)
Browse files Browse the repository at this point in the history
Crossing async boundaries is not free, so when this module is passed
synchronous pipeline stages, do not wrap them in async generators
to keep them synchronous.

BREAKING CHANGE: when the entire pipeline is synchronous, the return value will now be synchronous
  • Loading branch information
achingbrain authored Mar 31, 2023
1 parent 0ea9837 commit e583174
Show file tree
Hide file tree
Showing 5 changed files with 658 additions and 157 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
node_modules
coverage
.nyc_output
package-lock.json
build
dist
.docs
.coverage
node_modules
package-lock.json
yarn.lock
.vscode
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# it-pipe <!-- omit in toc -->

[![codecov](https://img.shields.io/codecov/c/github/alanshaw/it-pipe.svg?style=flat-square)](https://codecov.io/gh/alanshaw/it-pipe)
[![CI](https://img.shields.io/github/workflow/status/alanshaw/it-pipe/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/alanshaw/it-pipe/actions/workflows/js-test-and-release.yml)
[![CI](https://img.shields.io/github/actions/workflow/status/alanshaw/it-pipe/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/alanshaw/it-pipe/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)

> Utility to "pipe" async iterables together
## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Usage](#usage)
- [API](#api)
- [`pipe(firstFn, ...fns)`](#pipefirstfn-fns)
- [Contribute](#contribute)
- [API Docs](#api-docs)
- [License](#license)
- [Contribution](#contribution)

Expand All @@ -21,6 +22,14 @@
$ npm i it-pipe
```

### Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `ItPipe` in the global namespace.

```html
<script src="https://unpkg.com/it-pipe/dist/index.min.js"></script>
```

Based on this definition of streaming iterables <https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9>.

Almost identical to the [`pipeline`](https://github.com/bustle/streaming-iterables#pipeline) function from the [`streaming-iterables`](https://www.npmjs.com/package/streaming-iterables) module except that it supports duplex streams *and* will automatically wrap a "source" as the first param in a function.
Expand Down Expand Up @@ -65,9 +74,9 @@ Note:
- `firstFn` may be a `Function` or an `Iterable`
- `firstFn` or any of `fns` may be a [duplex object](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it) (an object with a `sink` and `source`).

## Contribute
## API Docs

Feel free to dive in! [Open an issue](https://github.com/alanshaw/it-pipe/issues/new) or submit PRs.
- <https://alanshaw.github.io/it-pipe>

## License

Expand Down
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"types": "./dist/src/index.d.ts",
"files": [
"src",
"dist/src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
Expand Down Expand Up @@ -144,18 +144,20 @@
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:node": "aegir test -t node --cov",
"test:electron-main": "aegir test -t electron-main",
"release": "aegir release"
"release": "aegir release",
"docs": "aegir docs"
},
"dependencies": {
"it-merge": "^2.0.0",
"it-pushable": "^3.1.0",
"it-stream-types": "^1.0.3"
"it-merge": "^3.0.0",
"it-pushable": "^3.1.0"
},
"devDependencies": {
"aegir": "^37.4.8",
"aegir": "^38.1.8",
"delay": "^5.0.0",
"it-all": "^2.0.0",
"it-drain": "^2.0.0",
"it-all": "^3.0.0",
"it-drain": "^3.0.0",
"it-map": "^3.0.0",
"it-stream-types": "^1.0.3",
"p-defer": "^4.0.0",
"streaming-iterables": "^7.0.4"
}
Expand Down
Loading

0 comments on commit e583174

Please sign in to comment.