Skip to content

Commit f8a38bf

Browse files
authored
feat!: convert to typescript (#28)
Converts all modules to typescript. There should be no API changes, but the modules are all now ESM-only. BREAKING CHANGE: all modules are now published as ESM-only
1 parent b621056 commit f8a38bf

File tree

298 files changed

+7499
-3134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

298 files changed

+7499
-3134
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "10:00"
8+
open-pull-requests-limit: 10
9+
commit-message:
10+
prefix: "deps"
11+
prefix-development: "deps(dev)"

.github/workflows/automerge.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Automerge
2+
on: [ pull_request ]
3+
4+
jobs:
5+
automerge:
6+
uses: protocol/.github/.github/workflows/automerge.yml@master
7+
with:
8+
job: 'automerge'
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: test & maybe release
2+
on:
3+
push:
4+
branches:
5+
- master # with #262 - ${{{ github.default_branch }}}
6+
pull_request:
7+
branches:
8+
- master # with #262 - ${{{ github.default_branch }}}
9+
10+
jobs:
11+
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v3
17+
with:
18+
node-version: lts/*
19+
- uses: ipfs/aegir/actions/cache-node-modules@master
20+
- run: npm run --if-present lint
21+
- run: npm run --if-present dep-check
22+
23+
test-node:
24+
needs: check
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
os: [windows-latest, ubuntu-latest, macos-latest]
29+
node: [16]
30+
fail-fast: true
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-node@v3
34+
with:
35+
node-version: ${{ matrix.node }}
36+
- uses: ipfs/aegir/actions/cache-node-modules@master
37+
- run: npm run --if-present test:node
38+
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
39+
with:
40+
flags: node
41+
42+
test-chrome:
43+
needs: check
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v3
47+
- uses: actions/setup-node@v3
48+
with:
49+
node-version: lts/*
50+
- uses: ipfs/aegir/actions/cache-node-modules@master
51+
- run: npm run --if-present test:chrome
52+
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
53+
with:
54+
flags: chrome
55+
56+
test-chrome-webworker:
57+
needs: check
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v3
61+
- uses: actions/setup-node@v3
62+
with:
63+
node-version: lts/*
64+
- uses: ipfs/aegir/actions/cache-node-modules@master
65+
- run: npm run --if-present test:chrome-webworker
66+
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
67+
with:
68+
flags: chrome-webworker
69+
70+
test-firefox:
71+
needs: check
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v3
75+
- uses: actions/setup-node@v3
76+
with:
77+
node-version: lts/*
78+
- uses: ipfs/aegir/actions/cache-node-modules@master
79+
- run: npm run --if-present test:firefox
80+
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
81+
with:
82+
flags: firefox
83+
84+
test-firefox-webworker:
85+
needs: check
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v3
89+
- uses: actions/setup-node@v3
90+
with:
91+
node-version: lts/*
92+
- uses: ipfs/aegir/actions/cache-node-modules@master
93+
- run: npm run --if-present test:firefox-webworker
94+
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
95+
with:
96+
flags: firefox-webworker
97+
98+
test-electron-main:
99+
needs: check
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: actions/checkout@v3
103+
- uses: actions/setup-node@v3
104+
with:
105+
node-version: lts/*
106+
- uses: ipfs/aegir/actions/cache-node-modules@master
107+
- run: npx xvfb-maybe npm run --if-present test:electron-main
108+
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
109+
with:
110+
flags: electron-main
111+
112+
test-electron-renderer:
113+
needs: check
114+
runs-on: ubuntu-latest
115+
steps:
116+
- uses: actions/checkout@v3
117+
- uses: actions/setup-node@v3
118+
with:
119+
node-version: lts/*
120+
- uses: ipfs/aegir/actions/cache-node-modules@master
121+
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
122+
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
123+
with:
124+
flags: electron-renderer
125+
126+
release:
127+
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
128+
runs-on: ubuntu-latest
129+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
130+
steps:
131+
- uses: actions/checkout@v3
132+
with:
133+
fetch-depth: 0
134+
- uses: actions/setup-node@v3
135+
with:
136+
node-version: lts/*
137+
- uses: ipfs/aegir/actions/cache-node-modules@master
138+
- uses: ipfs/aegir/actions/docker-login@master
139+
with:
140+
docker-token: ${{ secrets.DOCKER_TOKEN }}
141+
docker-username: ${{ secrets.DOCKER_USERNAME }}
142+
- run: npm run --if-present release
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

LICENSE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This project is dual licensed under MIT and Apache-2.0.
2+
3+
MIT: https://www.opensource.org/licenses/mit
4+
Apache-2.0: https://www.apache.org/licenses/license-2.0

LICENSE-APACHE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
2+
3+
http://www.apache.org/licenses/LICENSE-2.0
4+
5+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

LICENSE-MIT

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 83 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,83 @@
1-
# it
2-
3-
Utility modules to make dealing with async iterators easier, some trivial, some not.
4-
5-
* [blob-to-it](./packages/blob-to-it) Turn a Blob into an iterable
6-
* [browser-readablestream-to-it](./packages/browser-readablestream-to-it) Turn a browser ReadableStream into an iterable
7-
* [it-all](./packages/it-all) Collect the contents of an iterable into an array
8-
* [it-batch](./packages/it-batch) Batch up the contents of an iterable into arrays
9-
* [it-buffer-stream](./packages/it-buffer-stream) Creates an iterable of buffers
10-
* [it-drain](./packages/it-drain) Consume an iterable and ignore any output
11-
* [it-filter](./packages/it-filter) Skip some items in an iterable based on a filter function
12-
* [it-first](./packages/it-first) Return the first item in an iterable
13-
* [it-flat-batch](./packages/it-flat-batch) Take an iterable of variable length arrays and make them all the same length
14-
* [it-foreach](./packages/it-foreach) Invoke a function for every member of an iterable
15-
* [it-glob](./packages/it-glob) Glob matcher for file systems
16-
* [it-last](./packages/it-last) Return the last item in an iterable
17-
* [it-length](./packages/it-length) Consume an iterable and return its length
18-
* [it-map](./packages/it-map) Map the output of an iterable
19-
* [it-merge](./packages/it-merge) Treat multiple iterables as one
20-
* [it-multipart](./packages/it-multipart) Parse multipart message bodies as an iterable
21-
* [it-ndjson](./packages/it-ndjson) Parse multipart message bodies as an iterable
22-
* [it-parallel](./packages/it-parallel) Take an iterable of functions that return promises and run them in parallel up to a concurrency limit
23-
* [it-parallel-batch](./packages/it-parallel-batch) Take an iterable of functions that return promises and run them in parallel in batches
24-
* [it-peekable](./packages/it-peekable) Peek/push an iterable
25-
* [it-reduce](./packages/it-reduce) Reduce the output of an iterable
26-
* [it-skip](./packages/it-skip) Skip items at the start of an iterable
27-
* [it-sort](./packages/it-sort) Sort an iterable using a passed sort function
28-
* [it-split](./packages/it-split) Split an iterable of buffers by linebreaks
29-
* [it-take](./packages/it-take) Limit the number of items you want from an iterable
30-
* [it-to-browser-readablestream](./packages/it-to-browser-readablestream) Turns an iterable into a WhatWG [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
31-
* [it-to-buffer](./packages/it-to-buffer) Takes an iterable of Buffers and concatenates them
1+
# it <!-- omit in toc -->
2+
3+
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it)
4+
[![CI](https://img.shields.io/github/workflow/status/achingbrain/it/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml)
5+
6+
> A collection of utilities for making working with iterables more bearable
7+
8+
## Table of contents <!-- omit in toc -->
9+
10+
- [Structure](#structure)
11+
- [License](#license)
12+
- [Contribute](#contribute)
13+
14+
## Structure
15+
16+
- [`/packages/blob-to-it`](./packages/blob-to-it) Turns a blob into an async iterator
17+
- [`/packages/browser-readablestream-to-it`](./packages/browser-readablestream-to-it) Turns a browser readble stream into an async iterator
18+
- [`/packages/it-all`](./packages/it-all) Collects all values from an (async) iterable and returns them as an array
19+
- [`/packages/it-batch`](./packages/it-batch) Takes an async iterator that emits things and emits them as fixed size batches
20+
- [`/packages/it-buffer-stream`](./packages/it-buffer-stream) An async iterator that emits buffers containing bytes up to a certain length
21+
- [`/packages/it-drain`](./packages/it-drain) Empties an async iterator
22+
- [`/packages/it-filter`](./packages/it-filter) Filters the passed iterable by using the filter function
23+
- [`/packages/it-first`](./packages/it-first) Returns the first result from an async iterator
24+
- [`/packages/it-flat-batch`](./packages/it-flat-batch) Takes an async iterator that emits variable length arrays and emits them as fixed size batches
25+
- [`/packages/it-foreach`](./packages/it-foreach) Invokes the passed function for each item in an iterable
26+
- [`/packages/it-glob`](./packages/it-glob) Async iterable filename pattern matcher
27+
- [`/packages/it-last`](./packages/it-last) Returns the last result from an async iterator
28+
- [`/packages/it-length`](./packages/it-length) Counts the number of items in an async iterable
29+
- [`/packages/it-map`](./packages/it-map) Maps the values yielded by an async iterator
30+
- [`/packages/it-merge`](./packages/it-merge) Treat one or more iterables as a single iterable
31+
- [`/packages/it-multipart`](./packages/it-multipart) Async iterable http multipart message parser
32+
- [`/packages/it-ndjson`](./packages/it-ndjson) Parse iterators as ndjson and transform iterators to ndjson
33+
- [`/packages/it-parallel`](./packages/it-parallel) Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input
34+
- [`/packages/it-parallel-batch`](./packages/it-parallel-batch) Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input
35+
- [`/packages/it-peekable`](./packages/it-peekable) Allows peeking/pushing an iterable
36+
- [`/packages/it-reduce`](./packages/it-reduce) Reduces the values yielded from an async iterator
37+
- [`/packages/it-skip`](./packages/it-skip) Skip items from an iterable
38+
- [`/packages/it-sort`](./packages/it-sort) Collects all values from an async iterator, sorts them using the passed function and yields them
39+
- [`/packages/it-split`](./packages/it-split) Splits Uint8Arrays emitted by an (async) iterable by a delimiter
40+
- [`/packages/it-take`](./packages/it-take) Stop iteration after n items have been received
41+
- [`/packages/it-to-browser-readablestream`](./packages/it-to-browser-readablestream) Takes an async iterator and turns it into a browser readable stream
42+
- [`/packages/it-to-buffer`](./packages/it-to-buffer) Takes an async iterator that yields buffers and concatenates them all together
43+
44+
<!---->
45+
46+
- [blob-to-it](./packages/blob-to-it) Turn a Blob into an iterable
47+
- [browser-readablestream-to-it](./packages/browser-readablestream-to-it) Turn a browser ReadableStream into an iterable
48+
- [it-all](./packages/it-all) Collect the contents of an iterable into an array
49+
- [it-batch](./packages/it-batch) Batch up the contents of an iterable into arrays
50+
- [it-buffer-stream](./packages/it-buffer-stream) Creates an iterable of buffers
51+
- [it-drain](./packages/it-drain) Consume an iterable and ignore any output
52+
- [it-filter](./packages/it-filter) Skip some items in an iterable based on a filter function
53+
- [it-first](./packages/it-first) Return the first item in an iterable
54+
- [it-flat-batch](./packages/it-flat-batch) Take an iterable of variable length arrays and make them all the same length
55+
- [it-foreach](./packages/it-foreach) Invoke a function for every member of an iterable
56+
- [it-glob](./packages/it-glob) Glob matcher for file systems
57+
- [it-last](./packages/it-last) Return the last item in an iterable
58+
- [it-length](./packages/it-length) Consume an iterable and return its length
59+
- [it-map](./packages/it-map) Map the output of an iterable
60+
- [it-merge](./packages/it-merge) Treat multiple iterables as one
61+
- [it-multipart](./packages/it-multipart) Parse multipart message bodies as an iterable
62+
- [it-ndjson](./packages/it-ndjson) Parse multipart message bodies as an iterable
63+
- [it-parallel](./packages/it-parallel) Take an iterable of functions that return promises and run them in parallel up to a concurrency limit
64+
- [it-parallel-batch](./packages/it-parallel-batch) Take an iterable of functions that return promises and run them in parallel in batches
65+
- [it-peekable](./packages/it-peekable) Peek/push an iterable
66+
- [it-reduce](./packages/it-reduce) Reduce the output of an iterable
67+
- [it-skip](./packages/it-skip) Skip items at the start of an iterable
68+
- [it-sort](./packages/it-sort) Sort an iterable using a passed sort function
69+
- [it-split](./packages/it-split) Split an iterable of buffers by linebreaks
70+
- [it-take](./packages/it-take) Limit the number of items you want from an iterable
71+
- [it-to-browser-readablestream](./packages/it-to-browser-readablestream) Turns an iterable into a WhatWG [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
72+
- [it-to-buffer](./packages/it-to-buffer) Takes an iterable of Buffers and concatenates them
73+
74+
## License
75+
76+
Licensed under either of
77+
78+
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
79+
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
80+
81+
## Contribute
82+
83+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

lerna.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{
2-
"lerna": "2.9.0",
3-
"packages": [
4-
"packages/*"
5-
],
2+
"lerna": "5.4.0",
3+
"useWorkspaces": true,
64
"version": "independent",
75
"command": {
8-
"bootstrap": {
9-
"hoist": true
10-
},
116
"run": {
127
"stream": true
138
}
14-
}
9+
},
10+
"packages": [
11+
"packages/*"
12+
]
1513
}

package.json

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,38 @@
22
"name": "it",
33
"version": "1.0.0",
44
"description": "A collection of utilities for making working with iterables more bearable",
5+
"license": "Apache-2.0 OR MIT",
6+
"homepage": "https://github.com/achingbrain/it#readme",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/achingbrain/it.git"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/achingbrain/it/issues"
13+
},
14+
"engines": {
15+
"node": ">=16.0.0",
16+
"npm": ">=7.0.0"
17+
},
518
"private": true,
619
"scripts": {
720
"postinstall": "lerna bootstrap",
8-
"reset": "lerna run clean && rm -rf packages/*/node_modules packages/*/package-lock.json node_modules",
21+
"reset": "rm -rf packages/*/dist packages/*/node_modules packages/*/package-lock.json node_modules package-lock.json",
922
"test": "lerna run test",
1023
"coverage": "lerna run coverage",
11-
"build": "lerna run build",
24+
"build": "lerna exec -- tsc && lerna run build",
1225
"deploy": "lerna run deploy",
1326
"start": "NODE_ENV=development lerna run start",
1427
"clean": "lerna run clean",
1528
"lint": "lerna run lint",
29+
"dep-check": "lerna run dep-check",
1630
"check": "lerna run check",
1731
"publish": "lerna publish"
1832
},
19-
"devDependencies": {
20-
"coveralls-lerna": "0.0.5",
21-
"lerna": "^4.0.0"
22-
}
33+
"dependencies": {
34+
"lerna": "^6.0.0"
35+
},
36+
"workspaces": [
37+
"packages/*"
38+
]
2339
}

packages/blob-to-it/.npmignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)