Skip to content

Commit

Permalink
feat!: convert to typescript (#28)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
achingbrain committed Oct 17, 2022
1 parent b621056 commit f8a38bf
Show file tree
Hide file tree
Showing 298 changed files with 7,499 additions and 3,134 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
8 changes: 8 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Automerge
on: [ pull_request ]

jobs:
automerge:
uses: protocol/.github/.github/workflows/automerge.yml@master
with:
job: 'automerge'
145 changes: 145 additions & 0 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: test & maybe release
on:
push:
branches:
- master # with #262 - ${{{ github.default_branch }}}
pull_request:
branches:
- master # with #262 - ${{{ github.default_branch }}}

jobs:

check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present lint
- run: npm run --if-present dep-check

test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [16]
fail-fast: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:node
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: node

test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: chrome

test-chrome-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: chrome-webworker

test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: firefox

test-firefox-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: firefox-webworker

test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-main
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: electron-main

test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: electron-renderer

release:
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- uses: ipfs/aegir/actions/docker-login@master
with:
docker-token: ${{ secrets.DOCKER_TOKEN }}
docker-username: ${{ secrets.DOCKER_USERNAME }}
- run: npm run --if-present release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.

MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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

http://www.apache.org/licenses/LICENSE-2.0

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.
19 changes: 19 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
114 changes: 83 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,83 @@
# it

Utility modules to make dealing with async iterators easier, some trivial, some not.

* [blob-to-it](./packages/blob-to-it) Turn a Blob into an iterable
* [browser-readablestream-to-it](./packages/browser-readablestream-to-it) Turn a browser ReadableStream into an iterable
* [it-all](./packages/it-all) Collect the contents of an iterable into an array
* [it-batch](./packages/it-batch) Batch up the contents of an iterable into arrays
* [it-buffer-stream](./packages/it-buffer-stream) Creates an iterable of buffers
* [it-drain](./packages/it-drain) Consume an iterable and ignore any output
* [it-filter](./packages/it-filter) Skip some items in an iterable based on a filter function
* [it-first](./packages/it-first) Return the first item in an iterable
* [it-flat-batch](./packages/it-flat-batch) Take an iterable of variable length arrays and make them all the same length
* [it-foreach](./packages/it-foreach) Invoke a function for every member of an iterable
* [it-glob](./packages/it-glob) Glob matcher for file systems
* [it-last](./packages/it-last) Return the last item in an iterable
* [it-length](./packages/it-length) Consume an iterable and return its length
* [it-map](./packages/it-map) Map the output of an iterable
* [it-merge](./packages/it-merge) Treat multiple iterables as one
* [it-multipart](./packages/it-multipart) Parse multipart message bodies as an iterable
* [it-ndjson](./packages/it-ndjson) Parse multipart message bodies as an iterable
* [it-parallel](./packages/it-parallel) Take an iterable of functions that return promises and run them in parallel up to a concurrency limit
* [it-parallel-batch](./packages/it-parallel-batch) Take an iterable of functions that return promises and run them in parallel in batches
* [it-peekable](./packages/it-peekable) Peek/push an iterable
* [it-reduce](./packages/it-reduce) Reduce the output of an iterable
* [it-skip](./packages/it-skip) Skip items at the start of an iterable
* [it-sort](./packages/it-sort) Sort an iterable using a passed sort function
* [it-split](./packages/it-split) Split an iterable of buffers by linebreaks
* [it-take](./packages/it-take) Limit the number of items you want from an iterable
* [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)
* [it-to-buffer](./packages/it-to-buffer) Takes an iterable of Buffers and concatenates them
# it <!-- omit in toc -->

[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it)
[![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)

> A collection of utilities for making working with iterables more bearable
## Table of contents <!-- omit in toc -->

- [Structure](#structure)
- [License](#license)
- [Contribute](#contribute)

## Structure

- [`/packages/blob-to-it`](./packages/blob-to-it) Turns a blob into an async iterator
- [`/packages/browser-readablestream-to-it`](./packages/browser-readablestream-to-it) Turns a browser readble stream into an async iterator
- [`/packages/it-all`](./packages/it-all) Collects all values from an (async) iterable and returns them as an array
- [`/packages/it-batch`](./packages/it-batch) Takes an async iterator that emits things and emits them as fixed size batches
- [`/packages/it-buffer-stream`](./packages/it-buffer-stream) An async iterator that emits buffers containing bytes up to a certain length
- [`/packages/it-drain`](./packages/it-drain) Empties an async iterator
- [`/packages/it-filter`](./packages/it-filter) Filters the passed iterable by using the filter function
- [`/packages/it-first`](./packages/it-first) Returns the first result from an async iterator
- [`/packages/it-flat-batch`](./packages/it-flat-batch) Takes an async iterator that emits variable length arrays and emits them as fixed size batches
- [`/packages/it-foreach`](./packages/it-foreach) Invokes the passed function for each item in an iterable
- [`/packages/it-glob`](./packages/it-glob) Async iterable filename pattern matcher
- [`/packages/it-last`](./packages/it-last) Returns the last result from an async iterator
- [`/packages/it-length`](./packages/it-length) Counts the number of items in an async iterable
- [`/packages/it-map`](./packages/it-map) Maps the values yielded by an async iterator
- [`/packages/it-merge`](./packages/it-merge) Treat one or more iterables as a single iterable
- [`/packages/it-multipart`](./packages/it-multipart) Async iterable http multipart message parser
- [`/packages/it-ndjson`](./packages/it-ndjson) Parse iterators as ndjson and transform iterators to ndjson
- [`/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
- [`/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
- [`/packages/it-peekable`](./packages/it-peekable) Allows peeking/pushing an iterable
- [`/packages/it-reduce`](./packages/it-reduce) Reduces the values yielded from an async iterator
- [`/packages/it-skip`](./packages/it-skip) Skip items from an iterable
- [`/packages/it-sort`](./packages/it-sort) Collects all values from an async iterator, sorts them using the passed function and yields them
- [`/packages/it-split`](./packages/it-split) Splits Uint8Arrays emitted by an (async) iterable by a delimiter
- [`/packages/it-take`](./packages/it-take) Stop iteration after n items have been received
- [`/packages/it-to-browser-readablestream`](./packages/it-to-browser-readablestream) Takes an async iterator and turns it into a browser readable stream
- [`/packages/it-to-buffer`](./packages/it-to-buffer) Takes an async iterator that yields buffers and concatenates them all together

<!---->

- [blob-to-it](./packages/blob-to-it) Turn a Blob into an iterable
- [browser-readablestream-to-it](./packages/browser-readablestream-to-it) Turn a browser ReadableStream into an iterable
- [it-all](./packages/it-all) Collect the contents of an iterable into an array
- [it-batch](./packages/it-batch) Batch up the contents of an iterable into arrays
- [it-buffer-stream](./packages/it-buffer-stream) Creates an iterable of buffers
- [it-drain](./packages/it-drain) Consume an iterable and ignore any output
- [it-filter](./packages/it-filter) Skip some items in an iterable based on a filter function
- [it-first](./packages/it-first) Return the first item in an iterable
- [it-flat-batch](./packages/it-flat-batch) Take an iterable of variable length arrays and make them all the same length
- [it-foreach](./packages/it-foreach) Invoke a function for every member of an iterable
- [it-glob](./packages/it-glob) Glob matcher for file systems
- [it-last](./packages/it-last) Return the last item in an iterable
- [it-length](./packages/it-length) Consume an iterable and return its length
- [it-map](./packages/it-map) Map the output of an iterable
- [it-merge](./packages/it-merge) Treat multiple iterables as one
- [it-multipart](./packages/it-multipart) Parse multipart message bodies as an iterable
- [it-ndjson](./packages/it-ndjson) Parse multipart message bodies as an iterable
- [it-parallel](./packages/it-parallel) Take an iterable of functions that return promises and run them in parallel up to a concurrency limit
- [it-parallel-batch](./packages/it-parallel-batch) Take an iterable of functions that return promises and run them in parallel in batches
- [it-peekable](./packages/it-peekable) Peek/push an iterable
- [it-reduce](./packages/it-reduce) Reduce the output of an iterable
- [it-skip](./packages/it-skip) Skip items at the start of an iterable
- [it-sort](./packages/it-sort) Sort an iterable using a passed sort function
- [it-split](./packages/it-split) Split an iterable of buffers by linebreaks
- [it-take](./packages/it-take) Limit the number of items you want from an iterable
- [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)
- [it-to-buffer](./packages/it-to-buffer) Takes an iterable of Buffers and concatenates them

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribute

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.
14 changes: 6 additions & 8 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"lerna": "2.9.0",
"packages": [
"packages/*"
],
"lerna": "5.4.0",
"useWorkspaces": true,
"version": "independent",
"command": {
"bootstrap": {
"hoist": true
},
"run": {
"stream": true
}
}
},
"packages": [
"packages/*"
]
}
28 changes: 22 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,38 @@
"name": "it",
"version": "1.0.0",
"description": "A collection of utilities for making working with iterables more bearable",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/achingbrain/it#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/achingbrain/it.git"
},
"bugs": {
"url": "https://github.com/achingbrain/it/issues"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"private": true,
"scripts": {
"postinstall": "lerna bootstrap",
"reset": "lerna run clean && rm -rf packages/*/node_modules packages/*/package-lock.json node_modules",
"reset": "rm -rf packages/*/dist packages/*/node_modules packages/*/package-lock.json node_modules package-lock.json",
"test": "lerna run test",
"coverage": "lerna run coverage",
"build": "lerna run build",
"build": "lerna exec -- tsc && lerna run build",
"deploy": "lerna run deploy",
"start": "NODE_ENV=development lerna run start",
"clean": "lerna run clean",
"lint": "lerna run lint",
"dep-check": "lerna run dep-check",
"check": "lerna run check",
"publish": "lerna publish"
},
"devDependencies": {
"coveralls-lerna": "0.0.5",
"lerna": "^4.0.0"
}
"dependencies": {
"lerna": "^6.0.0"
},
"workspaces": [
"packages/*"
]
}
8 changes: 0 additions & 8 deletions packages/blob-to-it/.npmignore

This file was deleted.

4 changes: 4 additions & 0 deletions packages/blob-to-it/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.

MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions packages/blob-to-it/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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

http://www.apache.org/licenses/LICENSE-2.0

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.
Loading

0 comments on commit f8a38bf

Please sign in to comment.