diff --git a/README.md b/README.md index 68e91551..cce3fcc8 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,4 @@ Licensed under either of ## Contribution 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. + diff --git a/packages/blob-to-it/CHANGELOG.md b/packages/blob-to-it/CHANGELOG.md index bc6b277b..fda9e259 100644 --- a/packages/blob-to-it/CHANGELOG.md +++ b/packages/blob-to-it/CHANGELOG.md @@ -1,3 +1,15 @@ +## [blob-to-it-v2.0.2](https://github.com/achingbrain/it/compare/blob-to-it-v2.0.1...blob-to-it-v2.0.2) (2023-03-30) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [blob-to-it-v2.0.1](https://github.com/achingbrain/it/compare/blob-to-it-v2.0.0...blob-to-it-v2.0.1) (2023-03-02) diff --git a/packages/blob-to-it/package.json b/packages/blob-to-it/package.json index ff2c8fe6..5a2eac07 100644 --- a/packages/blob-to-it/package.json +++ b/packages/blob-to-it/package.json @@ -1,6 +1,6 @@ { "name": "blob-to-it", - "version": "2.0.1", + "version": "2.0.2", "description": "Turns a blob into an async iterator", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-all/CHANGELOG.md b/packages/it-all/CHANGELOG.md index b207a016..e158f1db 100644 --- a/packages/it-all/CHANGELOG.md +++ b/packages/it-all/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-all-v3.0.1](https://github.com/achingbrain/it/compare/it-all-v3.0.0...it-all-v3.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-all-v3.0.0](https://github.com/achingbrain/it/compare/it-all-v2.0.1...it-all-v3.0.0) (2023-03-30) diff --git a/packages/it-all/package.json b/packages/it-all/package.json index 93e8a4f4..d0ed218b 100644 --- a/packages/it-all/package.json +++ b/packages/it-all/package.json @@ -1,6 +1,6 @@ { "name": "it-all", - "version": "3.0.0", + "version": "3.0.1", "description": "Collects all values from an (async) iterable and returns them as an array", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-all/src/index.ts b/packages/it-all/src/index.ts index 39086678..a8293746 100644 --- a/packages/it-all/src/index.ts +++ b/packages/it-all/src/index.ts @@ -6,8 +6,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * Collects all values from an (async) iterable and returns them as an array */ function all (source: Iterable): T[] -function all (source: AsyncIterable): Promise -function all (source: AsyncIterable | Iterable): Promise | T[] { +function all (source: Iterable | AsyncIterable): Promise +function all (source: Iterable | AsyncIterable): Promise | T[] { if (isAsyncIterable(source)) { return (async () => { const arr = [] diff --git a/packages/it-batch/CHANGELOG.md b/packages/it-batch/CHANGELOG.md index c1de2258..483d7db5 100644 --- a/packages/it-batch/CHANGELOG.md +++ b/packages/it-batch/CHANGELOG.md @@ -1,3 +1,24 @@ +## [it-batch-v3.0.0](https://github.com/achingbrain/it/compare/it-batch-v2.0.1...it-batch-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-batch-v2.0.1](https://github.com/achingbrain/it/compare/it-batch-v2.0.0...it-batch-v2.0.1) (2023-03-02) diff --git a/packages/it-batch/package.json b/packages/it-batch/package.json index e5b89d92..34576bdb 100644 --- a/packages/it-batch/package.json +++ b/packages/it-batch/package.json @@ -1,6 +1,6 @@ { "name": "it-batch", - "version": "2.0.1", + "version": "3.0.0", "description": "Takes an async iterator that emits things and emits them as fixed size batches", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-batch/src/index.ts b/packages/it-batch/src/index.ts index 9af276ea..7915414b 100644 --- a/packages/it-batch/src/index.ts +++ b/packages/it-batch/src/index.ts @@ -7,8 +7,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * emits those things in fixed-sized batches */ function batch (source: Iterable, size?: number): Generator -function batch (source: AsyncIterable | Iterable, size?: number): AsyncGenerator -function batch (source: AsyncIterable | Iterable, size: number = 1): Generator | AsyncGenerator { +function batch (source: Iterable | AsyncIterable, size?: number): AsyncGenerator +function batch (source: Iterable | AsyncIterable, size: number = 1): Generator | AsyncGenerator { size = Number(size) if (isAsyncIterable(source)) { diff --git a/packages/it-batched-bytes/CHANGELOG.md b/packages/it-batched-bytes/CHANGELOG.md index b77a500e..f4b16b9b 100644 --- a/packages/it-batched-bytes/CHANGELOG.md +++ b/packages/it-batched-bytes/CHANGELOG.md @@ -1,3 +1,24 @@ +## [it-batched-bytes-v2.0.0](https://github.com/achingbrain/it/compare/it-batched-bytes-v1.0.1...it-batched-bytes-v2.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-batched-bytes-v1.0.1](https://github.com/achingbrain/it/compare/it-batched-bytes-v1.0.0...it-batched-bytes-v1.0.1) (2023-03-02) diff --git a/packages/it-batched-bytes/package.json b/packages/it-batched-bytes/package.json index b5e684e0..615e2e4a 100644 --- a/packages/it-batched-bytes/package.json +++ b/packages/it-batched-bytes/package.json @@ -1,6 +1,6 @@ { "name": "it-batched-bytes", - "version": "1.0.1", + "version": "2.0.0", "description": "Takes an async iterator that emits byte arrays and emits them as fixed size batches", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-batched-bytes/src/index.ts b/packages/it-batched-bytes/src/index.ts index 29007930..ca8341e1 100644 --- a/packages/it-batched-bytes/src/index.ts +++ b/packages/it-batched-bytes/src/index.ts @@ -35,7 +35,7 @@ export interface AsyncBatchedBytesOptions extends BatchedBytesOptions { * or the next event loop tick occurs, yield any bytes from the buffer. */ function batchedBytes (source: Iterable, options?: BatchedBytesOptions): Iterable -function batchedBytes (source: AsyncIterable, options?: AsyncBatchedBytesOptions): AsyncIterable +function batchedBytes (source: Iterable | AsyncIterable, options?: AsyncBatchedBytesOptions): AsyncIterable function batchedBytes (source: Iterable | AsyncIterable, options: AsyncBatchedBytesOptions = {}): AsyncIterable | Iterable { if (isAsyncIterable(source)) { return (async function * () { diff --git a/packages/it-buffer-stream/CHANGELOG.md b/packages/it-buffer-stream/CHANGELOG.md index 7b06adbf..b2ddc481 100644 --- a/packages/it-buffer-stream/CHANGELOG.md +++ b/packages/it-buffer-stream/CHANGELOG.md @@ -1,3 +1,15 @@ +## [it-buffer-stream-v3.0.2](https://github.com/achingbrain/it/compare/it-buffer-stream-v3.0.1...it-buffer-stream-v3.0.2) (2023-03-30) + + +### Bug Fixes + +* fix argument typo ([#57](https://github.com/achingbrain/it/issues/57)) ([a031dea](https://github.com/achingbrain/it/commit/a031dea54cbfb466b64602f41fcd4e934679e750)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + ## [it-buffer-stream-v3.0.1](https://github.com/achingbrain/it/compare/it-buffer-stream-v3.0.0...it-buffer-stream-v3.0.1) (2023-03-02) diff --git a/packages/it-buffer-stream/package.json b/packages/it-buffer-stream/package.json index 3c651a95..fa2b3c1d 100644 --- a/packages/it-buffer-stream/package.json +++ b/packages/it-buffer-stream/package.json @@ -1,6 +1,6 @@ { "name": "it-buffer-stream", - "version": "3.0.1", + "version": "3.0.2", "description": "An async iterator that emits buffers containing bytes up to a certain length", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-buffer-stream/src/index.ts b/packages/it-buffer-stream/src/index.ts index 9c4181ef..cadbf0ca 100644 --- a/packages/it-buffer-stream/src/index.ts +++ b/packages/it-buffer-stream/src/index.ts @@ -3,7 +3,7 @@ import randomBytes from 'iso-random-stream/src/random.js' export interface BufferStreamOptions { chunkSize?: number collector?: (arr: Uint8Array) => void - generator?: (lenght: number) => Uint8Array | Promise + generator?: (length: number) => Uint8Array | Promise } const defaultOptions: Required = { diff --git a/packages/it-drain/CHANGELOG.md b/packages/it-drain/CHANGELOG.md index d747a002..e1d48d7c 100644 --- a/packages/it-drain/CHANGELOG.md +++ b/packages/it-drain/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-drain-v3.0.1](https://github.com/achingbrain/it/compare/it-drain-v3.0.0...it-drain-v3.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-drain-v3.0.0](https://github.com/achingbrain/it/compare/it-drain-v2.0.1...it-drain-v3.0.0) (2023-03-30) diff --git a/packages/it-drain/package.json b/packages/it-drain/package.json index ce04e99c..7c04d978 100644 --- a/packages/it-drain/package.json +++ b/packages/it-drain/package.json @@ -1,6 +1,6 @@ { "name": "it-drain", - "version": "3.0.0", + "version": "3.0.1", "description": "Empties an async iterator", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-drain/src/index.ts b/packages/it-drain/src/index.ts index c2ea2979..b27527a9 100644 --- a/packages/it-drain/src/index.ts +++ b/packages/it-drain/src/index.ts @@ -7,8 +7,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * anything */ function drain (source: Iterable): void -function drain (source: AsyncIterable): Promise -function drain (source: AsyncIterable | Iterable): Promise | void { +function drain (source: Iterable | AsyncIterable): Promise +function drain (source: Iterable | AsyncIterable): Promise | void { if (isAsyncIterable(source)) { return (async () => { for await (const _ of source) { } // eslint-disable-line no-unused-vars,no-empty,@typescript-eslint/no-unused-vars diff --git a/packages/it-filter/CHANGELOG.md b/packages/it-filter/CHANGELOG.md index e6247a92..e9904bd5 100644 --- a/packages/it-filter/CHANGELOG.md +++ b/packages/it-filter/CHANGELOG.md @@ -1,3 +1,26 @@ +## [it-filter-v3.0.0](https://github.com/achingbrain/it/compare/it-filter-v2.0.2...it-filter-v3.0.0) (2023-03-31) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator and a synchronous filter function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#58](https://github.com/achingbrain/it/issues/58)) ([cdd84b4](https://github.com/achingbrain/it/commit/cdd84b4fd6ad746a2c11ecfbe176b628a541b619)), closes [#55](https://github.com/achingbrain/it/issues/55) + +## [it-filter-v2.0.2](https://github.com/achingbrain/it/compare/it-filter-v2.0.1...it-filter-v2.0.2) (2023-03-30) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-filter-v2.0.1](https://github.com/achingbrain/it/compare/it-filter-v2.0.0...it-filter-v2.0.1) (2023-03-02) diff --git a/packages/it-filter/README.md b/packages/it-filter/README.md index 91ce989a..5a57f7fd 100644 --- a/packages/it-filter/README.md +++ b/packages/it-filter/README.md @@ -33,10 +33,27 @@ Loading this module through a script tag will make it's exports available as `It import all from 'it-all' import filter from 'it-filter' -// This can also be an iterator, async iterator, generator, etc +// This can also be an iterator, generator, etc const values = [0, 1, 2, 3, 4] -const fn = val => val > 2 // Return boolean or promise of boolean to keep item +const fn = val => val > 2 // Return boolean to keep item + +const arr = all(filter(values, fn)) + +console.info(arr) // 3, 4 +``` + +Async sources and filter functions must be awaited: + +```javascript +import all from 'it-all' +import filter from 'it-filter' + +const values = async function * () { + yield * [0, 1, 2, 3, 4] +} + +const fn = async val => val > 2 // Return boolean or promise of boolean to keep item const arr = await all(filter(values, fn)) diff --git a/packages/it-filter/package.json b/packages/it-filter/package.json index 3b1e5ede..a7be9c88 100644 --- a/packages/it-filter/package.json +++ b/packages/it-filter/package.json @@ -1,6 +1,6 @@ { "name": "it-filter", - "version": "2.0.1", + "version": "3.0.0", "description": "Filters the passed iterable by using the filter function", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", @@ -134,6 +134,9 @@ "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", "release": "aegir release" }, + "dependencies": { + "it-peekable": "^3.0.0" + }, "devDependencies": { "aegir": "^38.1.7", "it-all": "^3.0.0" diff --git a/packages/it-filter/src/index.ts b/packages/it-filter/src/index.ts index 471ce25b..d5507138 100644 --- a/packages/it-filter/src/index.ts +++ b/packages/it-filter/src/index.ts @@ -1,11 +1,60 @@ +import peek from 'it-peekable' + +function isAsyncIterable (thing: any): thing is AsyncIterable { + return thing[Symbol.asyncIterator] != null +} /** * Filters the passed (async) iterable by using the filter function */ -export default async function * filter (source: AsyncIterable | Iterable, fn: (val: T) => boolean | Promise): AsyncGenerator { - for await (const entry of source) { - if (await fn(entry)) { - yield entry - } +function filter (source: Iterable, fn: (val: T) => Promise): AsyncGenerator +function filter (source: Iterable, fn: (val: T) => boolean): Generator +function filter (source: Iterable | AsyncIterable, fn: (val: T) => boolean | Promise): AsyncGenerator +function filter (source: Iterable | AsyncIterable, fn: (val: T) => boolean | Promise): Generator | AsyncGenerator { + if (isAsyncIterable(source)) { + return (async function * () { + for await (const entry of source) { + if (await fn(entry)) { + yield entry + } + } + })() + } + + // if mapping function returns a promise we have to return an async generator + const peekable = peek(source) + const { value, done } = peekable.next() + + if (done === true) { + return (function * () {}()) + } + + const res = fn(value) + + // @ts-expect-error .then is not present on O + if (typeof res.then === 'function') { + return (async function * () { + if (await res) { + yield value + } + + for await (const entry of peekable) { + if (await fn(entry)) { + yield entry + } + } + })() } + + const func = fn as (val: T) => boolean + + return (function * () { + for (const entry of source) { + if (func(entry)) { + yield entry + } + } + })() } + +export default filter diff --git a/packages/it-filter/test/index.spec.ts b/packages/it-filter/test/index.spec.ts index 1efebf08..762f190c 100644 --- a/packages/it-filter/test/index.spec.ts +++ b/packages/it-filter/test/index.spec.ts @@ -2,20 +2,47 @@ import { expect } from 'aegir/chai' import all from 'it-all' import filter from '../src/index.js' +function * values (): Generator { + yield * [0, 1, 2, 3, 4] +} + +async function * asyncValues (): AsyncGenerator { + yield * values() +} + describe('it-filter', () => { it('should filter all values greater than 2', async () => { - const values = [0, 1, 2, 3, 4] + const res = all(filter(values(), val => val > 2)) + + expect(res[Symbol.iterator]).to.be.ok() + expect(res).to.deep.equal([3, 4]) + }) - const res = await all(filter(values, val => val > 2)) + it('should filter all values greater than 2 with a promise', () => { + const res = all(filter(values(), val => val > 2)) + expect(res[Symbol.iterator]).to.be.ok() expect(res).to.deep.equal([3, 4]) }) it('should filter all values greater than 2 with a promise', async () => { - const values = [0, 1, 2, 3, 4] + const res = filter(values(), async val => val > 2) - const res = await all(filter(values, async val => val > 2)) + expect(res[Symbol.asyncIterator]).to.be.ok() + await expect(all(res)).to.eventually.deep.equal([3, 4]) + }) - expect(res).to.deep.equal([3, 4]) + it('should filter all async values greater than 2', async () => { + const res = filter(asyncValues(), val => val > 2) + + expect(res[Symbol.asyncIterator]).to.be.ok() + await expect(all(res)).to.eventually.deep.equal([3, 4]) + }) + + it('should filter all async values greater than 2 with a promise', async () => { + const res = filter(asyncValues(), async val => val > 2) + + expect(res[Symbol.asyncIterator]).to.be.ok() + await expect(all(res)).to.eventually.deep.equal([3, 4]) }) }) diff --git a/packages/it-first/CHANGELOG.md b/packages/it-first/CHANGELOG.md index 2277c468..065aed05 100644 --- a/packages/it-first/CHANGELOG.md +++ b/packages/it-first/CHANGELOG.md @@ -1,3 +1,19 @@ +## [it-first-v3.0.0](https://github.com/achingbrain/it/compare/it-first-v2.0.1...it-first-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + ## [it-first-v2.0.1](https://github.com/achingbrain/it/compare/it-first-v2.0.0...it-first-v2.0.1) (2023-03-02) diff --git a/packages/it-first/package.json b/packages/it-first/package.json index 079b11c9..0d0d824a 100644 --- a/packages/it-first/package.json +++ b/packages/it-first/package.json @@ -1,6 +1,6 @@ { "name": "it-first", - "version": "2.0.1", + "version": "3.0.0", "description": "Returns the first result from an async iterator", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-first/src/index.ts b/packages/it-first/src/index.ts index 02f5b53c..aba9bc8d 100644 --- a/packages/it-first/src/index.ts +++ b/packages/it-first/src/index.ts @@ -7,8 +7,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * case returns `undefined` */ function first (source: Iterable): T | undefined -function first (source: AsyncIterable): Promise -function first (source: AsyncIterable | Iterable): Promise | T | undefined { +function first (source: Iterable | AsyncIterable): Promise +function first (source: Iterable | AsyncIterable): Promise | T | undefined { if (isAsyncIterable(source)) { return (async () => { for await (const entry of source) { // eslint-disable-line no-unreachable-loop diff --git a/packages/it-flat-batch/CHANGELOG.md b/packages/it-flat-batch/CHANGELOG.md index 10273972..8fba9050 100644 --- a/packages/it-flat-batch/CHANGELOG.md +++ b/packages/it-flat-batch/CHANGELOG.md @@ -1,3 +1,24 @@ +## [it-flat-batch-v3.0.0](https://github.com/achingbrain/it/compare/it-flat-batch-v2.0.1...it-flat-batch-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-flat-batch-v2.0.1](https://github.com/achingbrain/it/compare/it-flat-batch-v2.0.0...it-flat-batch-v2.0.1) (2023-03-02) diff --git a/packages/it-flat-batch/package.json b/packages/it-flat-batch/package.json index 5d9ec88a..82b1b465 100644 --- a/packages/it-flat-batch/package.json +++ b/packages/it-flat-batch/package.json @@ -1,6 +1,6 @@ { "name": "it-flat-batch", - "version": "2.0.1", + "version": "3.0.0", "description": "Takes an async iterator that emits variable length arrays and emits them as fixed size batches", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-flat-batch/src/index.ts b/packages/it-flat-batch/src/index.ts index f9712133..9ed67552 100644 --- a/packages/it-flat-batch/src/index.ts +++ b/packages/it-flat-batch/src/index.ts @@ -7,8 +7,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * returns an async iterable that emits those things in fixed-size batches */ function batch (source: Iterable, batchSize?: number): Generator -function batch (source: AsyncIterable, batchSize?: number): AsyncGenerator -function batch (source: AsyncIterable | Iterable, batchSize: number = 1): AsyncGenerator | Generator { +function batch (source: Iterable | AsyncIterable, batchSize?: number): AsyncGenerator +function batch (source: Iterable | AsyncIterable, batchSize: number = 1): AsyncGenerator | Generator { let size = parseInt(`${batchSize}`) if (isNaN(size) || size < 1) { diff --git a/packages/it-foreach/CHANGELOG.md b/packages/it-foreach/CHANGELOG.md index 4e2c570e..18b12d8a 100644 --- a/packages/it-foreach/CHANGELOG.md +++ b/packages/it-foreach/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-foreach-v2.0.1](https://github.com/achingbrain/it/compare/it-foreach-v2.0.0...it-foreach-v2.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-foreach-v2.0.0](https://github.com/achingbrain/it/compare/it-foreach-v1.0.1...it-foreach-v2.0.0) (2023-03-30) diff --git a/packages/it-foreach/package.json b/packages/it-foreach/package.json index 0737399e..5f8654e7 100644 --- a/packages/it-foreach/package.json +++ b/packages/it-foreach/package.json @@ -1,6 +1,6 @@ { "name": "it-foreach", - "version": "2.0.0", + "version": "2.0.1", "description": "Invokes the passed function for each item in an iterable", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-foreach/src/index.ts b/packages/it-foreach/src/index.ts index 78aed5c9..7d8d2ba3 100644 --- a/packages/it-foreach/src/index.ts +++ b/packages/it-foreach/src/index.ts @@ -9,8 +9,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { */ function forEach (source: Iterable, fn: (thing: T) => Promise): AsyncGenerator function forEach (source: Iterable, fn: (thing: T) => void): Generator -function forEach (source: AsyncIterable, fn: (thing: T) => void | Promise): AsyncGenerator -function forEach (source: AsyncIterable | Iterable, fn: (thing: T) => void | Promise): AsyncGenerator | Generator { +function forEach (source: Iterable | AsyncIterable, fn: (thing: T) => void | Promise): AsyncGenerator +function forEach (source: Iterable | AsyncIterable, fn: (thing: T) => void | Promise): AsyncGenerator | Generator { if (isAsyncIterable(source)) { return (async function * () { for await (const thing of source) { diff --git a/packages/it-last/CHANGELOG.md b/packages/it-last/CHANGELOG.md index 09e756a9..e2b261cb 100644 --- a/packages/it-last/CHANGELOG.md +++ b/packages/it-last/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-last-v3.0.1](https://github.com/achingbrain/it/compare/it-last-v3.0.0...it-last-v3.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-last-v3.0.0](https://github.com/achingbrain/it/compare/it-last-v2.0.1...it-last-v3.0.0) (2023-03-30) diff --git a/packages/it-last/package.json b/packages/it-last/package.json index 19cb6238..70b2c3d9 100644 --- a/packages/it-last/package.json +++ b/packages/it-last/package.json @@ -1,6 +1,6 @@ { "name": "it-last", - "version": "3.0.0", + "version": "3.0.1", "description": "Returns the last result from an async iterator", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-last/src/index.ts b/packages/it-last/src/index.ts index 4b855a3d..82550c98 100644 --- a/packages/it-last/src/index.ts +++ b/packages/it-last/src/index.ts @@ -7,8 +7,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * return `undefined` */ function last (source: Iterable): T | undefined -function last (source: AsyncIterable): Promise -function last (source: AsyncIterable | Iterable): Promise | T | undefined { +function last (source: Iterable | AsyncIterable): Promise +function last (source: Iterable | AsyncIterable): Promise | T | undefined { if (isAsyncIterable(source)) { return (async () => { let res diff --git a/packages/it-length/CHANGELOG.md b/packages/it-length/CHANGELOG.md index 6cbaf414..5023855a 100644 --- a/packages/it-length/CHANGELOG.md +++ b/packages/it-length/CHANGELOG.md @@ -1,3 +1,19 @@ +## [it-length-v3.0.0](https://github.com/achingbrain/it/compare/it-length-v2.0.1...it-length-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + ## [it-length-v2.0.1](https://github.com/achingbrain/it/compare/it-length-v2.0.0...it-length-v2.0.1) (2023-03-02) diff --git a/packages/it-length/package.json b/packages/it-length/package.json index 2286eae9..397d6c4f 100644 --- a/packages/it-length/package.json +++ b/packages/it-length/package.json @@ -1,6 +1,6 @@ { "name": "it-length", - "version": "2.0.1", + "version": "3.0.0", "description": "Counts the number of items in an async iterable", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-length/src/index.ts b/packages/it-length/src/index.ts index 1751a508..215840f2 100644 --- a/packages/it-length/src/index.ts +++ b/packages/it-length/src/index.ts @@ -6,8 +6,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * Consumes the passed iterator and returns the number of items it contained */ function length (source: Iterable): number -function length (source: AsyncIterable): Promise -function length (source: AsyncIterable | Iterable): Promise | number { +function length (source: Iterable | AsyncIterable): Promise +function length (source: Iterable | AsyncIterable): Promise | number { if (isAsyncIterable(source)) { return (async () => { let count = 0 diff --git a/packages/it-map/CHANGELOG.md b/packages/it-map/CHANGELOG.md index a26e20bb..0e77efc3 100644 --- a/packages/it-map/CHANGELOG.md +++ b/packages/it-map/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-map-v3.0.1](https://github.com/achingbrain/it/compare/it-map-v3.0.0...it-map-v3.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-map-v3.0.0](https://github.com/achingbrain/it/compare/it-map-v2.0.1...it-map-v3.0.0) (2023-03-30) diff --git a/packages/it-map/package.json b/packages/it-map/package.json index e54ccdf2..33512a00 100644 --- a/packages/it-map/package.json +++ b/packages/it-map/package.json @@ -1,6 +1,6 @@ { "name": "it-map", - "version": "3.0.0", + "version": "3.0.1", "description": "Maps the values yielded by an async iterator", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-map/src/index.ts b/packages/it-map/src/index.ts index 2aebfb3d..ff3f6d1f 100644 --- a/packages/it-map/src/index.ts +++ b/packages/it-map/src/index.ts @@ -10,7 +10,7 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { */ function map (source: Iterable, func: (val: I) => Promise): AsyncGenerator function map (source: Iterable, func: (val: I) => O): Generator -function map (source: AsyncIterable, func: (val: I) => O | Promise): AsyncGenerator +function map (source: AsyncIterable | Iterable, func: (val: I) => O | Promise): AsyncGenerator function map (source: AsyncIterable | Iterable, func: (val: I) => O | Promise): AsyncGenerator | Generator { if (isAsyncIterable(source)) { return (async function * () { diff --git a/packages/it-map/test/index.spec.ts b/packages/it-map/test/index.spec.ts index 773c911c..902bdb75 100644 --- a/packages/it-map/test/index.spec.ts +++ b/packages/it-map/test/index.spec.ts @@ -1,13 +1,21 @@ import { expect } from 'aegir/chai' import map from '../src/index.js' +async function * asyncGenerator (): AsyncGenerator { + yield 1 +} + +function * generator (): Generator { + yield 1 +} + +async function * source (): Generator | AsyncGenerator { + yield 1 +} + describe('it-map', () => { it('should map an async iterator', async () => { - const iter = async function * (): AsyncGenerator { - yield 1 - } - - const gen = map(iter(), (val) => val + 1) + const gen = map(asyncGenerator(), (val) => val + 1) expect(gen[Symbol.asyncIterator]).to.be.ok() for await (const result of gen) { @@ -16,11 +24,7 @@ describe('it-map', () => { }) it('should map an async iterator to a promise', async () => { - const iter = async function * (): AsyncGenerator { - yield 1 - } - - const gen = map(iter(), async (val) => val + 1) + const gen = map(asyncGenerator(), async (val) => val + 1) expect(gen[Symbol.asyncIterator]).to.be.ok() for await (const result of gen) { @@ -29,11 +33,7 @@ describe('it-map', () => { }) it('should map an iterator', () => { - const iter = function * (): Generator { - yield 1 - } - - const gen = map(iter(), (val) => val + 1) + const gen = map(generator(), (val) => val + 1) expect(gen[Symbol.iterator]).to.be.ok() for (const result of gen) { @@ -42,11 +42,16 @@ describe('it-map', () => { }) it('should map an iterator to a promise', async () => { - const iter = function * (): Generator { - yield 1 + const gen = map(generator(), async (val) => val + 1) + expect(gen[Symbol.asyncIterator]).to.be.ok() + + for await (const result of gen) { + expect(result).to.equal(2) } + }) - const gen = map(iter(), async (val) => val + 1) + it('should map a source', async () => { + const gen = map(source(), (val) => val + 1) expect(gen[Symbol.asyncIterator]).to.be.ok() for await (const result of gen) { diff --git a/packages/it-multipart/CHANGELOG.md b/packages/it-multipart/CHANGELOG.md index bccd231e..c87e681a 100644 --- a/packages/it-multipart/CHANGELOG.md +++ b/packages/it-multipart/CHANGELOG.md @@ -1,3 +1,15 @@ +## [it-multipart-v3.0.2](https://github.com/achingbrain/it/compare/it-multipart-v3.0.1...it-multipart-v3.0.2) (2023-03-30) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([a76da40](https://github.com/achingbrain/it/commit/a76da40c6a230adeda777760ad4266c68a721a77)) + ## [it-multipart-v3.0.1](https://github.com/achingbrain/it/compare/it-multipart-v3.0.0...it-multipart-v3.0.1) (2023-03-02) diff --git a/packages/it-multipart/package.json b/packages/it-multipart/package.json index 9299dfd1..eed1ab8e 100644 --- a/packages/it-multipart/package.json +++ b/packages/it-multipart/package.json @@ -1,6 +1,6 @@ { "name": "it-multipart", - "version": "3.0.1", + "version": "3.0.2", "description": "Async iterable http multipart message parser", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-ndjson/CHANGELOG.md b/packages/it-ndjson/CHANGELOG.md index bef3cd38..fc1954b7 100644 --- a/packages/it-ndjson/CHANGELOG.md +++ b/packages/it-ndjson/CHANGELOG.md @@ -1,3 +1,15 @@ +## [it-ndjson-v1.0.2](https://github.com/achingbrain/it/compare/it-ndjson-v1.0.1...it-ndjson-v1.0.2) (2023-03-30) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-ndjson-v1.0.1](https://github.com/achingbrain/it/compare/it-ndjson-v1.0.0...it-ndjson-v1.0.1) (2023-03-02) diff --git a/packages/it-ndjson/package.json b/packages/it-ndjson/package.json index 8eefd35a..35036dac 100644 --- a/packages/it-ndjson/package.json +++ b/packages/it-ndjson/package.json @@ -1,6 +1,6 @@ { "name": "it-ndjson", - "version": "1.0.1", + "version": "1.0.2", "description": "Parse iterators as ndjson and transform iterators to ndjson", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-parallel-batch/CHANGELOG.md b/packages/it-parallel-batch/CHANGELOG.md index 2742296b..d4647e20 100644 --- a/packages/it-parallel-batch/CHANGELOG.md +++ b/packages/it-parallel-batch/CHANGELOG.md @@ -1,3 +1,25 @@ +## [it-parallel-batch-v3.0.0](https://github.com/achingbrain/it/compare/it-parallel-batch-v2.0.1...it-parallel-batch-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([c7d90e8](https://github.com/achingbrain/it/commit/c7d90e85e15495959991eff8aaad5964cf874d91)) +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-parallel-batch-v2.0.1](https://github.com/achingbrain/it/compare/it-parallel-batch-v2.0.0...it-parallel-batch-v2.0.1) (2023-03-02) diff --git a/packages/it-parallel-batch/package.json b/packages/it-parallel-batch/package.json index dedd9633..0eb662ae 100644 --- a/packages/it-parallel-batch/package.json +++ b/packages/it-parallel-batch/package.json @@ -1,6 +1,6 @@ { "name": "it-parallel-batch", - "version": "2.0.1", + "version": "3.0.0", "description": "Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", @@ -135,7 +135,7 @@ "release": "aegir release" }, "dependencies": { - "it-batch": "^2.0.0" + "it-batch": "^3.0.0" }, "devDependencies": { "aegir": "^38.1.7", diff --git a/packages/it-reduce/CHANGELOG.md b/packages/it-reduce/CHANGELOG.md index c9235e74..4de95c33 100644 --- a/packages/it-reduce/CHANGELOG.md +++ b/packages/it-reduce/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-reduce-v3.0.1](https://github.com/achingbrain/it/compare/it-reduce-v3.0.0...it-reduce-v3.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-reduce-v3.0.0](https://github.com/achingbrain/it/compare/it-reduce-v2.0.1...it-reduce-v3.0.0) (2023-03-30) diff --git a/packages/it-reduce/package.json b/packages/it-reduce/package.json index 03413a14..4ad361f2 100644 --- a/packages/it-reduce/package.json +++ b/packages/it-reduce/package.json @@ -1,6 +1,6 @@ { "name": "it-reduce", - "version": "3.0.0", + "version": "3.0.1", "description": "Reduces the values yielded from an async iterator", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-reduce/src/index.ts b/packages/it-reduce/src/index.ts index 28a67226..f63c689e 100644 --- a/packages/it-reduce/src/index.ts +++ b/packages/it-reduce/src/index.ts @@ -6,8 +6,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * Reduces the values yielded by an (async) iterable */ function reduce (source: Iterable, func: (acc: V, curr: T) => V, init: V): V -function reduce (source: AsyncIterable, func: (acc: V, curr: T) => V, init: V): Promise -function reduce (source: AsyncIterable | Iterable, func: (acc: V, curr: T) => V, init: V): Promise | V { +function reduce (source: Iterable | AsyncIterable, func: (acc: V, curr: T) => V, init: V): Promise +function reduce (source: Iterable | AsyncIterable, func: (acc: V, curr: T) => V, init: V): Promise | V { if (isAsyncIterable(source)) { return (async function () { for await (const val of source) { diff --git a/packages/it-skip/CHANGELOG.md b/packages/it-skip/CHANGELOG.md index 66e81ee9..b898ef6e 100644 --- a/packages/it-skip/CHANGELOG.md +++ b/packages/it-skip/CHANGELOG.md @@ -1,3 +1,24 @@ +## [it-skip-v3.0.0](https://github.com/achingbrain/it/compare/it-skip-v2.0.1...it-skip-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-skip-v2.0.1](https://github.com/achingbrain/it/compare/it-skip-v2.0.0...it-skip-v2.0.1) (2023-03-02) diff --git a/packages/it-skip/package.json b/packages/it-skip/package.json index 2f3aa138..3349c8a4 100644 --- a/packages/it-skip/package.json +++ b/packages/it-skip/package.json @@ -1,6 +1,6 @@ { "name": "it-skip", - "version": "2.0.1", + "version": "3.0.0", "description": "Skip items from an iterable", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-skip/src/index.ts b/packages/it-skip/src/index.ts index e4a129ab..a6ea0419 100644 --- a/packages/it-skip/src/index.ts +++ b/packages/it-skip/src/index.ts @@ -6,8 +6,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * Skip items from an iterable */ function skip (source: Iterable, offset: number): Generator -function skip (source: AsyncIterable, offset: number): AsyncGenerator -function skip (source: AsyncIterable | Iterable, offset: number): AsyncGenerator | Generator { +function skip (source: Iterable | AsyncIterable, offset: number): AsyncGenerator +function skip (source: Iterable | AsyncIterable, offset: number): AsyncGenerator | Generator { if (isAsyncIterable(source)) { return (async function * () { for await (const entry of source) { diff --git a/packages/it-sort/CHANGELOG.md b/packages/it-sort/CHANGELOG.md index ddc0977d..432b27f1 100644 --- a/packages/it-sort/CHANGELOG.md +++ b/packages/it-sort/CHANGELOG.md @@ -1,3 +1,24 @@ +## [it-sort-v3.0.0](https://github.com/achingbrain/it/compare/it-sort-v2.0.1...it-sort-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-sort-v2.0.1](https://github.com/achingbrain/it/compare/it-sort-v2.0.0...it-sort-v2.0.1) (2023-03-02) diff --git a/packages/it-sort/package.json b/packages/it-sort/package.json index eacd2917..7b07dd91 100644 --- a/packages/it-sort/package.json +++ b/packages/it-sort/package.json @@ -1,6 +1,6 @@ { "name": "it-sort", - "version": "2.0.1", + "version": "3.0.0", "description": "Collects all values from an async iterator, sorts them using the passed function and yields them", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-sort/src/index.ts b/packages/it-sort/src/index.ts index 43f0acff..b93e81dc 100644 --- a/packages/it-sort/src/index.ts +++ b/packages/it-sort/src/index.ts @@ -13,8 +13,8 @@ export interface CompareFunction { * using the passed function and yields them */ function sort (source: Iterable, sorter: CompareFunction): Generator -function sort (source: AsyncIterable, sorter: CompareFunction): AsyncGenerator -function sort (source: AsyncIterable | Iterable, sorter: CompareFunction): AsyncGenerator | Generator { +function sort (source: Iterable | AsyncIterable, sorter: CompareFunction): AsyncGenerator +function sort (source: Iterable | AsyncIterable, sorter: CompareFunction): AsyncGenerator | Generator { if (isAsyncIterable(source)) { return (async function * () { const arr = await all(source) diff --git a/packages/it-split/CHANGELOG.md b/packages/it-split/CHANGELOG.md index 760b50a2..19d7d522 100644 --- a/packages/it-split/CHANGELOG.md +++ b/packages/it-split/CHANGELOG.md @@ -1,3 +1,24 @@ +## [it-split-v3.0.0](https://github.com/achingbrain/it/compare/it-split-v2.0.2...it-split-v3.0.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* if you pass a synchronous iterator to a function it will return a synchronous generator in response + +### Bug Fixes + +* return iterators from synchronous sources ([#55](https://github.com/achingbrain/it/issues/55)) ([b6d8422](https://github.com/achingbrain/it/commit/b6d84222eb8e6d8c8956810d0e2ec1f065909742)) + + +### Trivial Changes + +* update project config, fix broken badges ([#53](https://github.com/achingbrain/it/issues/53)) ([e56c6ae](https://github.com/achingbrain/it/commit/e56c6ae9a0a766b5eab77040e92b2e034ce52d2e)) + + +### Dependencies + +* update sibling dependencies ([8b60209](https://github.com/achingbrain/it/commit/8b60209d429e282f8d5e5218ee2019ae7153585b)) + ## [it-split-v2.0.2](https://github.com/achingbrain/it/compare/it-split-v2.0.1...it-split-v2.0.2) (2023-03-02) diff --git a/packages/it-split/package.json b/packages/it-split/package.json index 4e6c0bab..5bad5a9c 100644 --- a/packages/it-split/package.json +++ b/packages/it-split/package.json @@ -1,6 +1,6 @@ { "name": "it-split", - "version": "2.0.2", + "version": "3.0.0", "description": "Splits Uint8Arrays emitted by an (async) iterable by a delimiter", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-split/src/index.ts b/packages/it-split/src/index.ts index 9a9df636..b0d9d122 100644 --- a/packages/it-split/src/index.ts +++ b/packages/it-split/src/index.ts @@ -12,8 +12,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * Splits Uint8Arrays emitted by an (async) iterable by a delimiter */ function split (source: Iterable, options?: SplitOptions): Generator -function split (source: AsyncIterable, options?: SplitOptions): AsyncGenerator -function split (source: AsyncIterable | Iterable, options: SplitOptions = {}): AsyncGenerator | Generator { +function split (source: Iterable | AsyncIterable, options?: SplitOptions): AsyncGenerator +function split (source: Iterable | AsyncIterable, options: SplitOptions = {}): AsyncGenerator | Generator { const bl = new Uint8ArrayList() const delimiter = options.delimiter ?? new TextEncoder().encode('\n') diff --git a/packages/it-take/CHANGELOG.md b/packages/it-take/CHANGELOG.md index b5690012..a02ef8a8 100644 --- a/packages/it-take/CHANGELOG.md +++ b/packages/it-take/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-take-v3.0.1](https://github.com/achingbrain/it/compare/it-take-v3.0.0...it-take-v3.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-take-v3.0.0](https://github.com/achingbrain/it/compare/it-take-v2.0.1...it-take-v3.0.0) (2023-03-30) diff --git a/packages/it-take/package.json b/packages/it-take/package.json index 725fa24e..33849f88 100644 --- a/packages/it-take/package.json +++ b/packages/it-take/package.json @@ -1,6 +1,6 @@ { "name": "it-take", - "version": "3.0.0", + "version": "3.0.1", "description": "Stop iteration after n items have been received", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-take/src/index.ts b/packages/it-take/src/index.ts index a8cab247..4892f1a0 100644 --- a/packages/it-take/src/index.ts +++ b/packages/it-take/src/index.ts @@ -6,8 +6,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * Stop iteration after n items have been received */ function take (source: Iterable, limit: number): Generator -function take (source: AsyncIterable, limit: number): AsyncGenerator -function take (source: AsyncIterable | Iterable, limit: number): AsyncGenerator | Generator { +function take (source: Iterable | AsyncIterable, limit: number): AsyncGenerator +function take (source: Iterable | AsyncIterable, limit: number): AsyncGenerator | Generator { if (isAsyncIterable(source)) { return (async function * () { let items = 0 diff --git a/packages/it-to-buffer/CHANGELOG.md b/packages/it-to-buffer/CHANGELOG.md index fc98f348..0b6d06ff 100644 --- a/packages/it-to-buffer/CHANGELOG.md +++ b/packages/it-to-buffer/CHANGELOG.md @@ -1,3 +1,10 @@ +## [it-to-buffer-v4.0.1](https://github.com/achingbrain/it/compare/it-to-buffer-v4.0.0...it-to-buffer-v4.0.1) (2023-03-31) + + +### Bug Fixes + +* allow Iterable | AsyncIterable union input ([#59](https://github.com/achingbrain/it/issues/59)) ([80ec2ac](https://github.com/achingbrain/it/commit/80ec2ace4f64b6291b39cb51bc5ebe2cedba7152)) + ## [it-to-buffer-v4.0.0](https://github.com/achingbrain/it/compare/it-to-buffer-v3.0.1...it-to-buffer-v4.0.0) (2023-03-30) diff --git a/packages/it-to-buffer/package.json b/packages/it-to-buffer/package.json index 2308c603..8773d9d1 100644 --- a/packages/it-to-buffer/package.json +++ b/packages/it-to-buffer/package.json @@ -1,6 +1,6 @@ { "name": "it-to-buffer", - "version": "4.0.0", + "version": "4.0.1", "description": "Takes an async iterator that yields buffers and concatenates them all together", "author": "Alex Potsides ", "license": "Apache-2.0 OR MIT", diff --git a/packages/it-to-buffer/src/index.ts b/packages/it-to-buffer/src/index.ts index 632097e3..424d9831 100644 --- a/packages/it-to-buffer/src/index.ts +++ b/packages/it-to-buffer/src/index.ts @@ -9,8 +9,8 @@ function isAsyncIterable (thing: any): thing is AsyncIterable { * into one buffer */ function toBuffer (source: Iterable): Uint8Array -function toBuffer (source: AsyncIterable): Promise -function toBuffer (source: AsyncIterable | Iterable): Promise | Uint8Array { +function toBuffer (source: Iterable | AsyncIterable): Promise +function toBuffer (source: Iterable | AsyncIterable): Promise | Uint8Array { if (isAsyncIterable(source)) { return (async () => { let buffer = new Uint8Array(0)