From 25af1d2cd7302fd9a624cf5f6b049afa2b2fc583 Mon Sep 17 00:00:00 2001 From: William Wong Date: Sat, 29 Jun 2024 01:08:15 -0700 Subject: [PATCH] Fix path under Node.js ESM (#37) * Fix ESM path * Update PR number * Rename Observable related to .ts --- CHANGELOG.md | 4 + package-lock.json | 399 +++++++++++++++++- .../asyncGeneratorWithLastValue.test.ts | 17 - .../importDefault/asyncIteratorDrop.test.ts | 22 - .../importDefault/asyncIteratorEvery.test.ts | 28 -- .../importDefault/asyncIteratorFilter.test.ts | 24 -- .../importDefault/asyncIteratorFind.test.ts | 18 - .../asyncIteratorFlatMap.test.ts | 15 - .../asyncIteratorForEach.test.ts | 12 - .../importDefault/asyncIteratorFrom.test.ts | 15 - .../importDefault/asyncIteratorMap.test.ts | 24 -- .../importDefault/asyncIteratorReduce.test.ts | 26 -- .../importDefault/asyncIteratorSome.test.ts | 26 -- .../importDefault/asyncIteratorTake.test.ts | 23 - .../asyncIteratorToArray.test.ts | 20 - .../asyncIteratorToIterable.test.ts | 21 - .../generatorWithLastValue.test.ts | 17 - .../iterableWritableStream.test.ts | 39 -- .../importDefault/iteratorAt.test.ts | 3 - .../importDefault/iteratorConcat.test.ts | 4 - .../importDefault/iteratorDrop.test.ts | 20 - .../importDefault/iteratorEntries.test.ts | 8 - .../importDefault/iteratorEvery.test.ts | 22 - .../importDefault/iteratorFilter.test.ts | 22 - .../importDefault/iteratorFind.test.ts | 16 - .../importDefault/iteratorFindIndex.test.ts | 3 - .../importDefault/iteratorFindLast.test.ts | 3 - .../iteratorFindLastIndex.test.ts | 4 - .../importDefault/iteratorFlatMap.test.ts | 15 - .../importDefault/iteratorForEach.test.ts | 12 - .../importDefault/iteratorFrom.test.ts | 15 - .../importDefault/iteratorIncludes.test.ts | 3 - .../importDefault/iteratorIndexOf.test.ts | 3 - .../importDefault/iteratorJoin.test.ts | 3 - .../importDefault/iteratorKeys.test.ts | 3 - .../importDefault/iteratorMap.test.ts | 22 - .../importDefault/iteratorReduce.test.ts | 24 -- .../importDefault/iteratorSlice.test.ts | 4 - .../importDefault/iteratorSome.test.ts | 22 - .../importDefault/iteratorTake.test.ts | 21 - .../importDefault/iteratorToArray.test.ts | 18 - .../importDefault/iteratorToAsync.test.ts | 11 - .../importDefault/iteratorToIterable.test.ts | 30 -- .../importDefault/iteratorToSpliced.test.ts | 4 - .../importDefault/iteratorToString.test.ts | 3 - .../importDefault/observable.test.ts | 17 - .../importDefault/observableFromAsync.test.ts | 20 - .../observableSubscribeAsReadable.test.ts | 21 - .../importDefault/observableValues.test.ts | 12 - .../importDefault/readableStreamFrom.test.ts | 12 - .../readableStreamValues.test.ts | 19 - .../importDefault/symbolObservable.test.ts | 7 - .../asyncGeneratorWithLastValue.test.ts | 17 - .../importNamed/asyncIteratorDrop.test.ts | 22 - .../importNamed/asyncIteratorEvery.test.ts | 29 -- .../importNamed/asyncIteratorFilter.test.ts | 24 -- .../importNamed/asyncIteratorFind.test.ts | 18 - .../importNamed/asyncIteratorFlatMap.test.ts | 16 - .../importNamed/asyncIteratorForEach.test.ts | 13 - .../importNamed/asyncIteratorFrom.test.ts | 15 - .../importNamed/asyncIteratorMap.test.ts | 24 -- .../importNamed/asyncIteratorReduce.test.ts | 27 -- .../importNamed/asyncIteratorSome.test.ts | 27 -- .../importNamed/asyncIteratorTake.test.ts | 23 - .../importNamed/asyncIteratorToArray.test.ts | 21 - .../asyncIteratorToIterable.test.ts | 21 - .../generatorWithLastValue.test.ts | 17 - .../iterableWritableStream.test.ts | 39 -- .../importNamed/iteratorAt.test.ts | 3 - .../importNamed/iteratorConcat.test.ts | 4 - .../importNamed/iteratorDrop.test.ts | 20 - .../importNamed/iteratorEntries.test.ts | 8 - .../importNamed/iteratorEvery.test.ts | 23 - .../importNamed/iteratorFilter.test.ts | 22 - .../importNamed/iteratorFind.test.ts | 16 - .../importNamed/iteratorFindIndex.test.ts | 3 - .../importNamed/iteratorFindLast.test.ts | 3 - .../importNamed/iteratorFindLastIndex.test.ts | 4 - .../importNamed/iteratorFlatMap.test.ts | 15 - .../importNamed/iteratorForEach.test.ts | 12 - .../importNamed/iteratorFrom.test.ts | 15 - .../importNamed/iteratorIncludes.test.ts | 3 - .../importNamed/iteratorIndexOf.test.ts | 3 - .../importNamed/iteratorKeys.test.ts | 3 - .../importNamed/iteratorMap.test.ts | 22 - .../importNamed/iteratorReduce.test.ts | 25 -- .../importNamed/iteratorSlice.test.ts | 4 - .../importNamed/iteratorSome.test.ts | 23 - .../importNamed/iteratorTake.test.ts | 21 - .../importNamed/iteratorToArray.test.ts | 19 - .../importNamed/iteratorToAsync.test.ts | 11 - .../importNamed/iteratorToIterable.test.ts | 31 -- .../importNamed/iteratorToSpliced.test.ts | 4 - .../importNamed/iteratorToString.test.ts | 3 - .../importNamed/observable.test.ts | 17 - .../importNamed/observableFromAsync.test.ts | 20 - .../observableSubscribeAsReadable.test.ts | 22 - .../importNamed/observableValues.test.ts | 13 - .../importNamed/readableStreamFrom.test.ts | 12 - .../importNamed/readableStreamValues.test.ts | 19 - .../importNamed/symbolObservable.test.ts | 8 - packages/integration-test/jest.config.json | 20 - packages/integration-test/package.json | 12 +- .../asyncGeneratorWithLastValue.test.ts | 18 - .../requireDefault/asyncIteratorDrop.test.ts | 23 - .../requireDefault/asyncIteratorEvery.test.ts | 29 -- .../asyncIteratorFilter.test.ts | 25 -- .../requireDefault/asyncIteratorFind.test.ts | 19 - .../asyncIteratorFlatMap.test.ts | 16 - .../asyncIteratorForEach.test.ts | 13 - .../requireDefault/asyncIteratorFrom.test.ts | 16 - .../requireDefault/asyncIteratorMap.test.ts | 25 -- .../asyncIteratorReduce.test.ts | 27 -- .../requireDefault/asyncIteratorSome.test.ts | 27 -- .../requireDefault/asyncIteratorTake.test.ts | 24 -- .../asyncIteratorToArray.test.ts | 21 - .../asyncIteratorToIterable.test.ts | 22 - .../generatorWithLastValue.test.ts | 18 - .../iterableWritableStream.test.ts | 40 -- .../requireDefault/iteratorAt.test.ts | 4 - .../requireDefault/iteratorConcat.test.ts | 5 - .../requireDefault/iteratorDrop.test.ts | 21 - .../requireDefault/iteratorEntries.test.ts | 9 - .../requireDefault/iteratorEvery.test.ts | 23 - .../requireDefault/iteratorFilter.test.ts | 23 - .../requireDefault/iteratorFind.test.ts | 17 - .../requireDefault/iteratorFindIndex.test.ts | 4 - .../requireDefault/iteratorFindLast.test.ts | 4 - .../iteratorFindLastIndex.test.ts | 5 - .../requireDefault/iteratorFlatMap.test.ts | 16 - .../requireDefault/iteratorForEach.test.ts | 13 - .../requireDefault/iteratorFrom.test.ts | 16 - .../requireDefault/iteratorIncludes.test.ts | 4 - .../requireDefault/iteratorIndexOf.test.ts | 4 - .../requireDefault/iteratorKeys.test.ts | 4 - .../requireDefault/iteratorMap.test.ts | 23 - .../requireDefault/iteratorReduce.test.ts | 25 -- .../requireDefault/iteratorSlice.test.ts | 5 - .../requireDefault/iteratorSome.test.ts | 24 -- .../requireDefault/iteratorTake.test.ts | 22 - .../requireDefault/iteratorToArray.test.ts | 19 - .../requireDefault/iteratorToAsync.test.ts | 12 - .../requireDefault/iteratorToIterable.test.ts | 31 -- .../requireDefault/iteratorToSpliced.test.ts | 5 - .../requireDefault/iteratorToString.test.ts | 4 - .../requireDefault/observable.test.ts | 18 - .../observableFromAsync.test.ts | 21 - .../observableSubscribeAsReadable.test.ts | 22 - .../requireDefault/observableValues.test.ts | 13 - .../requireDefault/readableStreamFrom.test.ts | 13 - .../readableStreamValues.test.ts | 20 - .../requireDefault/symbolObservable.test.ts | 8 - .../asyncGeneratorWithLastValue.test.ts | 18 - .../requireNamed/asyncIteratorDrop.test.ts | 23 - .../requireNamed/asyncIteratorEvery.test.ts | 30 -- .../requireNamed/asyncIteratorFilter.test.ts | 25 -- .../requireNamed/asyncIteratorFind.test.ts | 19 - .../requireNamed/asyncIteratorFlatMap.test.ts | 17 - .../requireNamed/asyncIteratorForEach.test.ts | 14 - .../requireNamed/asyncIteratorFrom.test.ts | 16 - .../requireNamed/asyncIteratorMap.test.ts | 25 -- .../requireNamed/asyncIteratorReduce.test.ts | 28 -- .../requireNamed/asyncIteratorSome.test.ts | 28 -- .../requireNamed/asyncIteratorTake.test.ts | 24 -- .../requireNamed/asyncIteratorToArray.test.ts | 22 - .../asyncIteratorToIterable.test.ts | 22 - .../generatorWithLastValue.test.ts | 18 - .../iterableWritableStream.test.ts | 40 -- .../requireNamed/iteratorAt.test.ts | 4 - .../requireNamed/iteratorConcat.test.ts | 5 - .../requireNamed/iteratorDrop.test.ts | 21 - .../requireNamed/iteratorEntries.test.ts | 9 - .../requireNamed/iteratorEvery.test.ts | 24 -- .../requireNamed/iteratorFilter.test.ts | 23 - .../requireNamed/iteratorFind.test.ts | 17 - .../requireNamed/iteratorFindIndex.test.ts | 4 - .../requireNamed/iteratorFindLast.test.ts | 4 - .../iteratorFindLastIndex.test.ts | 5 - .../requireNamed/iteratorFlatMap.test.ts | 16 - .../requireNamed/iteratorForEach.test.ts | 13 - .../requireNamed/iteratorFrom.test.ts | 16 - .../requireNamed/iteratorIncludes.test.ts | 4 - .../requireNamed/iteratorIndexOf.test.ts | 4 - .../requireNamed/iteratorKeys.test.ts | 4 - .../requireNamed/iteratorMap.test.ts | 23 - .../requireNamed/iteratorReduce.test.ts | 26 -- .../requireNamed/iteratorSlice.test.ts | 5 - .../requireNamed/iteratorSome.test.ts | 24 -- .../requireNamed/iteratorTake.test.ts | 22 - .../requireNamed/iteratorToArray.test.ts | 20 - .../requireNamed/iteratorToAsync.test.ts | 12 - .../requireNamed/iteratorToIterable.test.ts | 32 -- .../requireNamed/iteratorToSpliced.test.ts | 5 - .../requireNamed/iteratorToString.test.ts | 4 - .../requireNamed/observable.test.ts | 18 - .../requireNamed/observableFromAsync.test.ts | 21 - .../observableSubscribeAsReadable.test.ts | 23 - .../requireNamed/observableValues.test.ts | 14 - .../requireNamed/readableStreamFrom.test.ts | 13 - .../requireNamed/readableStreamValues.ts | 20 - .../requireNamed/symbolObservable.test.ts | 9 - .../asyncGeneratorWithLastValue.mjs | 20 + .../test/importDefault/asyncIteratorDrop.mjs | 25 ++ .../test/importDefault/asyncIteratorEvery.mjs | 31 ++ .../importDefault/asyncIteratorFilter.mjs | 27 ++ .../test/importDefault/asyncIteratorFind.mjs | 21 + .../importDefault/asyncIteratorFlatMap.mjs | 18 + .../importDefault/asyncIteratorForEach.mjs | 15 + .../test/importDefault/asyncIteratorFrom.mjs | 18 + .../test/importDefault/asyncIteratorMap.mjs | 27 ++ .../importDefault/asyncIteratorReduce.mjs | 29 ++ .../test/importDefault/asyncIteratorSome.mjs | 31 ++ .../test/importDefault/asyncIteratorTake.mjs | 26 ++ .../importDefault/asyncIteratorToArray.mjs | 23 + .../importDefault/asyncIteratorToIterable.mjs | 24 ++ .../importDefault/generatorWithLastValue.mjs | 20 + .../importDefault/iterableWritableStream.mjs | 43 ++ .../test/importDefault/iteratorAt.mjs | 6 + .../test/importDefault/iteratorConcat.mjs | 6 + .../test/importDefault/iteratorDrop.mjs | 23 + .../test/importDefault/iteratorEntries.mjs | 11 + .../test/importDefault/iteratorEvery.mjs | 25 ++ .../test/importDefault/iteratorFilter.mjs | 25 ++ .../test/importDefault/iteratorFind.mjs | 19 + .../test/importDefault/iteratorFindIndex.mjs | 6 + .../test/importDefault/iteratorFindLast.mjs | 6 + .../importDefault/iteratorFindLastIndex.mjs | 6 + .../test/importDefault/iteratorFlatMap.mjs | 18 + .../test/importDefault/iteratorForEach.mjs | 15 + .../test/importDefault/iteratorFrom.mjs | 18 + .../test/importDefault/iteratorIncludes.mjs | 6 + .../test/importDefault/iteratorIndexOf.mjs | 6 + .../test/importDefault/iteratorJoin.mjs | 6 + .../test/importDefault/iteratorKeys.mjs | 6 + .../test/importDefault/iteratorMap.mjs | 25 ++ .../test/importDefault/iteratorReduce.mjs | 27 ++ .../test/importDefault/iteratorSlice.mjs | 6 + .../test/importDefault/iteratorSome.mjs | 25 ++ .../test/importDefault/iteratorTake.mjs | 24 ++ .../test/importDefault/iteratorToArray.mjs | 21 + .../test/importDefault/iteratorToAsync.mjs | 14 + .../test/importDefault/iteratorToIterable.mjs | 34 ++ .../test/importDefault/iteratorToSpliced.mjs | 6 + .../test/importDefault/iteratorToString.mjs | 6 + .../test/importDefault/observable.mjs | 21 + .../importDefault/observableFromAsync.mjs | 24 ++ .../observableSubscribeAsReadable.mjs | 24 ++ .../test/importDefault/observableValues.mjs | 15 + .../test/importDefault/readableStreamFrom.mjs | 15 + .../importDefault/readableStreamValues.mjs | 22 + .../test/importDefault/symbolObservable.mjs | 10 + .../asyncGeneratorWithLastValue.mjs | 20 + .../test/importNamed/asyncIteratorDrop.mjs | 25 ++ .../test/importNamed/asyncIteratorEvery.mjs | 32 ++ .../test/importNamed/asyncIteratorFilter.mjs | 27 ++ .../test/importNamed/asyncIteratorFind.mjs | 21 + .../test/importNamed/asyncIteratorFlatMap.mjs | 19 + .../test/importNamed/asyncIteratorForEach.mjs | 16 + .../test/importNamed/asyncIteratorFrom.mjs | 18 + .../test/importNamed/asyncIteratorMap.mjs | 27 ++ .../test/importNamed/asyncIteratorReduce.mjs | 30 ++ .../test/importNamed/asyncIteratorSome.mjs | 32 ++ .../test/importNamed/asyncIteratorTake.mjs | 26 ++ .../test/importNamed/asyncIteratorToArray.mjs | 24 ++ .../importNamed/asyncIteratorToIterable.mjs | 24 ++ .../importNamed/generatorWithLastValue.mjs | 20 + .../importNamed/iterableWritableStream.mjs | 43 ++ .../test/importNamed/iteratorAt.mjs | 6 + .../test/importNamed/iteratorConcat.mjs | 6 + .../test/importNamed/iteratorDrop.mjs | 23 + .../test/importNamed/iteratorEntries.mjs | 11 + .../test/importNamed/iteratorEvery.mjs | 26 ++ .../test/importNamed/iteratorFilter.mjs | 25 ++ .../test/importNamed/iteratorFind.mjs | 19 + .../test/importNamed/iteratorFindIndex.mjs | 6 + .../test/importNamed/iteratorFindLast.mjs | 6 + .../importNamed/iteratorFindLastIndex.mjs | 6 + .../test/importNamed/iteratorFlatMap.mjs | 18 + .../test/importNamed/iteratorForEach.mjs | 15 + .../test/importNamed/iteratorFrom.mjs | 18 + .../test/importNamed/iteratorIncludes.mjs | 6 + .../test/importNamed/iteratorIndexOf.mjs | 6 + .../test/importNamed/iteratorJoin.mjs | 6 + .../test/importNamed/iteratorKeys.mjs | 6 + .../test/importNamed/iteratorMap.mjs | 25 ++ .../test/importNamed/iteratorReduce.mjs | 28 ++ .../test/importNamed/iteratorSlice.mjs | 6 + .../test/importNamed/iteratorSome.mjs | 26 ++ .../test/importNamed/iteratorTake.mjs | 24 ++ .../test/importNamed/iteratorToArray.mjs | 22 + .../test/importNamed/iteratorToAsync.mjs | 14 + .../test/importNamed/iteratorToIterable.mjs | 35 ++ .../test/importNamed/iteratorToSpliced.mjs | 6 + .../test/importNamed/iteratorToString.mjs | 6 + .../test/importNamed/observable.mjs | 21 + .../test/importNamed/observableFromAsync.mjs | 24 ++ .../observableSubscribeAsReadable.mjs | 25 ++ .../test/importNamed/observableValues.mjs | 16 + .../test/importNamed/readableStreamFrom.mjs | 15 + .../test/importNamed/readableStreamValues.mjs | 22 + .../test/importNamed/symbolObservable.mjs | 11 + .../asyncGeneratorWithLastValue.js | 20 + .../test/requireDefault/asyncIteratorDrop.js | 25 ++ .../test/requireDefault/asyncIteratorEvery.js | 31 ++ .../requireDefault/asyncIteratorFilter.js | 27 ++ .../test/requireDefault/asyncIteratorFind.js | 21 + .../requireDefault/asyncIteratorFlatMap.js | 18 + .../requireDefault/asyncIteratorForEach.js | 15 + .../test/requireDefault/asyncIteratorFrom.js | 18 + .../test/requireDefault/asyncIteratorMap.js | 27 ++ .../requireDefault/asyncIteratorReduce.js | 29 ++ .../test/requireDefault/asyncIteratorSome.js | 31 ++ .../test/requireDefault/asyncIteratorTake.js | 26 ++ .../requireDefault/asyncIteratorToArray.js | 23 + .../requireDefault/asyncIteratorToIterable.js | 24 ++ .../requireDefault/generatorWithLastValue.js | 20 + .../requireDefault/iterableWritableStream.js | 43 ++ .../test/requireDefault/iteratorAt.js | 6 + .../test/requireDefault/iteratorConcat.js | 6 + .../test/requireDefault/iteratorDrop.js | 23 + .../test/requireDefault/iteratorEntries.js | 11 + .../test/requireDefault/iteratorEvery.js | 25 ++ .../test/requireDefault/iteratorFilter.js | 25 ++ .../test/requireDefault/iteratorFind.js | 19 + .../test/requireDefault/iteratorFindIndex.js | 6 + .../test/requireDefault/iteratorFindLast.js | 6 + .../requireDefault/iteratorFindLastIndex.js | 6 + .../test/requireDefault/iteratorFlatMap.js | 18 + .../test/requireDefault/iteratorForEach.js | 15 + .../test/requireDefault/iteratorFrom.js | 18 + .../test/requireDefault/iteratorIncludes.js | 6 + .../test/requireDefault/iteratorIndexOf.js | 6 + .../test/requireDefault/iteratorJoin.js | 6 + .../test/requireDefault/iteratorKeys.js | 6 + .../test/requireDefault/iteratorMap.js | 25 ++ .../test/requireDefault/iteratorReduce.js | 27 ++ .../test/requireDefault/iteratorSlice.js | 6 + .../test/requireDefault/iteratorSome.js | 25 ++ .../test/requireDefault/iteratorTake.js | 24 ++ .../test/requireDefault/iteratorToArray.js | 21 + .../test/requireDefault/iteratorToAsync.js | 14 + .../test/requireDefault/iteratorToIterable.js | 34 ++ .../test/requireDefault/iteratorToSpliced.js | 6 + .../test/requireDefault/iteratorToString.js | 6 + .../test/requireDefault/observable.js | 21 + .../requireDefault/observableFromAsync.js | 24 ++ .../observableSubscribeAsReadable.js | 24 ++ .../test/requireDefault/observableValues.js | 15 + .../test/requireDefault/readableStreamFrom.js | 15 + .../requireDefault/readableStreamValues.js | 22 + .../test/requireDefault/symbolObservable.js | 10 + .../asyncGeneratorWithLastValue.js | 20 + .../test/requireNamed/asyncIteratorDrop.js | 25 ++ .../test/requireNamed/asyncIteratorEvery.js | 32 ++ .../test/requireNamed/asyncIteratorFilter.js | 27 ++ .../test/requireNamed/asyncIteratorFind.js | 21 + .../test/requireNamed/asyncIteratorFlatMap.js | 19 + .../test/requireNamed/asyncIteratorForEach.js | 16 + .../test/requireNamed/asyncIteratorFrom.js | 18 + .../test/requireNamed/asyncIteratorMap.js | 27 ++ .../test/requireNamed/asyncIteratorReduce.js | 30 ++ .../test/requireNamed/asyncIteratorSome.js | 32 ++ .../test/requireNamed/asyncIteratorTake.js | 26 ++ .../test/requireNamed/asyncIteratorToArray.js | 24 ++ .../requireNamed/asyncIteratorToIterable.js | 24 ++ .../requireNamed/generatorWithLastValue.js | 20 + .../requireNamed/iterableWritableStream.js | 43 ++ .../test/requireNamed/iteratorAt.js | 6 + .../test/requireNamed/iteratorConcat.js | 6 + .../test/requireNamed/iteratorDrop.js | 23 + .../test/requireNamed/iteratorEntries.js | 11 + .../test/requireNamed/iteratorEvery.js | 26 ++ .../test/requireNamed/iteratorFilter.js | 25 ++ .../test/requireNamed/iteratorFind.js | 19 + .../test/requireNamed/iteratorFindIndex.js | 6 + .../test/requireNamed/iteratorFindLast.js | 6 + .../requireNamed/iteratorFindLastIndex.js | 6 + .../test/requireNamed/iteratorFlatMap.js | 18 + .../test/requireNamed/iteratorForEach.js | 15 + .../test/requireNamed/iteratorFrom.js | 18 + .../test/requireNamed/iteratorIncludes.js | 6 + .../test/requireNamed/iteratorIndexOf.js | 6 + .../test/requireNamed/iteratorJoin.js | 6 + .../test/requireNamed/iteratorKeys.js | 6 + .../test/requireNamed/iteratorMap.js | 25 ++ .../test/requireNamed/iteratorReduce.js | 28 ++ .../test/requireNamed/iteratorSlice.js | 6 + .../test/requireNamed/iteratorSome.js | 26 ++ .../test/requireNamed/iteratorTake.js | 24 ++ .../test/requireNamed/iteratorToArray.js | 22 + .../test/requireNamed/iteratorToAsync.js | 14 + .../test/requireNamed/iteratorToIterable.js | 35 ++ .../test/requireNamed/iteratorToSpliced.js | 6 + .../test/requireNamed/iteratorToString.js | 6 + .../test/requireNamed/observable.js | 21 + .../test/requireNamed/observableFromAsync.js | 24 ++ .../observableSubscribeAsReadable.js | 25 ++ .../test/requireNamed/observableValues.js | 16 + .../test/requireNamed/readableStreamFrom.js | 15 + .../test/requireNamed/readableStreamValues.js | 22 + .../test/requireNamed/symbolObservable.js | 11 + .../iter-fest/src/Observable.fromOf.spec.ts | 4 +- packages/iter-fest/src/Observable.spec.ts | 6 +- packages/iter-fest/src/Observable.ts | 4 +- packages/iter-fest/src/SymbolObservable.ts | 2 +- packages/iter-fest/src/asyncIteratorDrop.ts | 2 +- packages/iter-fest/src/asyncIteratorEvery.ts | 2 +- packages/iter-fest/src/asyncIteratorFilter.ts | 2 +- packages/iter-fest/src/asyncIteratorFind.ts | 2 +- .../iter-fest/src/asyncIteratorFlatMap.ts | 2 +- .../iter-fest/src/asyncIteratorForEach.ts | 2 +- packages/iter-fest/src/asyncIteratorFrom.ts | 2 +- packages/iter-fest/src/asyncIteratorMap.ts | 2 +- packages/iter-fest/src/asyncIteratorReduce.ts | 2 +- packages/iter-fest/src/asyncIteratorSome.ts | 2 +- packages/iter-fest/src/asyncIteratorTake.ts | 2 +- .../iter-fest/src/asyncIteratorToArray.ts | 2 +- packages/iter-fest/src/index.ts | 100 ++--- packages/iter-fest/src/iteratorDrop.ts | 2 +- packages/iter-fest/src/iteratorEvery.ts | 2 +- packages/iter-fest/src/iteratorFilter.ts | 2 +- packages/iter-fest/src/iteratorFind.ts | 2 +- packages/iter-fest/src/iteratorFlatMap.ts | 2 +- packages/iter-fest/src/iteratorForEach.ts | 2 +- packages/iter-fest/src/iteratorFrom.ts | 2 +- packages/iter-fest/src/iteratorMap.ts | 2 +- packages/iter-fest/src/iteratorReduce.ts | 2 +- packages/iter-fest/src/iteratorSome.ts | 2 +- packages/iter-fest/src/iteratorTake.ts | 2 +- packages/iter-fest/src/iteratorToArray.ts | 2 +- packages/iter-fest/src/iteratorToAsync.ts | 2 +- .../iter-fest/src/observableFromAsync.spec.ts | 8 +- packages/iter-fest/src/observableFromAsync.ts | 2 +- .../src/observableSubscribeAsReadable.spec.ts | 8 +- .../src/observableSubscribeAsReadable.ts | 2 +- .../iter-fest/src/observableValues.spec.ts | 6 +- packages/iter-fest/src/observableValues.ts | 6 +- .../iter-fest/src/private/withResolvers.ts | 2 +- packages/iter-fest/src/tsconfig.json | 1 + .../src/tsconfig.precommit.production.json | 1 + .../src/tsconfig.precommit.test.json | 1 + 441 files changed, 4233 insertions(+), 3343 deletions(-) delete mode 100644 packages/integration-test/importDefault/asyncGeneratorWithLastValue.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorDrop.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorEvery.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorFilter.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorFind.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorFlatMap.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorForEach.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorFrom.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorMap.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorReduce.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorSome.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorTake.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorToArray.test.ts delete mode 100644 packages/integration-test/importDefault/asyncIteratorToIterable.test.ts delete mode 100644 packages/integration-test/importDefault/generatorWithLastValue.test.ts delete mode 100644 packages/integration-test/importDefault/iterableWritableStream.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorAt.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorConcat.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorDrop.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorEntries.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorEvery.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorFilter.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorFind.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorFindIndex.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorFindLast.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorFindLastIndex.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorFlatMap.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorForEach.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorFrom.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorIncludes.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorIndexOf.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorJoin.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorKeys.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorMap.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorReduce.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorSlice.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorSome.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorTake.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorToArray.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorToAsync.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorToIterable.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorToSpliced.test.ts delete mode 100644 packages/integration-test/importDefault/iteratorToString.test.ts delete mode 100644 packages/integration-test/importDefault/observable.test.ts delete mode 100644 packages/integration-test/importDefault/observableFromAsync.test.ts delete mode 100644 packages/integration-test/importDefault/observableSubscribeAsReadable.test.ts delete mode 100644 packages/integration-test/importDefault/observableValues.test.ts delete mode 100644 packages/integration-test/importDefault/readableStreamFrom.test.ts delete mode 100644 packages/integration-test/importDefault/readableStreamValues.test.ts delete mode 100644 packages/integration-test/importDefault/symbolObservable.test.ts delete mode 100644 packages/integration-test/importNamed/asyncGeneratorWithLastValue.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorDrop.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorEvery.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorFilter.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorFind.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorFlatMap.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorForEach.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorFrom.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorMap.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorReduce.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorSome.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorTake.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorToArray.test.ts delete mode 100644 packages/integration-test/importNamed/asyncIteratorToIterable.test.ts delete mode 100644 packages/integration-test/importNamed/generatorWithLastValue.test.ts delete mode 100644 packages/integration-test/importNamed/iterableWritableStream.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorAt.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorConcat.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorDrop.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorEntries.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorEvery.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorFilter.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorFind.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorFindIndex.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorFindLast.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorFindLastIndex.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorFlatMap.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorForEach.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorFrom.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorIncludes.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorIndexOf.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorKeys.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorMap.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorReduce.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorSlice.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorSome.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorTake.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorToArray.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorToAsync.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorToIterable.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorToSpliced.test.ts delete mode 100644 packages/integration-test/importNamed/iteratorToString.test.ts delete mode 100644 packages/integration-test/importNamed/observable.test.ts delete mode 100644 packages/integration-test/importNamed/observableFromAsync.test.ts delete mode 100644 packages/integration-test/importNamed/observableSubscribeAsReadable.test.ts delete mode 100644 packages/integration-test/importNamed/observableValues.test.ts delete mode 100644 packages/integration-test/importNamed/readableStreamFrom.test.ts delete mode 100644 packages/integration-test/importNamed/readableStreamValues.test.ts delete mode 100644 packages/integration-test/importNamed/symbolObservable.test.ts delete mode 100644 packages/integration-test/jest.config.json delete mode 100644 packages/integration-test/requireDefault/asyncGeneratorWithLastValue.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorDrop.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorEvery.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorFilter.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorFind.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorFlatMap.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorForEach.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorFrom.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorMap.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorReduce.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorSome.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorTake.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorToArray.test.ts delete mode 100644 packages/integration-test/requireDefault/asyncIteratorToIterable.test.ts delete mode 100644 packages/integration-test/requireDefault/generatorWithLastValue.test.ts delete mode 100644 packages/integration-test/requireDefault/iterableWritableStream.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorAt.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorConcat.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorDrop.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorEntries.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorEvery.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorFilter.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorFind.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorFindIndex.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorFindLast.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorFindLastIndex.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorFlatMap.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorForEach.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorFrom.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorIncludes.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorIndexOf.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorKeys.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorMap.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorReduce.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorSlice.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorSome.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorTake.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorToArray.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorToAsync.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorToIterable.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorToSpliced.test.ts delete mode 100644 packages/integration-test/requireDefault/iteratorToString.test.ts delete mode 100644 packages/integration-test/requireDefault/observable.test.ts delete mode 100644 packages/integration-test/requireDefault/observableFromAsync.test.ts delete mode 100644 packages/integration-test/requireDefault/observableSubscribeAsReadable.test.ts delete mode 100644 packages/integration-test/requireDefault/observableValues.test.ts delete mode 100644 packages/integration-test/requireDefault/readableStreamFrom.test.ts delete mode 100644 packages/integration-test/requireDefault/readableStreamValues.test.ts delete mode 100644 packages/integration-test/requireDefault/symbolObservable.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncGeneratorWithLastValue.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorDrop.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorEvery.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorFilter.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorFind.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorFlatMap.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorForEach.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorFrom.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorMap.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorReduce.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorSome.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorTake.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorToArray.test.ts delete mode 100644 packages/integration-test/requireNamed/asyncIteratorToIterable.test.ts delete mode 100644 packages/integration-test/requireNamed/generatorWithLastValue.test.ts delete mode 100644 packages/integration-test/requireNamed/iterableWritableStream.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorAt.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorConcat.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorDrop.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorEntries.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorEvery.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorFilter.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorFind.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorFindIndex.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorFindLast.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorFindLastIndex.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorFlatMap.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorForEach.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorFrom.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorIncludes.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorIndexOf.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorKeys.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorMap.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorReduce.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorSlice.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorSome.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorTake.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorToArray.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorToAsync.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorToIterable.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorToSpliced.test.ts delete mode 100644 packages/integration-test/requireNamed/iteratorToString.test.ts delete mode 100644 packages/integration-test/requireNamed/observable.test.ts delete mode 100644 packages/integration-test/requireNamed/observableFromAsync.test.ts delete mode 100644 packages/integration-test/requireNamed/observableSubscribeAsReadable.test.ts delete mode 100644 packages/integration-test/requireNamed/observableValues.test.ts delete mode 100644 packages/integration-test/requireNamed/readableStreamFrom.test.ts delete mode 100644 packages/integration-test/requireNamed/readableStreamValues.ts delete mode 100644 packages/integration-test/requireNamed/symbolObservable.test.ts create mode 100644 packages/integration-test/test/importDefault/asyncGeneratorWithLastValue.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorDrop.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorEvery.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorFilter.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorFind.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorFlatMap.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorForEach.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorFrom.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorMap.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorReduce.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorSome.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorTake.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorToArray.mjs create mode 100644 packages/integration-test/test/importDefault/asyncIteratorToIterable.mjs create mode 100644 packages/integration-test/test/importDefault/generatorWithLastValue.mjs create mode 100644 packages/integration-test/test/importDefault/iterableWritableStream.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorAt.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorConcat.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorDrop.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorEntries.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorEvery.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorFilter.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorFind.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorFindIndex.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorFindLast.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorFindLastIndex.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorFlatMap.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorForEach.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorFrom.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorIncludes.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorIndexOf.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorJoin.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorKeys.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorMap.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorReduce.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorSlice.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorSome.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorTake.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorToArray.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorToAsync.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorToIterable.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorToSpliced.mjs create mode 100644 packages/integration-test/test/importDefault/iteratorToString.mjs create mode 100644 packages/integration-test/test/importDefault/observable.mjs create mode 100644 packages/integration-test/test/importDefault/observableFromAsync.mjs create mode 100644 packages/integration-test/test/importDefault/observableSubscribeAsReadable.mjs create mode 100644 packages/integration-test/test/importDefault/observableValues.mjs create mode 100644 packages/integration-test/test/importDefault/readableStreamFrom.mjs create mode 100644 packages/integration-test/test/importDefault/readableStreamValues.mjs create mode 100644 packages/integration-test/test/importDefault/symbolObservable.mjs create mode 100644 packages/integration-test/test/importNamed/asyncGeneratorWithLastValue.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorDrop.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorEvery.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorFilter.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorFind.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorFlatMap.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorForEach.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorFrom.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorMap.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorReduce.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorSome.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorTake.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorToArray.mjs create mode 100644 packages/integration-test/test/importNamed/asyncIteratorToIterable.mjs create mode 100644 packages/integration-test/test/importNamed/generatorWithLastValue.mjs create mode 100644 packages/integration-test/test/importNamed/iterableWritableStream.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorAt.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorConcat.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorDrop.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorEntries.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorEvery.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorFilter.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorFind.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorFindIndex.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorFindLast.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorFindLastIndex.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorFlatMap.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorForEach.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorFrom.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorIncludes.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorIndexOf.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorJoin.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorKeys.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorMap.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorReduce.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorSlice.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorSome.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorTake.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorToArray.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorToAsync.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorToIterable.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorToSpliced.mjs create mode 100644 packages/integration-test/test/importNamed/iteratorToString.mjs create mode 100644 packages/integration-test/test/importNamed/observable.mjs create mode 100644 packages/integration-test/test/importNamed/observableFromAsync.mjs create mode 100644 packages/integration-test/test/importNamed/observableSubscribeAsReadable.mjs create mode 100644 packages/integration-test/test/importNamed/observableValues.mjs create mode 100644 packages/integration-test/test/importNamed/readableStreamFrom.mjs create mode 100644 packages/integration-test/test/importNamed/readableStreamValues.mjs create mode 100644 packages/integration-test/test/importNamed/symbolObservable.mjs create mode 100644 packages/integration-test/test/requireDefault/asyncGeneratorWithLastValue.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorDrop.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorEvery.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorFilter.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorFind.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorFlatMap.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorForEach.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorFrom.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorMap.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorReduce.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorSome.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorTake.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorToArray.js create mode 100644 packages/integration-test/test/requireDefault/asyncIteratorToIterable.js create mode 100644 packages/integration-test/test/requireDefault/generatorWithLastValue.js create mode 100644 packages/integration-test/test/requireDefault/iterableWritableStream.js create mode 100644 packages/integration-test/test/requireDefault/iteratorAt.js create mode 100644 packages/integration-test/test/requireDefault/iteratorConcat.js create mode 100644 packages/integration-test/test/requireDefault/iteratorDrop.js create mode 100644 packages/integration-test/test/requireDefault/iteratorEntries.js create mode 100644 packages/integration-test/test/requireDefault/iteratorEvery.js create mode 100644 packages/integration-test/test/requireDefault/iteratorFilter.js create mode 100644 packages/integration-test/test/requireDefault/iteratorFind.js create mode 100644 packages/integration-test/test/requireDefault/iteratorFindIndex.js create mode 100644 packages/integration-test/test/requireDefault/iteratorFindLast.js create mode 100644 packages/integration-test/test/requireDefault/iteratorFindLastIndex.js create mode 100644 packages/integration-test/test/requireDefault/iteratorFlatMap.js create mode 100644 packages/integration-test/test/requireDefault/iteratorForEach.js create mode 100644 packages/integration-test/test/requireDefault/iteratorFrom.js create mode 100644 packages/integration-test/test/requireDefault/iteratorIncludes.js create mode 100644 packages/integration-test/test/requireDefault/iteratorIndexOf.js create mode 100644 packages/integration-test/test/requireDefault/iteratorJoin.js create mode 100644 packages/integration-test/test/requireDefault/iteratorKeys.js create mode 100644 packages/integration-test/test/requireDefault/iteratorMap.js create mode 100644 packages/integration-test/test/requireDefault/iteratorReduce.js create mode 100644 packages/integration-test/test/requireDefault/iteratorSlice.js create mode 100644 packages/integration-test/test/requireDefault/iteratorSome.js create mode 100644 packages/integration-test/test/requireDefault/iteratorTake.js create mode 100644 packages/integration-test/test/requireDefault/iteratorToArray.js create mode 100644 packages/integration-test/test/requireDefault/iteratorToAsync.js create mode 100644 packages/integration-test/test/requireDefault/iteratorToIterable.js create mode 100644 packages/integration-test/test/requireDefault/iteratorToSpliced.js create mode 100644 packages/integration-test/test/requireDefault/iteratorToString.js create mode 100644 packages/integration-test/test/requireDefault/observable.js create mode 100644 packages/integration-test/test/requireDefault/observableFromAsync.js create mode 100644 packages/integration-test/test/requireDefault/observableSubscribeAsReadable.js create mode 100644 packages/integration-test/test/requireDefault/observableValues.js create mode 100644 packages/integration-test/test/requireDefault/readableStreamFrom.js create mode 100644 packages/integration-test/test/requireDefault/readableStreamValues.js create mode 100644 packages/integration-test/test/requireDefault/symbolObservable.js create mode 100644 packages/integration-test/test/requireNamed/asyncGeneratorWithLastValue.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorDrop.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorEvery.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorFilter.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorFind.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorFlatMap.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorForEach.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorFrom.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorMap.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorReduce.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorSome.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorTake.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorToArray.js create mode 100644 packages/integration-test/test/requireNamed/asyncIteratorToIterable.js create mode 100644 packages/integration-test/test/requireNamed/generatorWithLastValue.js create mode 100644 packages/integration-test/test/requireNamed/iterableWritableStream.js create mode 100644 packages/integration-test/test/requireNamed/iteratorAt.js create mode 100644 packages/integration-test/test/requireNamed/iteratorConcat.js create mode 100644 packages/integration-test/test/requireNamed/iteratorDrop.js create mode 100644 packages/integration-test/test/requireNamed/iteratorEntries.js create mode 100644 packages/integration-test/test/requireNamed/iteratorEvery.js create mode 100644 packages/integration-test/test/requireNamed/iteratorFilter.js create mode 100644 packages/integration-test/test/requireNamed/iteratorFind.js create mode 100644 packages/integration-test/test/requireNamed/iteratorFindIndex.js create mode 100644 packages/integration-test/test/requireNamed/iteratorFindLast.js create mode 100644 packages/integration-test/test/requireNamed/iteratorFindLastIndex.js create mode 100644 packages/integration-test/test/requireNamed/iteratorFlatMap.js create mode 100644 packages/integration-test/test/requireNamed/iteratorForEach.js create mode 100644 packages/integration-test/test/requireNamed/iteratorFrom.js create mode 100644 packages/integration-test/test/requireNamed/iteratorIncludes.js create mode 100644 packages/integration-test/test/requireNamed/iteratorIndexOf.js create mode 100644 packages/integration-test/test/requireNamed/iteratorJoin.js create mode 100644 packages/integration-test/test/requireNamed/iteratorKeys.js create mode 100644 packages/integration-test/test/requireNamed/iteratorMap.js create mode 100644 packages/integration-test/test/requireNamed/iteratorReduce.js create mode 100644 packages/integration-test/test/requireNamed/iteratorSlice.js create mode 100644 packages/integration-test/test/requireNamed/iteratorSome.js create mode 100644 packages/integration-test/test/requireNamed/iteratorTake.js create mode 100644 packages/integration-test/test/requireNamed/iteratorToArray.js create mode 100644 packages/integration-test/test/requireNamed/iteratorToAsync.js create mode 100644 packages/integration-test/test/requireNamed/iteratorToIterable.js create mode 100644 packages/integration-test/test/requireNamed/iteratorToSpliced.js create mode 100644 packages/integration-test/test/requireNamed/iteratorToString.js create mode 100644 packages/integration-test/test/requireNamed/observable.js create mode 100644 packages/integration-test/test/requireNamed/observableFromAsync.js create mode 100644 packages/integration-test/test/requireNamed/observableSubscribeAsReadable.js create mode 100644 packages/integration-test/test/requireNamed/observableValues.js create mode 100644 packages/integration-test/test/requireNamed/readableStreamFrom.js create mode 100644 packages/integration-test/test/requireNamed/readableStreamValues.js create mode 100644 packages/integration-test/test/requireNamed/symbolObservable.js diff --git a/CHANGELOG.md b/CHANGELOG.md index cf175c9..4d289d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.2.0] - 2024-06-16 +### Fixed + +- Fixed ESM imports under Node.js, in PR [#37](https://github.com/compulim/iter-fest/pull/37) + ### Added - Added typed `Observable` from `core-js-pure`, in PR [#8](https://github.com/compulim/iter-fest/pull/8) diff --git a/package-lock.json b/package-lock.json index deb401d..c8f99da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3306,6 +3306,32 @@ "@sinonjs/commons": "^3.0.0" } }, + "node_modules/@sinonjs/samsam": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-8.0.0.tgz", + "integrity": "sha512-Bp8KUVlLp8ibJZrnvq2foVhP0IVX2CIprMJPK0vqGqgrDa0OHVKeZyBykqskkrdxV6yKBPmGasO8LVjAKR3Gew==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^2.0.0", + "lodash.get": "^4.4.2", + "type-detect": "^4.0.8" + } + }, + "node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz", + "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/text-encoding": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz", + "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", + "dev": true + }, "node_modules/@testing-library/dom": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.1.0.tgz", @@ -3836,6 +3862,15 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -4293,6 +4328,12 @@ "node": ">=8" } }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, "node_modules/browserslist": { "version": "4.23.0", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", @@ -4754,6 +4795,18 @@ } } }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", @@ -4850,6 +4903,15 @@ "node": ">=8" } }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -5631,6 +5693,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "bin": { + "flat": "cli.js" + } + }, "node_modules/flat-cache": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", @@ -6043,6 +6114,15 @@ "node": ">= 0.4" } }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, "node_modules/html-encoding-sniffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", @@ -6446,6 +6526,15 @@ "node": ">=8" } }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -6552,6 +6641,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-weakmap": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", @@ -7734,6 +7835,12 @@ "node": ">=4.0" } }, + "node_modules/just-extend": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-6.2.0.tgz", + "integrity": "sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw==", + "dev": true + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -7822,6 +7929,12 @@ "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "dev": true }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -7834,6 +7947,22 @@ "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", "dev": true }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -7969,6 +8098,132 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mocha": { + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.2.tgz", + "integrity": "sha512-9btlN3JKCefPf+vKd/kcKz2SXxi12z6JswkGfaAF0saQvnsqLJk504ZmbxhSoENge08E9dsymozKgFMTl5PQsA==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "^3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "8.1.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/mocha/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/mocha/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -7992,6 +8247,28 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/nise": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/nise/-/nise-6.0.0.tgz", + "integrity": "sha512-K8ePqo9BFvN31HXwEtTNGzgrPpmvgciDsFz8aztFjt4LqKO/JeFD8tBOeuDiCMXrIl/m1YvfH8auSpxfaD09wg==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0", + "@sinonjs/fake-timers": "^11.2.2", + "@sinonjs/text-encoding": "^0.7.2", + "just-extend": "^6.2.0", + "path-to-regexp": "^6.2.1" + } + }, + "node_modules/nise/node_modules/@sinonjs/fake-timers": { + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz", + "integrity": "sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -8322,6 +8599,12 @@ "node": "14 || >=16.14" } }, + "node_modules/path-to-regexp": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.2.tgz", + "integrity": "sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==", + "dev": true + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -8615,6 +8898,15 @@ } ] }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, "node_modules/react": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", @@ -8937,6 +9229,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/safe-regex-test": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.3.tgz", @@ -8992,6 +9304,15 @@ "node": ">=10" } }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -9069,6 +9390,42 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "node_modules/sinon": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-18.0.0.tgz", + "integrity": "sha512-+dXDXzD1sBO6HlmZDd7mXZCR/y5ECiEiGCBSGuFD/kZ0bDTofPYc6JaeGmPSF+1j1MejGUWkORbYOLDyvqCWpA==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.1", + "@sinonjs/fake-timers": "^11.2.2", + "@sinonjs/samsam": "^8.0.0", + "diff": "^5.2.0", + "nise": "^6.0.0", + "supports-color": "^7" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/sinon" + } + }, + "node_modules/sinon/node_modules/@sinonjs/fake-timers": { + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz", + "integrity": "sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/sinon/node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -10475,6 +10832,12 @@ "node": ">=0.10.0" } }, + "node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -10619,6 +10982,33 @@ "node": ">=12" } }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -10639,13 +11029,10 @@ "iter-fest": "^0.0.0-0" }, "devDependencies": { - "@babel/preset-env": "^7.24.6", - "@babel/preset-typescript": "^7.24.6", - "@types/jest": "^29.5.12", - "babel-jest": "^29.7.0", "core-js-pure": "^3.37.1", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0" + "expect": "^29.7.0", + "mocha": "^10.5.2", + "sinon": "^18.0.0" } }, "packages/iter-fest": { diff --git a/packages/integration-test/importDefault/asyncGeneratorWithLastValue.test.ts b/packages/integration-test/importDefault/asyncGeneratorWithLastValue.test.ts deleted file mode 100644 index f9b1189..0000000 --- a/packages/integration-test/importDefault/asyncGeneratorWithLastValue.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { asyncGeneratorWithLastValue } from 'iter-fest'; - -test('asyncGeneratorWithLastValue should work', async () => { - const asyncGenerator = asyncGeneratorWithLastValue( - (async function* () { - yield 1; - - return 'end' as const; - })() - ); - - for await (const value of asyncGenerator) { - expect(value).toBe(1); - } - - expect(asyncGenerator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorDrop.test.ts b/packages/integration-test/importDefault/asyncIteratorDrop.test.ts deleted file mode 100644 index d4a168c..0000000 --- a/packages/integration-test/importDefault/asyncIteratorDrop.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { asyncIteratorDrop } from 'iter-fest'; - -test('asyncIteratorDrop should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorDrop(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorEvery.test.ts b/packages/integration-test/importDefault/asyncIteratorEvery.test.ts deleted file mode 100644 index bda934e..0000000 --- a/packages/integration-test/importDefault/asyncIteratorEvery.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { asyncIteratorEvery, asyncIteratorTake } from 'iter-fest'; - -test('asyncIteratorEvery should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 10); - - await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); - await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. - - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( - false - ); // first value is 0 - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/importDefault/asyncIteratorFilter.test.ts b/packages/integration-test/importDefault/asyncIteratorFilter.test.ts deleted file mode 100644 index 6b494a3..0000000 --- a/packages/integration-test/importDefault/asyncIteratorFilter.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { asyncIteratorFilter } from 'iter-fest'; - -test('asyncIteratorFilter should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorFind.test.ts b/packages/integration-test/importDefault/asyncIteratorFind.test.ts deleted file mode 100644 index cb2dd11..0000000 --- a/packages/integration-test/importDefault/asyncIteratorFind.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { asyncIteratorFind } from 'iter-fest'; - -test('asyncIteratorFind should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorFlatMap.test.ts b/packages/integration-test/importDefault/asyncIteratorFlatMap.test.ts deleted file mode 100644 index b791e81..0000000 --- a/packages/integration-test/importDefault/asyncIteratorFlatMap.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { asyncIteratorFlatMap, iteratorToAsync } from 'iter-fest'; - -test('should follow TC39 proposal sample (sync)', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); - - const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); - - await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); - await expect(result.next()).resolves.toEqual({ done: false, value: '' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorForEach.test.ts b/packages/integration-test/importDefault/asyncIteratorForEach.test.ts deleted file mode 100644 index 4e65c44..0000000 --- a/packages/integration-test/importDefault/asyncIteratorForEach.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { asyncIteratorForEach, iteratorToAsync } from 'iter-fest'; - -test('asyncIteratorForEach should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = async (value: number) => void log.push(value); - const iter = iteratorToAsync([1, 2, 3].values()); - - await asyncIteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorFrom.test.ts b/packages/integration-test/importDefault/asyncIteratorFrom.test.ts deleted file mode 100644 index 7b317c3..0000000 --- a/packages/integration-test/importDefault/asyncIteratorFrom.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { asyncIteratorFrom } from 'iter-fest'; - -test('asyncIteratorFrom should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return Promise.resolve({ done: false, value: 1 }); - } - } - - const iter = new Iter(); - const wrapper = asyncIteratorFrom(iter); - - await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorMap.test.ts b/packages/integration-test/importDefault/asyncIteratorMap.test.ts deleted file mode 100644 index 7db616e..0000000 --- a/packages/integration-test/importDefault/asyncIteratorMap.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { asyncIteratorMap } from 'iter-fest'; - -test('asyncIteratorMap should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorMap(naturals(), value => { - return value * value; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorReduce.test.ts b/packages/integration-test/importDefault/asyncIteratorReduce.test.ts deleted file mode 100644 index 3253176..0000000 --- a/packages/integration-test/importDefault/asyncIteratorReduce.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { asyncIteratorReduce, asyncIteratorTake } from 'iter-fest'; - -test('asyncIteratorReduce should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorReduce( - asyncIteratorTake(naturals(), 5), - async (sum, value) => { - return sum + value; - }, - 3 - ); - - await expect(result).resolves.toBe(13); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorSome.test.ts b/packages/integration-test/importDefault/asyncIteratorSome.test.ts deleted file mode 100644 index 34253a3..0000000 --- a/packages/integration-test/importDefault/asyncIteratorSome.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { asyncIteratorSome, asyncIteratorTake } from 'iter-fest'; - -test('asyncIteratorSome should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 4); - - await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. - - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/importDefault/asyncIteratorTake.test.ts b/packages/integration-test/importDefault/asyncIteratorTake.test.ts deleted file mode 100644 index 7a1fb45..0000000 --- a/packages/integration-test/importDefault/asyncIteratorTake.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { asyncIteratorTake } from 'iter-fest'; - -test('asyncIteratorTake should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorTake(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorToArray.test.ts b/packages/integration-test/importDefault/asyncIteratorToArray.test.ts deleted file mode 100644 index eb14885..0000000 --- a/packages/integration-test/importDefault/asyncIteratorToArray.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { asyncIteratorTake, asyncIteratorToArray } from 'iter-fest'; - -test('asyncIteratorToArray should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); - - await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/importDefault/asyncIteratorToIterable.test.ts b/packages/integration-test/importDefault/asyncIteratorToIterable.test.ts deleted file mode 100644 index 1c8af87..0000000 --- a/packages/integration-test/importDefault/asyncIteratorToIterable.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { asyncIteratorToAsyncIterable } from 'iter-fest'; - -test('asyncIteratorToIterable should work', async () => { - const iterable = asyncIteratorToAsyncIterable( - ((): AsyncIterator => { - let value = 0; - - return { - next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) - }; - })() - ); - - const values: number[] = []; - - for await (const value of iterable) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/importDefault/generatorWithLastValue.test.ts b/packages/integration-test/importDefault/generatorWithLastValue.test.ts deleted file mode 100644 index 06021d5..0000000 --- a/packages/integration-test/importDefault/generatorWithLastValue.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { generatorWithLastValue } from 'iter-fest'; - -test('generatorWithLastValue should work', () => { - const generator = generatorWithLastValue( - (function* () { - yield 1; - - return 'end' as const; - })() - ); - - for (const value of generator) { - expect(value).toBe(1); - } - - expect(generator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/importDefault/iterableWritableStream.test.ts b/packages/integration-test/importDefault/iterableWritableStream.test.ts deleted file mode 100644 index b93e300..0000000 --- a/packages/integration-test/importDefault/iterableWritableStream.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import withResolvers from 'core-js-pure/full/promise/with-resolvers'; -import { IterableWritableStream } from 'iter-fest'; - -test('IterableWritableStream should work', async () => { - let deferred = withResolvers(); - const done = jest.fn(); - const iterable = new IterableWritableStream(); - const writer = iterable.getWriter(); - const values = []; - - (async function () { - for await (const value of iterable) { - values.push(value); - - deferred.resolve(); - deferred = withResolvers(); - } - - done(); - deferred.resolve(); - })(); - - expect(values).toEqual([]); - expect(done).not.toHaveBeenCalled(); - - writer.write(1); - await deferred.promise; - expect(values).toEqual([1]); - expect(done).not.toHaveBeenCalled(); - - writer.write(2); - await deferred.promise; - expect(values).toEqual([1, 2]); - expect(done).not.toHaveBeenCalled(); - - writer.close(); - await deferred.promise; - expect(done).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/importDefault/iteratorAt.test.ts b/packages/integration-test/importDefault/iteratorAt.test.ts deleted file mode 100644 index 9245388..0000000 --- a/packages/integration-test/importDefault/iteratorAt.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorAt } from 'iter-fest'; - -test('iteratorAt should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); diff --git a/packages/integration-test/importDefault/iteratorConcat.test.ts b/packages/integration-test/importDefault/iteratorConcat.test.ts deleted file mode 100644 index d1fff69..0000000 --- a/packages/integration-test/importDefault/iteratorConcat.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorConcat } from 'iter-fest'; - -test('iterableConcat should work', () => - expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); diff --git a/packages/integration-test/importDefault/iteratorDrop.test.ts b/packages/integration-test/importDefault/iteratorDrop.test.ts deleted file mode 100644 index 0cea825..0000000 --- a/packages/integration-test/importDefault/iteratorDrop.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { iteratorDrop } from 'iter-fest'; - -test('iteratorDrop should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorDrop(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 3 }); - expect(result.next()).toEqual({ done: false, value: 4 }); - expect(result.next()).toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/importDefault/iteratorEntries.test.ts b/packages/integration-test/importDefault/iteratorEntries.test.ts deleted file mode 100644 index c25eb05..0000000 --- a/packages/integration-test/importDefault/iteratorEntries.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { iteratorEntries } from 'iter-fest'; - -test('iteratorEntries should work', () => - expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ - [0, 'A'], - [1, 'B'], - [2, 'C'] - ])); diff --git a/packages/integration-test/importDefault/iteratorEvery.test.ts b/packages/integration-test/importDefault/iteratorEvery.test.ts deleted file mode 100644 index 3c5daca..0000000 --- a/packages/integration-test/importDefault/iteratorEvery.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { iteratorEvery, iteratorTake } from 'iter-fest'; - -test('iteratorEvery should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 10); - - expect(iteratorEvery(iter, v => v >= 0)).toBe(true); - expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. - - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/importDefault/iteratorFilter.test.ts b/packages/integration-test/importDefault/iteratorFilter.test.ts deleted file mode 100644 index b0c2c9a..0000000 --- a/packages/integration-test/importDefault/iteratorFilter.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { iteratorFilter } from 'iter-fest'; - -test('iteratorFilter should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importDefault/iteratorFind.test.ts b/packages/integration-test/importDefault/iteratorFind.test.ts deleted file mode 100644 index d0cd9a2..0000000 --- a/packages/integration-test/importDefault/iteratorFind.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { iteratorFind } from 'iter-fest'; - -test('iteratorFind should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - expect(iteratorFind(naturals(), v => v > 1)).toBe(2); -}); diff --git a/packages/integration-test/importDefault/iteratorFindIndex.test.ts b/packages/integration-test/importDefault/iteratorFindIndex.test.ts deleted file mode 100644 index d120a13..0000000 --- a/packages/integration-test/importDefault/iteratorFindIndex.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorFindIndex } from 'iter-fest'; - -test('iteratorFindIndex should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); diff --git a/packages/integration-test/importDefault/iteratorFindLast.test.ts b/packages/integration-test/importDefault/iteratorFindLast.test.ts deleted file mode 100644 index 2558eba..0000000 --- a/packages/integration-test/importDefault/iteratorFindLast.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorFindLast } from 'iter-fest'; - -test('iteratorFindLast should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); diff --git a/packages/integration-test/importDefault/iteratorFindLastIndex.test.ts b/packages/integration-test/importDefault/iteratorFindLastIndex.test.ts deleted file mode 100644 index 304f61c..0000000 --- a/packages/integration-test/importDefault/iteratorFindLastIndex.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorFindLastIndex } from 'iter-fest'; - -test('iteratorFindLastIndex should work', () => - expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); diff --git a/packages/integration-test/importDefault/iteratorFlatMap.test.ts b/packages/integration-test/importDefault/iteratorFlatMap.test.ts deleted file mode 100644 index a4b47b9..0000000 --- a/packages/integration-test/importDefault/iteratorFlatMap.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { iteratorFlatMap } from 'iter-fest'; - -test('iteratorFlatMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = ["It's Sunny in", '', 'California'].values(); - - const result = iteratorFlatMap(sunny, value => value.split(' ').values()); - - expect(result.next()).toEqual({ done: false, value: "It's" }); - expect(result.next()).toEqual({ done: false, value: 'Sunny' }); - expect(result.next()).toEqual({ done: false, value: 'in' }); - expect(result.next()).toEqual({ done: false, value: '' }); - expect(result.next()).toEqual({ done: false, value: 'California' }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importDefault/iteratorForEach.test.ts b/packages/integration-test/importDefault/iteratorForEach.test.ts deleted file mode 100644 index b5a6557..0000000 --- a/packages/integration-test/importDefault/iteratorForEach.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { iteratorForEach } from 'iter-fest'; - -test('iteratorForEach should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = (value: number) => log.push(value); - const iter = [1, 2, 3].values(); - - iteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/importDefault/iteratorFrom.test.ts b/packages/integration-test/importDefault/iteratorFrom.test.ts deleted file mode 100644 index e6449b3..0000000 --- a/packages/integration-test/importDefault/iteratorFrom.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { iteratorFrom } from 'iter-fest'; - -test('iteratorFrom should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return { done: false, value: 1 }; - } - } - - const iter = new Iter(); - const wrapper = iteratorFrom(iter); - - expect(wrapper.next()).toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/importDefault/iteratorIncludes.test.ts b/packages/integration-test/importDefault/iteratorIncludes.test.ts deleted file mode 100644 index 48597e1..0000000 --- a/packages/integration-test/importDefault/iteratorIncludes.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorIncludes } from 'iter-fest'; - -test('iteratorIncludes should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); diff --git a/packages/integration-test/importDefault/iteratorIndexOf.test.ts b/packages/integration-test/importDefault/iteratorIndexOf.test.ts deleted file mode 100644 index 876ac19..0000000 --- a/packages/integration-test/importDefault/iteratorIndexOf.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorIndexOf } from 'iter-fest'; - -test('iteratorIndexOf should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); diff --git a/packages/integration-test/importDefault/iteratorJoin.test.ts b/packages/integration-test/importDefault/iteratorJoin.test.ts deleted file mode 100644 index 20318ce..0000000 --- a/packages/integration-test/importDefault/iteratorJoin.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorJoin } from 'iter-fest'; - -test('iteratorJoin should work', () => expect(iteratorJoin([1, 2, 3].values(), ', ')).toBe('1, 2, 3')); diff --git a/packages/integration-test/importDefault/iteratorKeys.test.ts b/packages/integration-test/importDefault/iteratorKeys.test.ts deleted file mode 100644 index c3b8103..0000000 --- a/packages/integration-test/importDefault/iteratorKeys.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorKeys } from 'iter-fest'; - -test('iteratorKeys should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); diff --git a/packages/integration-test/importDefault/iteratorMap.test.ts b/packages/integration-test/importDefault/iteratorMap.test.ts deleted file mode 100644 index c53f83d..0000000 --- a/packages/integration-test/importDefault/iteratorMap.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { iteratorMap } from 'iter-fest'; - -test('iteratorMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorMap(naturals(), value => { - return value * value; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importDefault/iteratorReduce.test.ts b/packages/integration-test/importDefault/iteratorReduce.test.ts deleted file mode 100644 index 719551a..0000000 --- a/packages/integration-test/importDefault/iteratorReduce.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { iteratorReduce, iteratorTake } from 'iter-fest'; - -test('iteratorReduce should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorReduce( - iteratorTake(naturals(), 5), - (sum, value) => { - return sum + value; - }, - 3 - ); - - expect(result).toBe(13); -}); diff --git a/packages/integration-test/importDefault/iteratorSlice.test.ts b/packages/integration-test/importDefault/iteratorSlice.test.ts deleted file mode 100644 index ae2c5dc..0000000 --- a/packages/integration-test/importDefault/iteratorSlice.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorSlice } from 'iter-fest'; - -test('iteratorSlice should work', () => - expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); diff --git a/packages/integration-test/importDefault/iteratorSome.test.ts b/packages/integration-test/importDefault/iteratorSome.test.ts deleted file mode 100644 index d561dc9..0000000 --- a/packages/integration-test/importDefault/iteratorSome.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { iteratorSome, iteratorTake } from 'iter-fest'; - -test('iteratorSome should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 4); - - expect(iteratorSome(iter, v => v > 1)).toEqual(true); - expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. - - expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); - expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/importDefault/iteratorTake.test.ts b/packages/integration-test/importDefault/iteratorTake.test.ts deleted file mode 100644 index a4c3caf..0000000 --- a/packages/integration-test/importDefault/iteratorTake.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { iteratorTake } from 'iter-fest'; - -test('iteratorTake should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorTake(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importDefault/iteratorToArray.test.ts b/packages/integration-test/importDefault/iteratorToArray.test.ts deleted file mode 100644 index dd23768..0000000 --- a/packages/integration-test/importDefault/iteratorToArray.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { iteratorTake, iteratorToArray } from 'iter-fest'; - -test('iteratorToArray should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorToArray(iteratorTake(naturals(), 5)); - - expect(result).toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/importDefault/iteratorToAsync.test.ts b/packages/integration-test/importDefault/iteratorToAsync.test.ts deleted file mode 100644 index 956c715..0000000 --- a/packages/integration-test/importDefault/iteratorToAsync.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { iteratorToAsync } from 'iter-fest'; - -test('iteratorToAsync should work', async () => { - const iterator = [1, 2, 3].values(); - const asyncIterator = iteratorToAsync(iterator); - - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importDefault/iteratorToIterable.test.ts b/packages/integration-test/importDefault/iteratorToIterable.test.ts deleted file mode 100644 index b6f2a9f..0000000 --- a/packages/integration-test/importDefault/iteratorToIterable.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { iteratorToIterable, Observable } from 'iter-fest'; - -test('iteratorToIterable should work', () => - expect( - Array.from( - iteratorToIterable( - ((): Iterator => { - let value = 0; - - return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; - })() - ) - ) - ).toEqual([1, 2, 3])); - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/importDefault/iteratorToSpliced.test.ts b/packages/integration-test/importDefault/iteratorToSpliced.test.ts deleted file mode 100644 index 2509bcb..0000000 --- a/packages/integration-test/importDefault/iteratorToSpliced.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorToSpliced } from 'iter-fest'; - -test('iteratorToSpliced should work', () => - expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); diff --git a/packages/integration-test/importDefault/iteratorToString.test.ts b/packages/integration-test/importDefault/iteratorToString.test.ts deleted file mode 100644 index b53da6c..0000000 --- a/packages/integration-test/importDefault/iteratorToString.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorToString } from 'iter-fest'; - -test('iteratorToString should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); diff --git a/packages/integration-test/importDefault/observable.test.ts b/packages/integration-test/importDefault/observable.test.ts deleted file mode 100644 index e1a6a6d..0000000 --- a/packages/integration-test/importDefault/observable.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Observable } from 'iter-fest'; - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/importDefault/observableFromAsync.test.ts b/packages/integration-test/importDefault/observableFromAsync.test.ts deleted file mode 100644 index 816884a..0000000 --- a/packages/integration-test/importDefault/observableFromAsync.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { observableFromAsync } from 'iter-fest'; - -test('observableFromAsync should work', async () => { - const observable = observableFromAsync( - (async function* () { - yield 1; - yield 2; - yield 3; - })() - ); - - const next = jest.fn(); - - await new Promise(resolve => observable.subscribe({ complete: resolve, next })); - - expect(next).toHaveBeenCalledTimes(3); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(next).toHaveBeenNthCalledWith(2, 2); - expect(next).toHaveBeenNthCalledWith(3, 3); -}); diff --git a/packages/integration-test/importDefault/observableSubscribeAsReadable.test.ts b/packages/integration-test/importDefault/observableSubscribeAsReadable.test.ts deleted file mode 100644 index 483ab53..0000000 --- a/packages/integration-test/importDefault/observableSubscribeAsReadable.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Observable, observableSubscribeAsReadable } from 'iter-fest'; - -test('observableSubscribeAsReadable should work', async () => { - const stream = new TextDecoderStream(); - const observable = Observable.from([65, 66, 67]); - const readable = observableSubscribeAsReadable(observable); - const numberToInt8Array = new TransformStream({ - transform(chunk, controller) { - controller.enqueue(Int8Array.from([chunk])); - } - }); - - readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); - - const reader = stream.readable.getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); - await expect(reader.read()).resolves.toEqual({ done: true }); -}); diff --git a/packages/integration-test/importDefault/observableValues.test.ts b/packages/integration-test/importDefault/observableValues.test.ts deleted file mode 100644 index de33e19..0000000 --- a/packages/integration-test/importDefault/observableValues.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Observable, observableValues } from 'iter-fest'; - -test('observableValues should work', async () => { - const observable = Observable.from([1, 2, 3]); - const values: number[] = []; - - for await (const value of observableValues(observable)) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/importDefault/readableStreamFrom.test.ts b/packages/integration-test/importDefault/readableStreamFrom.test.ts deleted file mode 100644 index 93429de..0000000 --- a/packages/integration-test/importDefault/readableStreamFrom.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { readableStreamFrom } from 'iter-fest'; - -test('readableStreamFrom should work', async () => { - const iterable = [1, 2, 3].values(); - - const reader = readableStreamFrom(iterable).getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); - await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importDefault/readableStreamValues.test.ts b/packages/integration-test/importDefault/readableStreamValues.test.ts deleted file mode 100644 index 1f09cc8..0000000 --- a/packages/integration-test/importDefault/readableStreamValues.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { readableStreamValues } from 'iter-fest'; - -test('readableStreamValues should work', async () => { - const readableStream = new ReadableStream({ - start(controller) { - controller.enqueue(1); - controller.enqueue(2); - controller.close(); - } - }); - - const values = []; - - for await (const value of readableStreamValues(readableStream)) { - values.push(value); - } - - expect(values).toEqual([1, 2]); -}); diff --git a/packages/integration-test/importDefault/symbolObservable.test.ts b/packages/integration-test/importDefault/symbolObservable.test.ts deleted file mode 100644 index 7b29a4a..0000000 --- a/packages/integration-test/importDefault/symbolObservable.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Observable, SymbolObservable } from 'iter-fest'; - -test('SymbolObservable should work', () => { - const observable = new Observable(() => {}); - - expect(observable[SymbolObservable]()).toBe(observable); -}); diff --git a/packages/integration-test/importNamed/asyncGeneratorWithLastValue.test.ts b/packages/integration-test/importNamed/asyncGeneratorWithLastValue.test.ts deleted file mode 100644 index 40fe959..0000000 --- a/packages/integration-test/importNamed/asyncGeneratorWithLastValue.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { asyncGeneratorWithLastValue } from 'iter-fest/asyncGeneratorWithLastValue'; - -test('asyncGeneratorWithLastValue should work', async () => { - const asyncGenerator = asyncGeneratorWithLastValue( - (async function* () { - yield 1; - - return 'end' as const; - })() - ); - - for await (const value of asyncGenerator) { - expect(value).toBe(1); - } - - expect(asyncGenerator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorDrop.test.ts b/packages/integration-test/importNamed/asyncIteratorDrop.test.ts deleted file mode 100644 index 5939c32..0000000 --- a/packages/integration-test/importNamed/asyncIteratorDrop.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { asyncIteratorDrop } from 'iter-fest/asyncIteratorDrop'; - -test('asyncIteratorDrop should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorDrop(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorEvery.test.ts b/packages/integration-test/importNamed/asyncIteratorEvery.test.ts deleted file mode 100644 index e563f3d..0000000 --- a/packages/integration-test/importNamed/asyncIteratorEvery.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { asyncIteratorEvery } from 'iter-fest/asyncIteratorEvery'; -import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; - -test('asyncIteratorEvery should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 10); - - await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); - await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. - - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( - false - ); // first value is 0 - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/importNamed/asyncIteratorFilter.test.ts b/packages/integration-test/importNamed/asyncIteratorFilter.test.ts deleted file mode 100644 index f838872..0000000 --- a/packages/integration-test/importNamed/asyncIteratorFilter.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { asyncIteratorFilter } from 'iter-fest/asyncIteratorFilter'; - -test('asyncIteratorFilter should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorFind.test.ts b/packages/integration-test/importNamed/asyncIteratorFind.test.ts deleted file mode 100644 index 652a7d5..0000000 --- a/packages/integration-test/importNamed/asyncIteratorFind.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { asyncIteratorFind } from 'iter-fest/asyncIteratorFind'; - -test('asyncIteratorFind should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorFlatMap.test.ts b/packages/integration-test/importNamed/asyncIteratorFlatMap.test.ts deleted file mode 100644 index 8813a1a..0000000 --- a/packages/integration-test/importNamed/asyncIteratorFlatMap.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { asyncIteratorFlatMap } from 'iter-fest/asyncIteratorFlatMap'; -import { iteratorToAsync } from 'iter-fest/iteratorToAsync'; - -test('should follow TC39 proposal sample (sync)', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); - - const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); - - await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); - await expect(result.next()).resolves.toEqual({ done: false, value: '' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorForEach.test.ts b/packages/integration-test/importNamed/asyncIteratorForEach.test.ts deleted file mode 100644 index 13550a7..0000000 --- a/packages/integration-test/importNamed/asyncIteratorForEach.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { asyncIteratorForEach } from 'iter-fest/asyncIteratorForEach'; -import { iteratorToAsync } from 'iter-fest/iteratorToAsync'; - -test('asyncIteratorForEach should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = async (value: number) => void log.push(value); - const iter = iteratorToAsync([1, 2, 3].values()); - - await asyncIteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorFrom.test.ts b/packages/integration-test/importNamed/asyncIteratorFrom.test.ts deleted file mode 100644 index 9945a8d..0000000 --- a/packages/integration-test/importNamed/asyncIteratorFrom.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { asyncIteratorFrom } from 'iter-fest/asyncIteratorFrom'; - -test('asyncIteratorFrom should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return Promise.resolve({ done: false, value: 1 }); - } - } - - const iter = new Iter(); - const wrapper = asyncIteratorFrom(iter); - - await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorMap.test.ts b/packages/integration-test/importNamed/asyncIteratorMap.test.ts deleted file mode 100644 index 69fbc16..0000000 --- a/packages/integration-test/importNamed/asyncIteratorMap.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { asyncIteratorMap } from 'iter-fest/asyncIteratorMap'; - -test('asyncIteratorMap should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorMap(naturals(), value => { - return value * value; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorReduce.test.ts b/packages/integration-test/importNamed/asyncIteratorReduce.test.ts deleted file mode 100644 index 87cc75b..0000000 --- a/packages/integration-test/importNamed/asyncIteratorReduce.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { asyncIteratorReduce } from 'iter-fest/asyncIteratorReduce'; -import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; - -test('asyncIteratorReduce should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorReduce( - asyncIteratorTake(naturals(), 5), - async (sum, value) => { - return sum + value; - }, - 3 - ); - - await expect(result).resolves.toBe(13); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorSome.test.ts b/packages/integration-test/importNamed/asyncIteratorSome.test.ts deleted file mode 100644 index 0ec52a9..0000000 --- a/packages/integration-test/importNamed/asyncIteratorSome.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { asyncIteratorSome } from 'iter-fest/asyncIteratorSome'; -import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; - -test('asyncIteratorSome should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 4); - - await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. - - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/importNamed/asyncIteratorTake.test.ts b/packages/integration-test/importNamed/asyncIteratorTake.test.ts deleted file mode 100644 index d63ba27..0000000 --- a/packages/integration-test/importNamed/asyncIteratorTake.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; - -test('asyncIteratorTake should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorTake(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorToArray.test.ts b/packages/integration-test/importNamed/asyncIteratorToArray.test.ts deleted file mode 100644 index ff4feaf..0000000 --- a/packages/integration-test/importNamed/asyncIteratorToArray.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; -import { asyncIteratorToArray } from 'iter-fest/asyncIteratorToArray'; - -test('asyncIteratorToArray should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); - - await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/importNamed/asyncIteratorToIterable.test.ts b/packages/integration-test/importNamed/asyncIteratorToIterable.test.ts deleted file mode 100644 index bdfae8e..0000000 --- a/packages/integration-test/importNamed/asyncIteratorToIterable.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { asyncIteratorToAsyncIterable } from 'iter-fest/asyncIteratorToAsyncIterable'; - -test('asyncIteratorToIterable should work', async () => { - const iterable = asyncIteratorToAsyncIterable( - ((): AsyncIterator => { - let value = 0; - - return { - next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) - }; - })() - ); - - const values: number[] = []; - - for await (const value of iterable) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/importNamed/generatorWithLastValue.test.ts b/packages/integration-test/importNamed/generatorWithLastValue.test.ts deleted file mode 100644 index a871721..0000000 --- a/packages/integration-test/importNamed/generatorWithLastValue.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { generatorWithLastValue } from 'iter-fest/generatorWithLastValue'; - -test('generatorWithLastValue should work', () => { - const generator = generatorWithLastValue( - (function* () { - yield 1; - - return 'end' as const; - })() - ); - - for (const value of generator) { - expect(value).toBe(1); - } - - expect(generator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/importNamed/iterableWritableStream.test.ts b/packages/integration-test/importNamed/iterableWritableStream.test.ts deleted file mode 100644 index 789f593..0000000 --- a/packages/integration-test/importNamed/iterableWritableStream.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import withResolvers from 'core-js-pure/full/promise/with-resolvers'; -import { IterableWritableStream } from 'iter-fest/iterableWritableStream'; - -test('IterableWritableStream should work', async () => { - let deferred = withResolvers(); - const done = jest.fn(); - const iterable = new IterableWritableStream(); - const writer = iterable.getWriter(); - const values = []; - - (async function () { - for await (const value of iterable) { - values.push(value); - - deferred.resolve(); - deferred = withResolvers(); - } - - done(); - deferred.resolve(); - })(); - - expect(values).toEqual([]); - expect(done).not.toHaveBeenCalled(); - - writer.write(1); - await deferred.promise; - expect(values).toEqual([1]); - expect(done).not.toHaveBeenCalled(); - - writer.write(2); - await deferred.promise; - expect(values).toEqual([1, 2]); - expect(done).not.toHaveBeenCalled(); - - writer.close(); - await deferred.promise; - expect(done).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/importNamed/iteratorAt.test.ts b/packages/integration-test/importNamed/iteratorAt.test.ts deleted file mode 100644 index 8027ef1..0000000 --- a/packages/integration-test/importNamed/iteratorAt.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorAt } from 'iter-fest/iteratorAt'; - -test('iteratorAt should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); diff --git a/packages/integration-test/importNamed/iteratorConcat.test.ts b/packages/integration-test/importNamed/iteratorConcat.test.ts deleted file mode 100644 index abf5789..0000000 --- a/packages/integration-test/importNamed/iteratorConcat.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorConcat } from 'iter-fest/iteratorConcat'; - -test('iterableConcat should work', () => - expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); diff --git a/packages/integration-test/importNamed/iteratorDrop.test.ts b/packages/integration-test/importNamed/iteratorDrop.test.ts deleted file mode 100644 index 7d27bba..0000000 --- a/packages/integration-test/importNamed/iteratorDrop.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { iteratorDrop } from 'iter-fest/iteratorDrop'; - -test('iteratorDrop should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorDrop(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 3 }); - expect(result.next()).toEqual({ done: false, value: 4 }); - expect(result.next()).toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/importNamed/iteratorEntries.test.ts b/packages/integration-test/importNamed/iteratorEntries.test.ts deleted file mode 100644 index 5913ee0..0000000 --- a/packages/integration-test/importNamed/iteratorEntries.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { iteratorEntries } from 'iter-fest/iteratorEntries'; - -test('iteratorEntries should work', () => - expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ - [0, 'A'], - [1, 'B'], - [2, 'C'] - ])); diff --git a/packages/integration-test/importNamed/iteratorEvery.test.ts b/packages/integration-test/importNamed/iteratorEvery.test.ts deleted file mode 100644 index e4a703e..0000000 --- a/packages/integration-test/importNamed/iteratorEvery.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { iteratorEvery } from 'iter-fest/iteratorEvery'; -import { iteratorTake } from 'iter-fest/iteratorTake'; - -test('iteratorEvery should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 10); - - expect(iteratorEvery(iter, v => v >= 0)).toBe(true); - expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. - - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/importNamed/iteratorFilter.test.ts b/packages/integration-test/importNamed/iteratorFilter.test.ts deleted file mode 100644 index e849e18..0000000 --- a/packages/integration-test/importNamed/iteratorFilter.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { iteratorFilter } from 'iter-fest/iteratorFilter'; - -test('iteratorFilter should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importNamed/iteratorFind.test.ts b/packages/integration-test/importNamed/iteratorFind.test.ts deleted file mode 100644 index e381d1c..0000000 --- a/packages/integration-test/importNamed/iteratorFind.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { iteratorFind } from 'iter-fest/iteratorFind'; - -test('iteratorFind should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - expect(iteratorFind(naturals(), v => v > 1)).toBe(2); -}); diff --git a/packages/integration-test/importNamed/iteratorFindIndex.test.ts b/packages/integration-test/importNamed/iteratorFindIndex.test.ts deleted file mode 100644 index a8c2c60..0000000 --- a/packages/integration-test/importNamed/iteratorFindIndex.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorFindIndex } from 'iter-fest/iteratorFindIndex'; - -test('iteratorFindIndex should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); diff --git a/packages/integration-test/importNamed/iteratorFindLast.test.ts b/packages/integration-test/importNamed/iteratorFindLast.test.ts deleted file mode 100644 index 1ec3bf4..0000000 --- a/packages/integration-test/importNamed/iteratorFindLast.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorFindLast } from 'iter-fest/iteratorFindLast'; - -test('iteratorFindLast should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); diff --git a/packages/integration-test/importNamed/iteratorFindLastIndex.test.ts b/packages/integration-test/importNamed/iteratorFindLastIndex.test.ts deleted file mode 100644 index 1838227..0000000 --- a/packages/integration-test/importNamed/iteratorFindLastIndex.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorFindLastIndex } from 'iter-fest/iteratorFindLastIndex'; - -test('iteratorFindLastIndex should work', () => - expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); diff --git a/packages/integration-test/importNamed/iteratorFlatMap.test.ts b/packages/integration-test/importNamed/iteratorFlatMap.test.ts deleted file mode 100644 index 3ef201a..0000000 --- a/packages/integration-test/importNamed/iteratorFlatMap.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { iteratorFlatMap } from 'iter-fest/iteratorFlatMap'; - -test('iteratorFlatMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = ["It's Sunny in", '', 'California'].values(); - - const result = iteratorFlatMap(sunny, value => value.split(' ').values()); - - expect(result.next()).toEqual({ done: false, value: "It's" }); - expect(result.next()).toEqual({ done: false, value: 'Sunny' }); - expect(result.next()).toEqual({ done: false, value: 'in' }); - expect(result.next()).toEqual({ done: false, value: '' }); - expect(result.next()).toEqual({ done: false, value: 'California' }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importNamed/iteratorForEach.test.ts b/packages/integration-test/importNamed/iteratorForEach.test.ts deleted file mode 100644 index f7e06ef..0000000 --- a/packages/integration-test/importNamed/iteratorForEach.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { iteratorForEach } from 'iter-fest/iteratorForEach'; - -test('iteratorForEach should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = (value: number) => log.push(value); - const iter = [1, 2, 3].values(); - - iteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/importNamed/iteratorFrom.test.ts b/packages/integration-test/importNamed/iteratorFrom.test.ts deleted file mode 100644 index 429a08b..0000000 --- a/packages/integration-test/importNamed/iteratorFrom.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { iteratorFrom } from 'iter-fest/iteratorFrom'; - -test('iteratorFrom should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return { done: false, value: 1 }; - } - } - - const iter = new Iter(); - const wrapper = iteratorFrom(iter); - - expect(wrapper.next()).toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/importNamed/iteratorIncludes.test.ts b/packages/integration-test/importNamed/iteratorIncludes.test.ts deleted file mode 100644 index 976a207..0000000 --- a/packages/integration-test/importNamed/iteratorIncludes.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorIncludes } from 'iter-fest/iteratorIncludes'; - -test('iteratorIncludes should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); diff --git a/packages/integration-test/importNamed/iteratorIndexOf.test.ts b/packages/integration-test/importNamed/iteratorIndexOf.test.ts deleted file mode 100644 index 82d3454..0000000 --- a/packages/integration-test/importNamed/iteratorIndexOf.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorIndexOf } from 'iter-fest/iteratorIndexOf'; - -test('iteratorIndexOf should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); diff --git a/packages/integration-test/importNamed/iteratorKeys.test.ts b/packages/integration-test/importNamed/iteratorKeys.test.ts deleted file mode 100644 index 524008b..0000000 --- a/packages/integration-test/importNamed/iteratorKeys.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorKeys } from 'iter-fest/iteratorKeys'; - -test('iteratorKeys should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); diff --git a/packages/integration-test/importNamed/iteratorMap.test.ts b/packages/integration-test/importNamed/iteratorMap.test.ts deleted file mode 100644 index 6bf3901..0000000 --- a/packages/integration-test/importNamed/iteratorMap.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { iteratorMap } from 'iter-fest/iteratorMap'; - -test('iteratorMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorMap(naturals(), value => { - return value * value; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/importNamed/iteratorReduce.test.ts b/packages/integration-test/importNamed/iteratorReduce.test.ts deleted file mode 100644 index 530e758..0000000 --- a/packages/integration-test/importNamed/iteratorReduce.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { iteratorReduce } from 'iter-fest/iteratorReduce'; -import { iteratorTake } from 'iter-fest/iteratorTake'; - -test('iteratorReduce should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorReduce( - iteratorTake(naturals(), 5), - (sum, value) => { - return sum + value; - }, - 3 - ); - - expect(result).toBe(13); -}); diff --git a/packages/integration-test/importNamed/iteratorSlice.test.ts b/packages/integration-test/importNamed/iteratorSlice.test.ts deleted file mode 100644 index 7b032eb..0000000 --- a/packages/integration-test/importNamed/iteratorSlice.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorSlice } from 'iter-fest/iteratorSlice'; - -test('iteratorSlice should work', () => - expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); diff --git a/packages/integration-test/importNamed/iteratorSome.test.ts b/packages/integration-test/importNamed/iteratorSome.test.ts deleted file mode 100644 index e438425..0000000 --- a/packages/integration-test/importNamed/iteratorSome.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { iteratorSome } from 'iter-fest/iteratorSome'; -import { iteratorTake } from 'iter-fest/iteratorTake'; - -test('iteratorSome should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 4); - - expect(iteratorSome(iter, v => v > 1)).toEqual(true); - expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. - - expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); - expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/importNamed/iteratorTake.test.ts b/packages/integration-test/importNamed/iteratorTake.test.ts deleted file mode 100644 index ae26703..0000000 --- a/packages/integration-test/importNamed/iteratorTake.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { iteratorTake } from 'iter-fest/iteratorTake'; - -test('iteratorTake should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorTake(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importNamed/iteratorToArray.test.ts b/packages/integration-test/importNamed/iteratorToArray.test.ts deleted file mode 100644 index 09f7c6c..0000000 --- a/packages/integration-test/importNamed/iteratorToArray.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { iteratorTake } from 'iter-fest/iteratorTake'; -import { iteratorToArray } from 'iter-fest/iteratorToArray'; - -test('iteratorToArray should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorToArray(iteratorTake(naturals(), 5)); - - expect(result).toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/importNamed/iteratorToAsync.test.ts b/packages/integration-test/importNamed/iteratorToAsync.test.ts deleted file mode 100644 index eefe839..0000000 --- a/packages/integration-test/importNamed/iteratorToAsync.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { iteratorToAsync } from 'iter-fest/iteratorToAsync'; - -test('iteratorToAsync should work', async () => { - const iterator = [1, 2, 3].values(); - const asyncIterator = iteratorToAsync(iterator); - - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importNamed/iteratorToIterable.test.ts b/packages/integration-test/importNamed/iteratorToIterable.test.ts deleted file mode 100644 index 9c2c8d2..0000000 --- a/packages/integration-test/importNamed/iteratorToIterable.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { iteratorToIterable } from 'iter-fest/iteratorToIterable'; -import { Observable } from 'iter-fest/observable'; - -test('iteratorToIterable should work', () => - expect( - Array.from( - iteratorToIterable( - ((): Iterator => { - let value = 0; - - return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; - })() - ) - ) - ).toEqual([1, 2, 3])); - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/importNamed/iteratorToSpliced.test.ts b/packages/integration-test/importNamed/iteratorToSpliced.test.ts deleted file mode 100644 index 7bbdf47..0000000 --- a/packages/integration-test/importNamed/iteratorToSpliced.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { iteratorToSpliced } from 'iter-fest/iteratorToSpliced'; - -test('iteratorToSpliced should work', () => - expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); diff --git a/packages/integration-test/importNamed/iteratorToString.test.ts b/packages/integration-test/importNamed/iteratorToString.test.ts deleted file mode 100644 index aa0b536..0000000 --- a/packages/integration-test/importNamed/iteratorToString.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { iteratorToString } from 'iter-fest/iteratorToString'; - -test('iteratorToString should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); diff --git a/packages/integration-test/importNamed/observable.test.ts b/packages/integration-test/importNamed/observable.test.ts deleted file mode 100644 index 91af8ca..0000000 --- a/packages/integration-test/importNamed/observable.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Observable } from 'iter-fest/observable'; - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/importNamed/observableFromAsync.test.ts b/packages/integration-test/importNamed/observableFromAsync.test.ts deleted file mode 100644 index b27311d..0000000 --- a/packages/integration-test/importNamed/observableFromAsync.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { observableFromAsync } from 'iter-fest/observableFromAsync'; - -test('observableFromAsync should work', async () => { - const observable = observableFromAsync( - (async function* () { - yield 1; - yield 2; - yield 3; - })() - ); - - const next = jest.fn(); - - await new Promise(resolve => observable.subscribe({ complete: resolve, next })); - - expect(next).toHaveBeenCalledTimes(3); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(next).toHaveBeenNthCalledWith(2, 2); - expect(next).toHaveBeenNthCalledWith(3, 3); -}); diff --git a/packages/integration-test/importNamed/observableSubscribeAsReadable.test.ts b/packages/integration-test/importNamed/observableSubscribeAsReadable.test.ts deleted file mode 100644 index 4497389..0000000 --- a/packages/integration-test/importNamed/observableSubscribeAsReadable.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Observable } from 'iter-fest/observable'; -import { observableSubscribeAsReadable } from 'iter-fest/observableSubscribeAsReadable'; - -test('observableSubscribeAsReadable should work', async () => { - const stream = new TextDecoderStream(); - const observable = Observable.from([65, 66, 67]); - const readable = observableSubscribeAsReadable(observable); - const numberToInt8Array = new TransformStream({ - transform(chunk, controller) { - controller.enqueue(Int8Array.from([chunk])); - } - }); - - readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); - - const reader = stream.readable.getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); - await expect(reader.read()).resolves.toEqual({ done: true }); -}); diff --git a/packages/integration-test/importNamed/observableValues.test.ts b/packages/integration-test/importNamed/observableValues.test.ts deleted file mode 100644 index e604d3a..0000000 --- a/packages/integration-test/importNamed/observableValues.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Observable } from 'iter-fest/observable'; -import { observableValues } from 'iter-fest/observableValues'; - -test('observableValues should work', async () => { - const observable = Observable.from([1, 2, 3]); - const values: number[] = []; - - for await (const value of observableValues(observable)) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/importNamed/readableStreamFrom.test.ts b/packages/integration-test/importNamed/readableStreamFrom.test.ts deleted file mode 100644 index 8017eba..0000000 --- a/packages/integration-test/importNamed/readableStreamFrom.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { readableStreamFrom } from 'iter-fest/readableStreamFrom'; - -test('readableStreamFrom should work', async () => { - const iterable = [1, 2, 3].values(); - - const reader = readableStreamFrom(iterable).getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); - await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/importNamed/readableStreamValues.test.ts b/packages/integration-test/importNamed/readableStreamValues.test.ts deleted file mode 100644 index e23794c..0000000 --- a/packages/integration-test/importNamed/readableStreamValues.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { readableStreamValues } from 'iter-fest/readableStreamValues'; - -test('readableStreamValues should work', async () => { - const readableStream = new ReadableStream({ - start(controller) { - controller.enqueue(1); - controller.enqueue(2); - controller.close(); - } - }); - - const values = []; - - for await (const value of readableStreamValues(readableStream)) { - values.push(value); - } - - expect(values).toEqual([1, 2]); -}); diff --git a/packages/integration-test/importNamed/symbolObservable.test.ts b/packages/integration-test/importNamed/symbolObservable.test.ts deleted file mode 100644 index a69cdc8..0000000 --- a/packages/integration-test/importNamed/symbolObservable.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Observable } from 'iter-fest/observable'; -import { SymbolObservable } from 'iter-fest/symbolObservable'; - -test('SymbolObservable should work', () => { - const observable = new Observable(() => {}); - - expect(observable[SymbolObservable]()).toBe(observable); -}); diff --git a/packages/integration-test/jest.config.json b/packages/integration-test/jest.config.json deleted file mode 100644 index 6ce761c..0000000 --- a/packages/integration-test/jest.config.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "testMatch": ["**/__tests__/**/*.?([cm])[jt]s?(x)", "**/?(*.)+(spec|test).?([cm])[jt]s?(x)"], - "transform": { - "\\.(cjsx?|jsx?|mjsx?|ts)$": [ - "babel-jest", - { - "presets": [ - "@babel/preset-typescript", - [ - "@babel/preset-env", - { - "modules": "commonjs", - "targets": "defaults" - } - ] - ] - } - ] - } -} diff --git a/packages/integration-test/package.json b/packages/integration-test/package.json index d6f1d30..a66612b 100644 --- a/packages/integration-test/package.json +++ b/packages/integration-test/package.json @@ -10,7 +10,8 @@ "bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // {}) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | has($K) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true", "precommit": "eslint --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts ./", "switch": "cat package.json | jq --arg SWITCH_NAME $SWITCH_NAME -r '(.[\"switch:\" + $SWITCH_NAME] // {}) as $TEMPLATE | .devDependencies += ($TEMPLATE.devDependencies // {}) | .dependencies += ($TEMPLATE.dependencies // {})' | tee ./package.json.tmp && mv ./package.json.tmp ./package.json", - "test": "jest" + "test": "mocha --recursive", + "test:jest": "jest" }, "author": "William Wong (https://github.com/compulim)", "license": "MIT", @@ -18,13 +19,10 @@ "iter-fest": "^0.0.0-0" }, "devDependencies": { - "@babel/preset-env": "^7.24.6", - "@babel/preset-typescript": "^7.24.6", - "@types/jest": "^29.5.12", - "babel-jest": "^29.7.0", "core-js-pure": "^3.37.1", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0" + "expect": "^29.7.0", + "mocha": "^10.5.2", + "sinon": "^18.0.0" }, "dependencies": { "iter-fest": "^0.0.0-0" diff --git a/packages/integration-test/requireDefault/asyncGeneratorWithLastValue.test.ts b/packages/integration-test/requireDefault/asyncGeneratorWithLastValue.test.ts deleted file mode 100644 index 3347570..0000000 --- a/packages/integration-test/requireDefault/asyncGeneratorWithLastValue.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncGeneratorWithLastValue } = require('iter-fest'); - -test('asyncGeneratorWithLastValue should work', async () => { - const asyncGenerator = asyncGeneratorWithLastValue( - (async function* () { - yield 1; - - return 'end' as const; - })() - ); - - for await (const value of asyncGenerator) { - expect(value).toBe(1); - } - - expect(asyncGenerator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorDrop.test.ts b/packages/integration-test/requireDefault/asyncIteratorDrop.test.ts deleted file mode 100644 index 5ae0562..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorDrop.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorDrop } = require('iter-fest'); - -test('asyncIteratorDrop should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorDrop(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorEvery.test.ts b/packages/integration-test/requireDefault/asyncIteratorEvery.test.ts deleted file mode 100644 index 65fb35a..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorEvery.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorEvery, asyncIteratorTake } = require('iter-fest'); - -test('asyncIteratorEvery should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 10); - - await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); - await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. - - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( - false - ); // first value is 0 - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorFilter.test.ts b/packages/integration-test/requireDefault/asyncIteratorFilter.test.ts deleted file mode 100644 index 8f41256..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorFilter.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFilter } = require('iter-fest'); - -test('asyncIteratorFilter should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorFind.test.ts b/packages/integration-test/requireDefault/asyncIteratorFind.test.ts deleted file mode 100644 index 08cc6a1..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorFind.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFind } = require('iter-fest'); - -test('asyncIteratorFind should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorFlatMap.test.ts b/packages/integration-test/requireDefault/asyncIteratorFlatMap.test.ts deleted file mode 100644 index 7898445..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorFlatMap.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFlatMap, iteratorToAsync } = require('iter-fest'); - -test('should follow TC39 proposal sample (sync)', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); - - const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); - - await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); - await expect(result.next()).resolves.toEqual({ done: false, value: '' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorForEach.test.ts b/packages/integration-test/requireDefault/asyncIteratorForEach.test.ts deleted file mode 100644 index e66b402..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorForEach.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorForEach, iteratorToAsync } = require('iter-fest'); - -test('asyncIteratorForEach should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = async (value: number) => void log.push(value); - const iter = iteratorToAsync([1, 2, 3].values()); - - await asyncIteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorFrom.test.ts b/packages/integration-test/requireDefault/asyncIteratorFrom.test.ts deleted file mode 100644 index 8a87205..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorFrom.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFrom } = require('iter-fest'); - -test('asyncIteratorFrom should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return Promise.resolve({ done: false, value: 1 }); - } - } - - const iter = new Iter(); - const wrapper = asyncIteratorFrom(iter); - - await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorMap.test.ts b/packages/integration-test/requireDefault/asyncIteratorMap.test.ts deleted file mode 100644 index bb27813..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorMap.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorMap } = require('iter-fest'); - -test('asyncIteratorMap should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorMap(naturals(), value => { - return value * value; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorReduce.test.ts b/packages/integration-test/requireDefault/asyncIteratorReduce.test.ts deleted file mode 100644 index ddd6285..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorReduce.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorReduce, asyncIteratorTake } = require('iter-fest'); - -test('asyncIteratorReduce should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorReduce( - asyncIteratorTake(naturals(), 5), - async (sum, value) => { - return sum + value; - }, - 3 - ); - - await expect(result).resolves.toBe(13); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorSome.test.ts b/packages/integration-test/requireDefault/asyncIteratorSome.test.ts deleted file mode 100644 index 5450efc..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorSome.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorSome, asyncIteratorTake } = require('iter-fest'); - -test('asyncIteratorSome should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 4); - - await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. - - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorTake.test.ts b/packages/integration-test/requireDefault/asyncIteratorTake.test.ts deleted file mode 100644 index f702c98..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorTake.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorTake } = require('iter-fest'); - -test('asyncIteratorTake should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorTake(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorToArray.test.ts b/packages/integration-test/requireDefault/asyncIteratorToArray.test.ts deleted file mode 100644 index fe36741..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorToArray.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorTake, asyncIteratorToArray } = require('iter-fest'); - -test('asyncIteratorToArray should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); - - await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/requireDefault/asyncIteratorToIterable.test.ts b/packages/integration-test/requireDefault/asyncIteratorToIterable.test.ts deleted file mode 100644 index 22fc7f9..0000000 --- a/packages/integration-test/requireDefault/asyncIteratorToIterable.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorToAsyncIterable } = require('iter-fest'); - -test('asyncIteratorToIterable should work', async () => { - const iterable = asyncIteratorToAsyncIterable( - ((): AsyncIterator => { - let value = 0; - - return { - next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) - }; - })() - ); - - const values: number[] = []; - - for await (const value of iterable) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/requireDefault/generatorWithLastValue.test.ts b/packages/integration-test/requireDefault/generatorWithLastValue.test.ts deleted file mode 100644 index 7449621..0000000 --- a/packages/integration-test/requireDefault/generatorWithLastValue.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { generatorWithLastValue } = require('iter-fest'); - -test('generatorWithLastValue should work', () => { - const generator = generatorWithLastValue( - (function* () { - yield 1; - - return 'end' as const; - })() - ); - - for (const value of generator) { - expect(value).toBe(1); - } - - expect(generator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/requireDefault/iterableWritableStream.test.ts b/packages/integration-test/requireDefault/iterableWritableStream.test.ts deleted file mode 100644 index ac9d0bc..0000000 --- a/packages/integration-test/requireDefault/iterableWritableStream.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const withResolvers = require('core-js-pure/full/promise/with-resolvers'); -const { IterableWritableStream } = require('iter-fest'); - -test('IterableWritableStream should work', async () => { - let deferred = withResolvers(); - const done = jest.fn(); - const iterable = new IterableWritableStream(); - const writer = iterable.getWriter(); - const values = []; - - (async function () { - for await (const value of iterable) { - values.push(value); - - deferred.resolve(); - deferred = withResolvers(); - } - - done(); - deferred.resolve(); - })(); - - expect(values).toEqual([]); - expect(done).not.toHaveBeenCalled(); - - writer.write(1); - await deferred.promise; - expect(values).toEqual([1]); - expect(done).not.toHaveBeenCalled(); - - writer.write(2); - await deferred.promise; - expect(values).toEqual([1, 2]); - expect(done).not.toHaveBeenCalled(); - - writer.close(); - await deferred.promise; - expect(done).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/requireDefault/iteratorAt.test.ts b/packages/integration-test/requireDefault/iteratorAt.test.ts deleted file mode 100644 index 9a21f82..0000000 --- a/packages/integration-test/requireDefault/iteratorAt.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorAt } = require('iter-fest'); - -test('iteratorAt should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); diff --git a/packages/integration-test/requireDefault/iteratorConcat.test.ts b/packages/integration-test/requireDefault/iteratorConcat.test.ts deleted file mode 100644 index ac8a054..0000000 --- a/packages/integration-test/requireDefault/iteratorConcat.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorConcat } = require('iter-fest'); - -test('iterableConcat should work', () => - expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); diff --git a/packages/integration-test/requireDefault/iteratorDrop.test.ts b/packages/integration-test/requireDefault/iteratorDrop.test.ts deleted file mode 100644 index bdef648..0000000 --- a/packages/integration-test/requireDefault/iteratorDrop.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorDrop } = require('iter-fest'); - -test('iteratorDrop should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorDrop(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 3 }); - expect(result.next()).toEqual({ done: false, value: 4 }); - expect(result.next()).toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/requireDefault/iteratorEntries.test.ts b/packages/integration-test/requireDefault/iteratorEntries.test.ts deleted file mode 100644 index 8189ddc..0000000 --- a/packages/integration-test/requireDefault/iteratorEntries.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorEntries } = require('iter-fest'); - -test('iteratorEntries should work', () => - expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ - [0, 'A'], - [1, 'B'], - [2, 'C'] - ])); diff --git a/packages/integration-test/requireDefault/iteratorEvery.test.ts b/packages/integration-test/requireDefault/iteratorEvery.test.ts deleted file mode 100644 index 05b8de6..0000000 --- a/packages/integration-test/requireDefault/iteratorEvery.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorEvery, iteratorTake } = require('iter-fest'); - -test('iteratorEvery should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 10); - - expect(iteratorEvery(iter, v => v >= 0)).toBe(true); - expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. - - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/requireDefault/iteratorFilter.test.ts b/packages/integration-test/requireDefault/iteratorFilter.test.ts deleted file mode 100644 index e33f0f5..0000000 --- a/packages/integration-test/requireDefault/iteratorFilter.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFilter } = require('iter-fest'); - -test('iteratorFilter should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireDefault/iteratorFind.test.ts b/packages/integration-test/requireDefault/iteratorFind.test.ts deleted file mode 100644 index 7e2f277..0000000 --- a/packages/integration-test/requireDefault/iteratorFind.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFind } = require('iter-fest'); - -test('iteratorFind should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - expect(iteratorFind(naturals(), v => v > 1)).toBe(2); -}); diff --git a/packages/integration-test/requireDefault/iteratorFindIndex.test.ts b/packages/integration-test/requireDefault/iteratorFindIndex.test.ts deleted file mode 100644 index 95d2e81..0000000 --- a/packages/integration-test/requireDefault/iteratorFindIndex.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFindIndex } = require('iter-fest'); - -test('iteratorFindIndex should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); diff --git a/packages/integration-test/requireDefault/iteratorFindLast.test.ts b/packages/integration-test/requireDefault/iteratorFindLast.test.ts deleted file mode 100644 index 99b460a..0000000 --- a/packages/integration-test/requireDefault/iteratorFindLast.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFindLast } = require('iter-fest'); - -test('iteratorFindLast should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); diff --git a/packages/integration-test/requireDefault/iteratorFindLastIndex.test.ts b/packages/integration-test/requireDefault/iteratorFindLastIndex.test.ts deleted file mode 100644 index 0a0e9a2..0000000 --- a/packages/integration-test/requireDefault/iteratorFindLastIndex.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFindLastIndex } = require('iter-fest'); - -test('iteratorFindLastIndex should work', () => - expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); diff --git a/packages/integration-test/requireDefault/iteratorFlatMap.test.ts b/packages/integration-test/requireDefault/iteratorFlatMap.test.ts deleted file mode 100644 index cc70229..0000000 --- a/packages/integration-test/requireDefault/iteratorFlatMap.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFlatMap } = require('iter-fest'); - -test('iteratorFlatMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = ["It's Sunny in", '', 'California'].values(); - - const result = iteratorFlatMap(sunny, value => value.split(' ').values()); - - expect(result.next()).toEqual({ done: false, value: "It's" }); - expect(result.next()).toEqual({ done: false, value: 'Sunny' }); - expect(result.next()).toEqual({ done: false, value: 'in' }); - expect(result.next()).toEqual({ done: false, value: '' }); - expect(result.next()).toEqual({ done: false, value: 'California' }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireDefault/iteratorForEach.test.ts b/packages/integration-test/requireDefault/iteratorForEach.test.ts deleted file mode 100644 index d1d4472..0000000 --- a/packages/integration-test/requireDefault/iteratorForEach.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorForEach } = require('iter-fest'); - -test('iteratorForEach should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = (value: number) => log.push(value); - const iter = [1, 2, 3].values(); - - iteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/requireDefault/iteratorFrom.test.ts b/packages/integration-test/requireDefault/iteratorFrom.test.ts deleted file mode 100644 index 2a862fe..0000000 --- a/packages/integration-test/requireDefault/iteratorFrom.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFrom } = require('iter-fest'); - -test('iteratorFrom should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return { done: false, value: 1 }; - } - } - - const iter = new Iter(); - const wrapper = iteratorFrom(iter); - - expect(wrapper.next()).toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/requireDefault/iteratorIncludes.test.ts b/packages/integration-test/requireDefault/iteratorIncludes.test.ts deleted file mode 100644 index ddf50b9..0000000 --- a/packages/integration-test/requireDefault/iteratorIncludes.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorIncludes } = require('iter-fest'); - -test('iteratorIncludes should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); diff --git a/packages/integration-test/requireDefault/iteratorIndexOf.test.ts b/packages/integration-test/requireDefault/iteratorIndexOf.test.ts deleted file mode 100644 index 87c2743..0000000 --- a/packages/integration-test/requireDefault/iteratorIndexOf.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorIndexOf } = require('iter-fest'); - -test('iteratorIndexOf should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); diff --git a/packages/integration-test/requireDefault/iteratorKeys.test.ts b/packages/integration-test/requireDefault/iteratorKeys.test.ts deleted file mode 100644 index ddbae70..0000000 --- a/packages/integration-test/requireDefault/iteratorKeys.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorKeys } = require('iter-fest'); - -test('iteratorKeys should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); diff --git a/packages/integration-test/requireDefault/iteratorMap.test.ts b/packages/integration-test/requireDefault/iteratorMap.test.ts deleted file mode 100644 index 659a61a..0000000 --- a/packages/integration-test/requireDefault/iteratorMap.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorMap } = require('iter-fest'); - -test('iteratorMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorMap(naturals(), value => { - return value * value; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireDefault/iteratorReduce.test.ts b/packages/integration-test/requireDefault/iteratorReduce.test.ts deleted file mode 100644 index f43a880..0000000 --- a/packages/integration-test/requireDefault/iteratorReduce.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorReduce, iteratorTake } = require('iter-fest'); - -test('iteratorReduce should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorReduce( - iteratorTake(naturals(), 5), - (sum, value) => { - return sum + value; - }, - 3 - ); - - expect(result).toBe(13); -}); diff --git a/packages/integration-test/requireDefault/iteratorSlice.test.ts b/packages/integration-test/requireDefault/iteratorSlice.test.ts deleted file mode 100644 index f582a11..0000000 --- a/packages/integration-test/requireDefault/iteratorSlice.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorSlice } = require('iter-fest'); - -test('iteratorSlice should work', () => - expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); diff --git a/packages/integration-test/requireDefault/iteratorSome.test.ts b/packages/integration-test/requireDefault/iteratorSome.test.ts deleted file mode 100644 index 9fb1c18..0000000 --- a/packages/integration-test/requireDefault/iteratorSome.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorSome } = require('iter-fest'); -const { iteratorTake } = require('iter-fest'); - -test('iteratorSome should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 4); - - expect(iteratorSome(iter, v => v > 1)).toEqual(true); - expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. - - expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); - expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/requireDefault/iteratorTake.test.ts b/packages/integration-test/requireDefault/iteratorTake.test.ts deleted file mode 100644 index 01a780b..0000000 --- a/packages/integration-test/requireDefault/iteratorTake.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorTake } = require('iter-fest'); - -test('iteratorTake should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorTake(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireDefault/iteratorToArray.test.ts b/packages/integration-test/requireDefault/iteratorToArray.test.ts deleted file mode 100644 index 0223fe7..0000000 --- a/packages/integration-test/requireDefault/iteratorToArray.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorTake, iteratorToArray } = require('iter-fest'); - -test('iteratorToArray should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorToArray(iteratorTake(naturals(), 5)); - - expect(result).toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/requireDefault/iteratorToAsync.test.ts b/packages/integration-test/requireDefault/iteratorToAsync.test.ts deleted file mode 100644 index 4c4a4a9..0000000 --- a/packages/integration-test/requireDefault/iteratorToAsync.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToAsync } = require('iter-fest'); - -test('iteratorToAsync should work', async () => { - const iterator = [1, 2, 3].values(); - const asyncIterator = iteratorToAsync(iterator); - - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireDefault/iteratorToIterable.test.ts b/packages/integration-test/requireDefault/iteratorToIterable.test.ts deleted file mode 100644 index 70c034d..0000000 --- a/packages/integration-test/requireDefault/iteratorToIterable.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToIterable, Observable } = require('iter-fest'); - -test('iteratorToIterable should work', () => - expect( - Array.from( - iteratorToIterable( - ((): Iterator => { - let value = 0; - - return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; - })() - ) - ) - ).toEqual([1, 2, 3])); - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/requireDefault/iteratorToSpliced.test.ts b/packages/integration-test/requireDefault/iteratorToSpliced.test.ts deleted file mode 100644 index 9f537cf..0000000 --- a/packages/integration-test/requireDefault/iteratorToSpliced.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToSpliced } = require('iter-fest'); - -test('iteratorToSpliced should work', () => - expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); diff --git a/packages/integration-test/requireDefault/iteratorToString.test.ts b/packages/integration-test/requireDefault/iteratorToString.test.ts deleted file mode 100644 index e61336e..0000000 --- a/packages/integration-test/requireDefault/iteratorToString.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToString } = require('iter-fest'); - -test('iteratorToString should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); diff --git a/packages/integration-test/requireDefault/observable.test.ts b/packages/integration-test/requireDefault/observable.test.ts deleted file mode 100644 index 2565ba9..0000000 --- a/packages/integration-test/requireDefault/observable.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable } = require('iter-fest'); - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/requireDefault/observableFromAsync.test.ts b/packages/integration-test/requireDefault/observableFromAsync.test.ts deleted file mode 100644 index a8737e2..0000000 --- a/packages/integration-test/requireDefault/observableFromAsync.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { observableFromAsync } = require('iter-fest'); - -test('observableFromAsync should work', async () => { - const observable = observableFromAsync( - (async function* () { - yield 1; - yield 2; - yield 3; - })() - ); - - const next = jest.fn(); - - await new Promise(resolve => observable.subscribe({ complete: resolve, next })); - - expect(next).toHaveBeenCalledTimes(3); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(next).toHaveBeenNthCalledWith(2, 2); - expect(next).toHaveBeenNthCalledWith(3, 3); -}); diff --git a/packages/integration-test/requireDefault/observableSubscribeAsReadable.test.ts b/packages/integration-test/requireDefault/observableSubscribeAsReadable.test.ts deleted file mode 100644 index cc736d9..0000000 --- a/packages/integration-test/requireDefault/observableSubscribeAsReadable.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable, observableSubscribeAsReadable } = require('iter-fest'); - -test('observableSubscribeAsReadable should work', async () => { - const stream = new TextDecoderStream(); - const observable = Observable.from([65, 66, 67]); - const readable = observableSubscribeAsReadable(observable); - const numberToInt8Array = new TransformStream({ - transform(chunk, controller) { - controller.enqueue(Int8Array.from([chunk])); - } - }); - - readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); - - const reader = stream.readable.getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); - await expect(reader.read()).resolves.toEqual({ done: true }); -}); diff --git a/packages/integration-test/requireDefault/observableValues.test.ts b/packages/integration-test/requireDefault/observableValues.test.ts deleted file mode 100644 index 3608401..0000000 --- a/packages/integration-test/requireDefault/observableValues.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable, observableValues } = require('iter-fest'); - -test('observableValues should work', async () => { - const observable = Observable.from([1, 2, 3]); - const values: number[] = []; - - for await (const value of observableValues(observable)) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/requireDefault/readableStreamFrom.test.ts b/packages/integration-test/requireDefault/readableStreamFrom.test.ts deleted file mode 100644 index 3d48954..0000000 --- a/packages/integration-test/requireDefault/readableStreamFrom.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { readableStreamFrom } = require('iter-fest'); - -test('readableStreamFrom should work', async () => { - const iterable = [1, 2, 3].values(); - - const reader = readableStreamFrom(iterable).getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); - await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireDefault/readableStreamValues.test.ts b/packages/integration-test/requireDefault/readableStreamValues.test.ts deleted file mode 100644 index 06c398d..0000000 --- a/packages/integration-test/requireDefault/readableStreamValues.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { readableStreamValues } = require('iter-fest'); - -test('readableStreamValues should work', async () => { - const readableStream = new ReadableStream({ - start(controller) { - controller.enqueue(1); - controller.enqueue(2); - controller.close(); - } - }); - - const values = []; - - for await (const value of readableStreamValues(readableStream)) { - values.push(value); - } - - expect(values).toEqual([1, 2]); -}); diff --git a/packages/integration-test/requireDefault/symbolObservable.test.ts b/packages/integration-test/requireDefault/symbolObservable.test.ts deleted file mode 100644 index 5f9e984..0000000 --- a/packages/integration-test/requireDefault/symbolObservable.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable, SymbolObservable } = require('iter-fest'); - -test('SymbolObservable should work', () => { - const observable = new Observable(() => {}); - - expect(observable[SymbolObservable]()).toBe(observable); -}); diff --git a/packages/integration-test/requireNamed/asyncGeneratorWithLastValue.test.ts b/packages/integration-test/requireNamed/asyncGeneratorWithLastValue.test.ts deleted file mode 100644 index 583dffb..0000000 --- a/packages/integration-test/requireNamed/asyncGeneratorWithLastValue.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncGeneratorWithLastValue } = require('iter-fest/asyncGeneratorWithLastValue'); - -test('asyncGeneratorWithLastValue should work', async () => { - const asyncGenerator = asyncGeneratorWithLastValue( - (async function* () { - yield 1; - - return 'end' as const; - })() - ); - - for await (const value of asyncGenerator) { - expect(value).toBe(1); - } - - expect(asyncGenerator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorDrop.test.ts b/packages/integration-test/requireNamed/asyncIteratorDrop.test.ts deleted file mode 100644 index cf81311..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorDrop.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorDrop } = require('iter-fest/asyncIteratorDrop'); - -test('asyncIteratorDrop should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorDrop(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorEvery.test.ts b/packages/integration-test/requireNamed/asyncIteratorEvery.test.ts deleted file mode 100644 index 2bf12f1..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorEvery.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorEvery } = require('iter-fest/asyncIteratorEvery'); -const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); - -test('asyncIteratorEvery should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 10); - - await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); - await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. - - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( - false - ); // first value is 0 - await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorFilter.test.ts b/packages/integration-test/requireNamed/asyncIteratorFilter.test.ts deleted file mode 100644 index 91ec755..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorFilter.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFilter } = require('iter-fest/asyncIteratorFilter'); - -test('asyncIteratorFilter should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorFind.test.ts b/packages/integration-test/requireNamed/asyncIteratorFind.test.ts deleted file mode 100644 index 6d43e48..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorFind.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFind } = require('iter-fest/asyncIteratorFind'); - -test('asyncIteratorFind should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorFlatMap.test.ts b/packages/integration-test/requireNamed/asyncIteratorFlatMap.test.ts deleted file mode 100644 index 1c1cf89..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorFlatMap.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFlatMap } = require('iter-fest/asyncIteratorFlatMap'); -const { iteratorToAsync } = require('iter-fest/iteratorToAsync'); - -test('should follow TC39 proposal sample (sync)', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); - - const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); - - await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); - await expect(result.next()).resolves.toEqual({ done: false, value: '' }); - await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorForEach.test.ts b/packages/integration-test/requireNamed/asyncIteratorForEach.test.ts deleted file mode 100644 index 7b9757e..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorForEach.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorForEach } = require('iter-fest/asyncIteratorForEach'); -const { iteratorToAsync } = require('iter-fest/iteratorToAsync'); - -test('asyncIteratorForEach should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = async (value: number) => void log.push(value); - const iter = iteratorToAsync([1, 2, 3].values()); - - await asyncIteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorFrom.test.ts b/packages/integration-test/requireNamed/asyncIteratorFrom.test.ts deleted file mode 100644 index 079a735..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorFrom.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorFrom } = require('iter-fest/asyncIteratorFrom'); - -test('asyncIteratorFrom should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return Promise.resolve({ done: false, value: 1 }); - } - } - - const iter = new Iter(); - const wrapper = asyncIteratorFrom(iter); - - await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorMap.test.ts b/packages/integration-test/requireNamed/asyncIteratorMap.test.ts deleted file mode 100644 index 56a5699..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorMap.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorMap } = require('iter-fest/asyncIteratorMap'); - -test('asyncIteratorMap should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorMap(naturals(), value => { - return value * value; - }); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorReduce.test.ts b/packages/integration-test/requireNamed/asyncIteratorReduce.test.ts deleted file mode 100644 index d4ab9cc..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorReduce.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorReduce } = require('iter-fest/asyncIteratorReduce'); -const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); - -test('asyncIteratorReduce should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorReduce( - asyncIteratorTake(naturals(), 5), - async (sum, value) => { - return sum + value; - }, - 3 - ); - - await expect(result).resolves.toBe(13); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorSome.test.ts b/packages/integration-test/requireNamed/asyncIteratorSome.test.ts deleted file mode 100644 index 8c1863b..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorSome.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorSome } = require('iter-fest/asyncIteratorSome'); -const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); - -test('asyncIteratorSome should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const iter = asyncIteratorTake(naturals(), 4); - - await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. - - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual(true); - await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( - true - ); // acting on a new iterator -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorTake.test.ts b/packages/integration-test/requireNamed/asyncIteratorTake.test.ts deleted file mode 100644 index f97cfc0..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorTake.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); - -test('asyncIteratorTake should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorTake(naturals(), 3); - - await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorToArray.test.ts b/packages/integration-test/requireNamed/asyncIteratorToArray.test.ts deleted file mode 100644 index cbcabe1..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorToArray.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); -const { asyncIteratorToArray } = require('iter-fest/asyncIteratorToArray'); - -test('asyncIteratorToArray should work', async () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - async function* naturals() { - await 0; - let i = 0; - - while (true) { - await 0; - yield i; - - i += 1; - } - } - - const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); - - await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/requireNamed/asyncIteratorToIterable.test.ts b/packages/integration-test/requireNamed/asyncIteratorToIterable.test.ts deleted file mode 100644 index ad6b917..0000000 --- a/packages/integration-test/requireNamed/asyncIteratorToIterable.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { asyncIteratorToAsyncIterable } = require('iter-fest/asyncIteratorToAsyncIterable'); - -test('asyncIteratorToIterable should work', async () => { - const iterable = asyncIteratorToAsyncIterable( - ((): AsyncIterator => { - let value = 0; - - return { - next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) - }; - })() - ); - - const values: number[] = []; - - for await (const value of iterable) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/requireNamed/generatorWithLastValue.test.ts b/packages/integration-test/requireNamed/generatorWithLastValue.test.ts deleted file mode 100644 index 369e3c9..0000000 --- a/packages/integration-test/requireNamed/generatorWithLastValue.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { generatorWithLastValue } = require('iter-fest/generatorWithLastValue'); - -test('generatorWithLastValue should work', () => { - const generator = generatorWithLastValue( - (function* () { - yield 1; - - return 'end' as const; - })() - ); - - for (const value of generator) { - expect(value).toBe(1); - } - - expect(generator.lastValue()).toEqual('end'); -}); diff --git a/packages/integration-test/requireNamed/iterableWritableStream.test.ts b/packages/integration-test/requireNamed/iterableWritableStream.test.ts deleted file mode 100644 index f1a2aa7..0000000 --- a/packages/integration-test/requireNamed/iterableWritableStream.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const withResolvers = require('core-js-pure/full/promise/with-resolvers'); -const { IterableWritableStream } = require('iter-fest/iterableWritableStream'); - -test('IterableWritableStream should work', async () => { - let deferred = withResolvers(); - const done = jest.fn(); - const iterable = new IterableWritableStream(); - const writer = iterable.getWriter(); - const values = []; - - (async function () { - for await (const value of iterable) { - values.push(value); - - deferred.resolve(); - deferred = withResolvers(); - } - - done(); - deferred.resolve(); - })(); - - expect(values).toEqual([]); - expect(done).not.toHaveBeenCalled(); - - writer.write(1); - await deferred.promise; - expect(values).toEqual([1]); - expect(done).not.toHaveBeenCalled(); - - writer.write(2); - await deferred.promise; - expect(values).toEqual([1, 2]); - expect(done).not.toHaveBeenCalled(); - - writer.close(); - await deferred.promise; - expect(done).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/requireNamed/iteratorAt.test.ts b/packages/integration-test/requireNamed/iteratorAt.test.ts deleted file mode 100644 index 2c841b3..0000000 --- a/packages/integration-test/requireNamed/iteratorAt.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorAt } = require('iter-fest/iteratorAt'); - -test('iteratorAt should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); diff --git a/packages/integration-test/requireNamed/iteratorConcat.test.ts b/packages/integration-test/requireNamed/iteratorConcat.test.ts deleted file mode 100644 index f0e7ce9..0000000 --- a/packages/integration-test/requireNamed/iteratorConcat.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorConcat } = require('iter-fest/iteratorConcat'); - -test('iterableConcat should work', () => - expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); diff --git a/packages/integration-test/requireNamed/iteratorDrop.test.ts b/packages/integration-test/requireNamed/iteratorDrop.test.ts deleted file mode 100644 index f86a103..0000000 --- a/packages/integration-test/requireNamed/iteratorDrop.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorDrop } = require('iter-fest/iteratorDrop'); - -test('iteratorDrop should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorDrop(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 3 }); - expect(result.next()).toEqual({ done: false, value: 4 }); - expect(result.next()).toEqual({ done: false, value: 5 }); -}); diff --git a/packages/integration-test/requireNamed/iteratorEntries.test.ts b/packages/integration-test/requireNamed/iteratorEntries.test.ts deleted file mode 100644 index 686dd7b..0000000 --- a/packages/integration-test/requireNamed/iteratorEntries.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorEntries } = require('iter-fest/iteratorEntries'); - -test('iteratorEntries should work', () => - expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ - [0, 'A'], - [1, 'B'], - [2, 'C'] - ])); diff --git a/packages/integration-test/requireNamed/iteratorEvery.test.ts b/packages/integration-test/requireNamed/iteratorEvery.test.ts deleted file mode 100644 index ccc5c54..0000000 --- a/packages/integration-test/requireNamed/iteratorEvery.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorEvery } = require('iter-fest/iteratorEvery'); -const { iteratorTake } = require('iter-fest/iteratorTake'); - -test('iteratorEvery should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 10); - - expect(iteratorEvery(iter, v => v >= 0)).toBe(true); - expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. - - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 - expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/requireNamed/iteratorFilter.test.ts b/packages/integration-test/requireNamed/iteratorFilter.test.ts deleted file mode 100644 index cc0df59..0000000 --- a/packages/integration-test/requireNamed/iteratorFilter.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFilter } = require('iter-fest/iteratorFilter'); - -test('iteratorFilter should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorFilter(naturals(), value => { - return value % 2 == 0; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireNamed/iteratorFind.test.ts b/packages/integration-test/requireNamed/iteratorFind.test.ts deleted file mode 100644 index 80fd370..0000000 --- a/packages/integration-test/requireNamed/iteratorFind.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFind } = require('iter-fest/iteratorFind'); - -test('iteratorFind should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - expect(iteratorFind(naturals(), v => v > 1)).toBe(2); -}); diff --git a/packages/integration-test/requireNamed/iteratorFindIndex.test.ts b/packages/integration-test/requireNamed/iteratorFindIndex.test.ts deleted file mode 100644 index 81b7846..0000000 --- a/packages/integration-test/requireNamed/iteratorFindIndex.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFindIndex } = require('iter-fest/iteratorFindIndex'); - -test('iteratorFindIndex should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); diff --git a/packages/integration-test/requireNamed/iteratorFindLast.test.ts b/packages/integration-test/requireNamed/iteratorFindLast.test.ts deleted file mode 100644 index c349a71..0000000 --- a/packages/integration-test/requireNamed/iteratorFindLast.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFindLast } = require('iter-fest/iteratorFindLast'); - -test('iteratorFindLast should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); diff --git a/packages/integration-test/requireNamed/iteratorFindLastIndex.test.ts b/packages/integration-test/requireNamed/iteratorFindLastIndex.test.ts deleted file mode 100644 index 0590989..0000000 --- a/packages/integration-test/requireNamed/iteratorFindLastIndex.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFindLastIndex } = require('iter-fest/iteratorFindLastIndex'); - -test('iteratorFindLastIndex should work', () => - expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); diff --git a/packages/integration-test/requireNamed/iteratorFlatMap.test.ts b/packages/integration-test/requireNamed/iteratorFlatMap.test.ts deleted file mode 100644 index 4173564..0000000 --- a/packages/integration-test/requireNamed/iteratorFlatMap.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFlatMap } = require('iter-fest/iteratorFlatMap'); - -test('iteratorFlatMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const sunny = ["It's Sunny in", '', 'California'].values(); - - const result = iteratorFlatMap(sunny, value => value.split(' ').values()); - - expect(result.next()).toEqual({ done: false, value: "It's" }); - expect(result.next()).toEqual({ done: false, value: 'Sunny' }); - expect(result.next()).toEqual({ done: false, value: 'in' }); - expect(result.next()).toEqual({ done: false, value: '' }); - expect(result.next()).toEqual({ done: false, value: 'California' }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireNamed/iteratorForEach.test.ts b/packages/integration-test/requireNamed/iteratorForEach.test.ts deleted file mode 100644 index abadccd..0000000 --- a/packages/integration-test/requireNamed/iteratorForEach.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorForEach } = require('iter-fest/iteratorForEach'); - -test('iteratorForEach should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - const log: number[] = []; - const fn = (value: number) => log.push(value); - const iter = [1, 2, 3].values(); - - iteratorForEach(iter, fn); - - expect(log.join(', ')).toBe('1, 2, 3'); -}); diff --git a/packages/integration-test/requireNamed/iteratorFrom.test.ts b/packages/integration-test/requireNamed/iteratorFrom.test.ts deleted file mode 100644 index 94d71fe..0000000 --- a/packages/integration-test/requireNamed/iteratorFrom.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorFrom } = require('iter-fest/iteratorFrom'); - -test('iteratorFrom should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - class Iter { - next() { - return { done: false, value: 1 }; - } - } - - const iter = new Iter(); - const wrapper = iteratorFrom(iter); - - expect(wrapper.next()).toEqual({ done: false, value: 1 }); -}); diff --git a/packages/integration-test/requireNamed/iteratorIncludes.test.ts b/packages/integration-test/requireNamed/iteratorIncludes.test.ts deleted file mode 100644 index e0f1807..0000000 --- a/packages/integration-test/requireNamed/iteratorIncludes.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorIncludes } = require('iter-fest/iteratorIncludes'); - -test('iteratorIncludes should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); diff --git a/packages/integration-test/requireNamed/iteratorIndexOf.test.ts b/packages/integration-test/requireNamed/iteratorIndexOf.test.ts deleted file mode 100644 index 28e6b24..0000000 --- a/packages/integration-test/requireNamed/iteratorIndexOf.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorIndexOf } = require('iter-fest/iteratorIndexOf'); - -test('iteratorIndexOf should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); diff --git a/packages/integration-test/requireNamed/iteratorKeys.test.ts b/packages/integration-test/requireNamed/iteratorKeys.test.ts deleted file mode 100644 index b974a6b..0000000 --- a/packages/integration-test/requireNamed/iteratorKeys.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorKeys } = require('iter-fest/iteratorKeys'); - -test('iteratorKeys should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); diff --git a/packages/integration-test/requireNamed/iteratorMap.test.ts b/packages/integration-test/requireNamed/iteratorMap.test.ts deleted file mode 100644 index efc4795..0000000 --- a/packages/integration-test/requireNamed/iteratorMap.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorMap } = require('iter-fest/iteratorMap'); - -test('iteratorMap should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorMap(naturals(), value => { - return value * value; - }); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 4 }); -}); diff --git a/packages/integration-test/requireNamed/iteratorReduce.test.ts b/packages/integration-test/requireNamed/iteratorReduce.test.ts deleted file mode 100644 index 738d0bb..0000000 --- a/packages/integration-test/requireNamed/iteratorReduce.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorReduce } = require('iter-fest/iteratorReduce'); -const { iteratorTake } = require('iter-fest/iteratorTake'); - -test('iteratorReduce should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorReduce( - iteratorTake(naturals(), 5), - (sum, value) => { - return sum + value; - }, - 3 - ); - - expect(result).toBe(13); -}); diff --git a/packages/integration-test/requireNamed/iteratorSlice.test.ts b/packages/integration-test/requireNamed/iteratorSlice.test.ts deleted file mode 100644 index e76cc41..0000000 --- a/packages/integration-test/requireNamed/iteratorSlice.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorSlice } = require('iter-fest/iteratorSlice'); - -test('iteratorSlice should work', () => - expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); diff --git a/packages/integration-test/requireNamed/iteratorSome.test.ts b/packages/integration-test/requireNamed/iteratorSome.test.ts deleted file mode 100644 index 923366d..0000000 --- a/packages/integration-test/requireNamed/iteratorSome.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorSome } = require('iter-fest/iteratorSome'); -const { iteratorTake } = require('iter-fest/iteratorTake'); - -test('iteratorSome should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const iter = iteratorTake(naturals(), 4); - - expect(iteratorSome(iter, v => v > 1)).toEqual(true); - expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. - - expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); - expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator -}); diff --git a/packages/integration-test/requireNamed/iteratorTake.test.ts b/packages/integration-test/requireNamed/iteratorTake.test.ts deleted file mode 100644 index 01ab311..0000000 --- a/packages/integration-test/requireNamed/iteratorTake.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorTake } = require('iter-fest/iteratorTake'); - -test('iteratorTake should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorTake(naturals(), 3); - - expect(result.next()).toEqual({ done: false, value: 0 }); - expect(result.next()).toEqual({ done: false, value: 1 }); - expect(result.next()).toEqual({ done: false, value: 2 }); - expect(result.next()).toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireNamed/iteratorToArray.test.ts b/packages/integration-test/requireNamed/iteratorToArray.test.ts deleted file mode 100644 index 0b48122..0000000 --- a/packages/integration-test/requireNamed/iteratorToArray.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorTake } = require('iter-fest/iteratorTake'); -const { iteratorToArray } = require('iter-fest/iteratorToArray'); - -test('iteratorToArray should work', () => { - // Copied from https://github.com/tc39/proposal-iterator-helpers. - function* naturals() { - let i = 0; - - while (true) { - yield i; - - i += 1; - } - } - - const result = iteratorToArray(iteratorTake(naturals(), 5)); - - expect(result).toEqual([0, 1, 2, 3, 4]); -}); diff --git a/packages/integration-test/requireNamed/iteratorToAsync.test.ts b/packages/integration-test/requireNamed/iteratorToAsync.test.ts deleted file mode 100644 index 020ec75..0000000 --- a/packages/integration-test/requireNamed/iteratorToAsync.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToAsync } = require('iter-fest/iteratorToAsync'); - -test('iteratorToAsync should work', async () => { - const iterator = [1, 2, 3].values(); - const asyncIterator = iteratorToAsync(iterator); - - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); - await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireNamed/iteratorToIterable.test.ts b/packages/integration-test/requireNamed/iteratorToIterable.test.ts deleted file mode 100644 index 2a6005e..0000000 --- a/packages/integration-test/requireNamed/iteratorToIterable.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToIterable } = require('iter-fest/iteratorToIterable'); -const { Observable } = require('iter-fest/observable'); - -test('iteratorToIterable should work', () => - expect( - Array.from( - iteratorToIterable( - ((): Iterator => { - let value = 0; - - return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; - })() - ) - ) - ).toEqual([1, 2, 3])); - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/requireNamed/iteratorToSpliced.test.ts b/packages/integration-test/requireNamed/iteratorToSpliced.test.ts deleted file mode 100644 index e9fe94d..0000000 --- a/packages/integration-test/requireNamed/iteratorToSpliced.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToSpliced } = require('iter-fest/iteratorToSpliced'); - -test('iteratorToSpliced should work', () => - expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); diff --git a/packages/integration-test/requireNamed/iteratorToString.test.ts b/packages/integration-test/requireNamed/iteratorToString.test.ts deleted file mode 100644 index 0945a1a..0000000 --- a/packages/integration-test/requireNamed/iteratorToString.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { iteratorToString } = require('iter-fest/iteratorToString'); - -test('iteratorToString should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); diff --git a/packages/integration-test/requireNamed/observable.test.ts b/packages/integration-test/requireNamed/observable.test.ts deleted file mode 100644 index 3f77c4d..0000000 --- a/packages/integration-test/requireNamed/observable.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable } = require('iter-fest/observable'); - -test('Observable should work', () => { - const next = jest.fn(); - const complete = jest.fn(); - - const observable = new Observable(observer => { - observer.next(1); - observer.complete(); - }); - - observable.subscribe({ complete, next }); - - expect(next).toHaveBeenCalledTimes(1); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(complete).toHaveBeenCalledTimes(1); -}); diff --git a/packages/integration-test/requireNamed/observableFromAsync.test.ts b/packages/integration-test/requireNamed/observableFromAsync.test.ts deleted file mode 100644 index dcd6b6c..0000000 --- a/packages/integration-test/requireNamed/observableFromAsync.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { observableFromAsync } = require('iter-fest/observableFromAsync'); - -test('observableFromAsync should work', async () => { - const observable = observableFromAsync( - (async function* () { - yield 1; - yield 2; - yield 3; - })() - ); - - const next = jest.fn(); - - await new Promise(resolve => observable.subscribe({ complete: resolve, next })); - - expect(next).toHaveBeenCalledTimes(3); - expect(next).toHaveBeenNthCalledWith(1, 1); - expect(next).toHaveBeenNthCalledWith(2, 2); - expect(next).toHaveBeenNthCalledWith(3, 3); -}); diff --git a/packages/integration-test/requireNamed/observableSubscribeAsReadable.test.ts b/packages/integration-test/requireNamed/observableSubscribeAsReadable.test.ts deleted file mode 100644 index 1674ae8..0000000 --- a/packages/integration-test/requireNamed/observableSubscribeAsReadable.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable } = require('iter-fest/observable'); -const { observableSubscribeAsReadable } = require('iter-fest/observableSubscribeAsReadable'); - -test('observableSubscribeAsReadable should work', async () => { - const stream = new TextDecoderStream(); - const observable = Observable.from([65, 66, 67]); - const readable = observableSubscribeAsReadable(observable); - const numberToInt8Array = new TransformStream({ - transform(chunk, controller) { - controller.enqueue(Int8Array.from([chunk])); - } - }); - - readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); - - const reader = stream.readable.getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); - await expect(reader.read()).resolves.toEqual({ done: true }); -}); diff --git a/packages/integration-test/requireNamed/observableValues.test.ts b/packages/integration-test/requireNamed/observableValues.test.ts deleted file mode 100644 index a1c5e02..0000000 --- a/packages/integration-test/requireNamed/observableValues.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable } = require('iter-fest/observable'); -const { observableValues } = require('iter-fest/observableValues'); - -test('observableValues should work', async () => { - const observable = Observable.from([1, 2, 3]); - const values: number[] = []; - - for await (const value of observableValues(observable)) { - values.push(value); - } - - expect(values).toEqual([1, 2, 3]); -}); diff --git a/packages/integration-test/requireNamed/readableStreamFrom.test.ts b/packages/integration-test/requireNamed/readableStreamFrom.test.ts deleted file mode 100644 index e634e41..0000000 --- a/packages/integration-test/requireNamed/readableStreamFrom.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { readableStreamFrom } = require('iter-fest/readableStreamFrom'); - -test('readableStreamFrom should work', async () => { - const iterable = [1, 2, 3].values(); - - const reader = readableStreamFrom(iterable).getReader(); - - await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); - await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); - await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); -}); diff --git a/packages/integration-test/requireNamed/readableStreamValues.ts b/packages/integration-test/requireNamed/readableStreamValues.ts deleted file mode 100644 index 44ac821..0000000 --- a/packages/integration-test/requireNamed/readableStreamValues.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { readableStreamValues } = require('iter-fest/readableStreamValues'); - -test('readableStreamValues should work', async () => { - const readableStream = new ReadableStream({ - start(controller) { - controller.enqueue(1); - controller.enqueue(2); - controller.close(); - } - }); - - const values = []; - - for await (const value of readableStreamValues(readableStream)) { - values.push(value); - } - - expect(values).toEqual([1, 2]); -}); diff --git a/packages/integration-test/requireNamed/symbolObservable.test.ts b/packages/integration-test/requireNamed/symbolObservable.test.ts deleted file mode 100644 index eba3b68..0000000 --- a/packages/integration-test/requireNamed/symbolObservable.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { Observable } = require('iter-fest/observable'); -const { SymbolObservable } = require('iter-fest/symbolObservable'); - -test('SymbolObservable should work', () => { - const observable = new Observable(() => {}); - - expect(observable[SymbolObservable]()).toBe(observable); -}); diff --git a/packages/integration-test/test/importDefault/asyncGeneratorWithLastValue.mjs b/packages/integration-test/test/importDefault/asyncGeneratorWithLastValue.mjs new file mode 100644 index 0000000..7bd0429 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncGeneratorWithLastValue.mjs @@ -0,0 +1,20 @@ +import { expect } from 'expect'; +import { asyncGeneratorWithLastValue } from 'iter-fest'; + +describe('asyncGeneratorWithLastValue', () => { + it('should work', async () => { + const asyncGenerator = asyncGeneratorWithLastValue( + (async function* () { + yield 1; + + return 'end'; + })() + ); + + for await (const value of asyncGenerator) { + expect(value).toBe(1); + } + + expect(asyncGenerator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorDrop.mjs b/packages/integration-test/test/importDefault/asyncIteratorDrop.mjs new file mode 100644 index 0000000..beeafe7 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorDrop.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { asyncIteratorDrop } from 'iter-fest'; + +describe('asyncIteratorDrop', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorDrop(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorEvery.mjs b/packages/integration-test/test/importDefault/asyncIteratorEvery.mjs new file mode 100644 index 0000000..9b0bb42 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorEvery.mjs @@ -0,0 +1,31 @@ +import { expect } from 'expect'; +import { asyncIteratorEvery, asyncIteratorTake } from 'iter-fest'; + +describe('asyncIteratorEvery', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 10); + + await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); + await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. + + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( + false + ); // first value is 0 + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorFilter.mjs b/packages/integration-test/test/importDefault/asyncIteratorFilter.mjs new file mode 100644 index 0000000..ee0c46b --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorFilter.mjs @@ -0,0 +1,27 @@ +import { expect } from 'expect'; +import { asyncIteratorFilter } from 'iter-fest'; + +describe('asyncIteratorFilter', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorFind.mjs b/packages/integration-test/test/importDefault/asyncIteratorFind.mjs new file mode 100644 index 0000000..359db6a --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorFind.mjs @@ -0,0 +1,21 @@ +import { expect } from 'expect'; +import { asyncIteratorFind } from 'iter-fest'; + +describe('asyncIteratorFind', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorFlatMap.mjs b/packages/integration-test/test/importDefault/asyncIteratorFlatMap.mjs new file mode 100644 index 0000000..0f692d1 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorFlatMap.mjs @@ -0,0 +1,18 @@ +import { expect } from 'expect'; +import { asyncIteratorFlatMap, iteratorToAsync } from 'iter-fest'; + +describe('asyncIteratorFlatMap', () => { + it('should follow TC39 proposal sample (sync)', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); + + const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); + + await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); + await expect(result.next()).resolves.toEqual({ done: false, value: '' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorForEach.mjs b/packages/integration-test/test/importDefault/asyncIteratorForEach.mjs new file mode 100644 index 0000000..9fcee31 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorForEach.mjs @@ -0,0 +1,15 @@ +import { expect } from 'expect'; +import { asyncIteratorForEach, iteratorToAsync } from 'iter-fest'; + +describe('asyncIteratorForEach', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = async value => void log.push(value); + const iter = iteratorToAsync([1, 2, 3].values()); + + await asyncIteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorFrom.mjs b/packages/integration-test/test/importDefault/asyncIteratorFrom.mjs new file mode 100644 index 0000000..98faee6 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorFrom.mjs @@ -0,0 +1,18 @@ +import { expect } from 'expect'; +import { asyncIteratorFrom } from 'iter-fest'; + +describe('asyncIteratorFrom', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return Promise.resolve({ done: false, value: 1 }); + } + } + + const iter = new Iter(); + const wrapper = asyncIteratorFrom(iter); + + await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorMap.mjs b/packages/integration-test/test/importDefault/asyncIteratorMap.mjs new file mode 100644 index 0000000..bc6467f --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorMap.mjs @@ -0,0 +1,27 @@ +import { expect } from 'expect'; +import { asyncIteratorMap } from 'iter-fest'; + +describe('asyncIteratorMap', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorMap(naturals(), value => { + return value * value; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorReduce.mjs b/packages/integration-test/test/importDefault/asyncIteratorReduce.mjs new file mode 100644 index 0000000..2816d07 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorReduce.mjs @@ -0,0 +1,29 @@ +import { expect } from 'expect'; +import { asyncIteratorReduce, asyncIteratorTake } from 'iter-fest'; + +describe('asyncIteratorReduce', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorReduce( + asyncIteratorTake(naturals(), 5), + async (sum, value) => { + return sum + value; + }, + 3 + ); + + await expect(result).resolves.toBe(13); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorSome.mjs b/packages/integration-test/test/importDefault/asyncIteratorSome.mjs new file mode 100644 index 0000000..1acea47 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorSome.mjs @@ -0,0 +1,31 @@ +import { expect } from 'expect'; +import { asyncIteratorSome, asyncIteratorTake } from 'iter-fest'; + +describe('asyncIteratorSome', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 4); + + await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); + await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. + + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual( + true + ); + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorTake.mjs b/packages/integration-test/test/importDefault/asyncIteratorTake.mjs new file mode 100644 index 0000000..c3032ed --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorTake.mjs @@ -0,0 +1,26 @@ +import { expect } from 'expect'; +import { asyncIteratorTake } from 'iter-fest'; + +describe('asyncIteratorTake', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorTake(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorToArray.mjs b/packages/integration-test/test/importDefault/asyncIteratorToArray.mjs new file mode 100644 index 0000000..0a326d3 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorToArray.mjs @@ -0,0 +1,23 @@ +import { expect } from 'expect'; +import { asyncIteratorTake, asyncIteratorToArray } from 'iter-fest'; + +describe('asyncIteratorToArray', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); + + await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/importDefault/asyncIteratorToIterable.mjs b/packages/integration-test/test/importDefault/asyncIteratorToIterable.mjs new file mode 100644 index 0000000..aa98326 --- /dev/null +++ b/packages/integration-test/test/importDefault/asyncIteratorToIterable.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { asyncIteratorToAsyncIterable } from 'iter-fest'; + +describe('asyncIteratorToIterable', () => { + it('should work', async () => { + const iterable = asyncIteratorToAsyncIterable( + (() => { + let value = 0; + + return { + next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) + }; + })() + ); + + const values = []; + + for await (const value of iterable) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/importDefault/generatorWithLastValue.mjs b/packages/integration-test/test/importDefault/generatorWithLastValue.mjs new file mode 100644 index 0000000..23200c5 --- /dev/null +++ b/packages/integration-test/test/importDefault/generatorWithLastValue.mjs @@ -0,0 +1,20 @@ +import { expect } from 'expect'; +import { generatorWithLastValue } from 'iter-fest'; + +describe('generatorWithLastValue', () => { + it('should work', () => { + const generator = generatorWithLastValue( + (function* () { + yield 1; + + return 'end'; + })() + ); + + for (const value of generator) { + expect(value).toBe(1); + } + + expect(generator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/importDefault/iterableWritableStream.mjs b/packages/integration-test/test/importDefault/iterableWritableStream.mjs new file mode 100644 index 0000000..9a8b023 --- /dev/null +++ b/packages/integration-test/test/importDefault/iterableWritableStream.mjs @@ -0,0 +1,43 @@ +import withResolvers from 'core-js-pure/full/promise/with-resolvers.js'; +import { expect } from 'expect'; +import { IterableWritableStream } from 'iter-fest'; +import { fake } from 'sinon'; + +describe('IterableWritableStream', () => { + it('should work', async () => { + let deferred = withResolvers(); + const done = fake(() => {}); + const iterable = new IterableWritableStream(); + const writer = iterable.getWriter(); + const values = []; + + (async function () { + for await (const value of iterable) { + values.push(value); + + deferred.resolve(); + deferred = withResolvers(); + } + + done(); + deferred.resolve(); + })(); + + expect(values).toEqual([]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(1); + await deferred.promise; + expect(values).toEqual([1]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(2); + await deferred.promise; + expect(values).toEqual([1, 2]); + expect(done).toHaveProperty('callCount', 0); + + writer.close(); + await deferred.promise; + expect(done).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorAt.mjs b/packages/integration-test/test/importDefault/iteratorAt.mjs new file mode 100644 index 0000000..6c6caf0 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorAt.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorAt } from 'iter-fest'; + +describe('iteratorAt', () => { + it('should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); +}); diff --git a/packages/integration-test/test/importDefault/iteratorConcat.mjs b/packages/integration-test/test/importDefault/iteratorConcat.mjs new file mode 100644 index 0000000..b53cfa3 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorConcat.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorConcat } from 'iter-fest'; + +describe('iterableConcat', () => { + it('should work', () => expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); +}); diff --git a/packages/integration-test/test/importDefault/iteratorDrop.mjs b/packages/integration-test/test/importDefault/iteratorDrop.mjs new file mode 100644 index 0000000..d009936 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorDrop.mjs @@ -0,0 +1,23 @@ +import { expect } from 'expect'; +import { iteratorDrop } from 'iter-fest'; + +describe('iteratorDrop', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorDrop(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 3 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + expect(result.next()).toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorEntries.mjs b/packages/integration-test/test/importDefault/iteratorEntries.mjs new file mode 100644 index 0000000..12ba48e --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorEntries.mjs @@ -0,0 +1,11 @@ +import { expect } from 'expect'; +import { iteratorEntries } from 'iter-fest'; + +describe('iteratorEntries', () => { + it('should work', () => + expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ + [0, 'A'], + [1, 'B'], + [2, 'C'] + ])); +}); diff --git a/packages/integration-test/test/importDefault/iteratorEvery.mjs b/packages/integration-test/test/importDefault/iteratorEvery.mjs new file mode 100644 index 0000000..190ebd8 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorEvery.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { iteratorEvery, iteratorTake } from 'iter-fest'; + +describe('iteratorEvery', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 10); + + expect(iteratorEvery(iter, v => v >= 0)).toBe(true); + expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. + + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorFilter.mjs b/packages/integration-test/test/importDefault/iteratorFilter.mjs new file mode 100644 index 0000000..25a4cbf --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorFilter.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { iteratorFilter } from 'iter-fest'; + +describe('iteratorFilter', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorFind.mjs b/packages/integration-test/test/importDefault/iteratorFind.mjs new file mode 100644 index 0000000..95a7ca8 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorFind.mjs @@ -0,0 +1,19 @@ +import { expect } from 'expect'; +import { iteratorFind } from 'iter-fest'; + +describe('iteratorFind', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + expect(iteratorFind(naturals(), v => v > 1)).toBe(2); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorFindIndex.mjs b/packages/integration-test/test/importDefault/iteratorFindIndex.mjs new file mode 100644 index 0000000..8e1e009 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorFindIndex.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorFindIndex } from 'iter-fest'; + +describe('iteratorFindIndex', () => { + it('should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); +}); diff --git a/packages/integration-test/test/importDefault/iteratorFindLast.mjs b/packages/integration-test/test/importDefault/iteratorFindLast.mjs new file mode 100644 index 0000000..7c8db58 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorFindLast.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorFindLast } from 'iter-fest'; + +describe('iteratorFindLast', () => { + it('should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); +}); diff --git a/packages/integration-test/test/importDefault/iteratorFindLastIndex.mjs b/packages/integration-test/test/importDefault/iteratorFindLastIndex.mjs new file mode 100644 index 0000000..7aabac4 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorFindLastIndex.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorFindLastIndex } from 'iter-fest'; + +describe('iteratorFindLastIndex', () => { + it('should work', () => expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); +}); diff --git a/packages/integration-test/test/importDefault/iteratorFlatMap.mjs b/packages/integration-test/test/importDefault/iteratorFlatMap.mjs new file mode 100644 index 0000000..376e44f --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorFlatMap.mjs @@ -0,0 +1,18 @@ +import { expect } from 'expect'; +import { iteratorFlatMap } from 'iter-fest'; + +describe('iteratorFlatMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = ["It's Sunny in", '', 'California'].values(); + + const result = iteratorFlatMap(sunny, value => value.split(' ').values()); + + expect(result.next()).toEqual({ done: false, value: "It's" }); + expect(result.next()).toEqual({ done: false, value: 'Sunny' }); + expect(result.next()).toEqual({ done: false, value: 'in' }); + expect(result.next()).toEqual({ done: false, value: '' }); + expect(result.next()).toEqual({ done: false, value: 'California' }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorForEach.mjs b/packages/integration-test/test/importDefault/iteratorForEach.mjs new file mode 100644 index 0000000..7deb194 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorForEach.mjs @@ -0,0 +1,15 @@ +import { expect } from 'expect'; +import { iteratorForEach } from 'iter-fest'; + +describe('iteratorForEach', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = value => log.push(value); + const iter = [1, 2, 3].values(); + + iteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorFrom.mjs b/packages/integration-test/test/importDefault/iteratorFrom.mjs new file mode 100644 index 0000000..6c1d7b6 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorFrom.mjs @@ -0,0 +1,18 @@ +import { expect } from 'expect'; +import { iteratorFrom } from 'iter-fest'; + +describe('iteratorFrom', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return { done: false, value: 1 }; + } + } + + const iter = new Iter(); + const wrapper = iteratorFrom(iter); + + expect(wrapper.next()).toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorIncludes.mjs b/packages/integration-test/test/importDefault/iteratorIncludes.mjs new file mode 100644 index 0000000..775db5a --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorIncludes.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorIncludes } from 'iter-fest'; + +describe('iteratorIncludes', () => { + it('should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); +}); diff --git a/packages/integration-test/test/importDefault/iteratorIndexOf.mjs b/packages/integration-test/test/importDefault/iteratorIndexOf.mjs new file mode 100644 index 0000000..07d17bc --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorIndexOf.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorIndexOf } from 'iter-fest'; + +describe('iteratorIndexOf', () => { + it('should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); +}); diff --git a/packages/integration-test/test/importDefault/iteratorJoin.mjs b/packages/integration-test/test/importDefault/iteratorJoin.mjs new file mode 100644 index 0000000..a5d50d9 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorJoin.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorJoin } from 'iter-fest'; + +describe('iteratorJoin', () => { + it('should work', () => expect(iteratorJoin([1, 2, 3].values(), ', ')).toBe('1, 2, 3')); +}); diff --git a/packages/integration-test/test/importDefault/iteratorKeys.mjs b/packages/integration-test/test/importDefault/iteratorKeys.mjs new file mode 100644 index 0000000..25883af --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorKeys.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorKeys } from 'iter-fest'; + +describe('iteratorKeys', () => { + it('should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); +}); diff --git a/packages/integration-test/test/importDefault/iteratorMap.mjs b/packages/integration-test/test/importDefault/iteratorMap.mjs new file mode 100644 index 0000000..5635174 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorMap.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { iteratorMap } from 'iter-fest'; + +describe('iteratorMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorMap(naturals(), value => { + return value * value; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorReduce.mjs b/packages/integration-test/test/importDefault/iteratorReduce.mjs new file mode 100644 index 0000000..4441864 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorReduce.mjs @@ -0,0 +1,27 @@ +import { expect } from 'expect'; +import { iteratorReduce, iteratorTake } from 'iter-fest'; + +describe('iteratorReduce', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorReduce( + iteratorTake(naturals(), 5), + (sum, value) => { + return sum + value; + }, + 3 + ); + + expect(result).toBe(13); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorSlice.mjs b/packages/integration-test/test/importDefault/iteratorSlice.mjs new file mode 100644 index 0000000..a2a24b8 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorSlice.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorSlice } from 'iter-fest'; + +describe('iteratorSlice', () => { + it('should work', () => expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); +}); diff --git a/packages/integration-test/test/importDefault/iteratorSome.mjs b/packages/integration-test/test/importDefault/iteratorSome.mjs new file mode 100644 index 0000000..3f8f0b7 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorSome.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { iteratorSome, iteratorTake } from 'iter-fest'; + +describe('iteratorSome', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 4); + + expect(iteratorSome(iter, v => v > 1)).toEqual(true); + expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. + + expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); + expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorTake.mjs b/packages/integration-test/test/importDefault/iteratorTake.mjs new file mode 100644 index 0000000..0f72ed3 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorTake.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { iteratorTake } from 'iter-fest'; + +describe('iteratorTake', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorTake(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorToArray.mjs b/packages/integration-test/test/importDefault/iteratorToArray.mjs new file mode 100644 index 0000000..d91340b --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorToArray.mjs @@ -0,0 +1,21 @@ +import { expect } from 'expect'; +import { iteratorTake, iteratorToArray } from 'iter-fest'; + +describe('iteratorToArray', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorToArray(iteratorTake(naturals(), 5)); + + expect(result).toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorToAsync.mjs b/packages/integration-test/test/importDefault/iteratorToAsync.mjs new file mode 100644 index 0000000..d5b6c1a --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorToAsync.mjs @@ -0,0 +1,14 @@ +import { expect } from 'expect'; +import { iteratorToAsync } from 'iter-fest'; + +describe('iteratorToAsync', () => { + it('should work', async () => { + const iterator = [1, 2, 3].values(); + const asyncIterator = iteratorToAsync(iterator); + + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorToIterable.mjs b/packages/integration-test/test/importDefault/iteratorToIterable.mjs new file mode 100644 index 0000000..3e76c87 --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorToIterable.mjs @@ -0,0 +1,34 @@ +import { expect } from 'expect'; +import { iteratorToIterable, Observable } from 'iter-fest'; +import { fake } from 'sinon'; + +describe('iteratorToIterable', () => { + it('should work', () => + expect( + Array.from( + iteratorToIterable( + (() => { + let value = 0; + + return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; + })() + ) + ) + ).toEqual([1, 2, 3])); + + it('Observable should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/importDefault/iteratorToSpliced.mjs b/packages/integration-test/test/importDefault/iteratorToSpliced.mjs new file mode 100644 index 0000000..972cb4e --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorToSpliced.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorToSpliced } from 'iter-fest'; + +describe('iteratorToSpliced', () => { + it('should work', () => expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); +}); diff --git a/packages/integration-test/test/importDefault/iteratorToString.mjs b/packages/integration-test/test/importDefault/iteratorToString.mjs new file mode 100644 index 0000000..592477a --- /dev/null +++ b/packages/integration-test/test/importDefault/iteratorToString.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorToString } from 'iter-fest'; + +describe('iteratorToString', () => { + it('should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); +}); diff --git a/packages/integration-test/test/importDefault/observable.mjs b/packages/integration-test/test/importDefault/observable.mjs new file mode 100644 index 0000000..523ffe2 --- /dev/null +++ b/packages/integration-test/test/importDefault/observable.mjs @@ -0,0 +1,21 @@ +import { expect } from 'expect'; +import { Observable } from 'iter-fest'; +import { fake } from 'sinon'; + +describe('Observable', () => { + it('should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/importDefault/observableFromAsync.mjs b/packages/integration-test/test/importDefault/observableFromAsync.mjs new file mode 100644 index 0000000..369d3d8 --- /dev/null +++ b/packages/integration-test/test/importDefault/observableFromAsync.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { observableFromAsync } from 'iter-fest'; +import { fake } from 'sinon'; + +describe('observableFromAsync', () => { + it('should work', async () => { + const observable = observableFromAsync( + (async function* () { + yield 1; + yield 2; + yield 3; + })() + ); + + const next = fake(() => {}); + + await new Promise(resolve => observable.subscribe({ complete: resolve, next })); + + expect(next).toHaveProperty('callCount', 3); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(next.getCall(1)).toHaveProperty('args', [2]); + expect(next.getCall(2)).toHaveProperty('args', [3]); + }); +}); diff --git a/packages/integration-test/test/importDefault/observableSubscribeAsReadable.mjs b/packages/integration-test/test/importDefault/observableSubscribeAsReadable.mjs new file mode 100644 index 0000000..118ea05 --- /dev/null +++ b/packages/integration-test/test/importDefault/observableSubscribeAsReadable.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { Observable, observableSubscribeAsReadable } from 'iter-fest'; + +describe('observableSubscribeAsReadable', () => { + it('should work', async () => { + const stream = new TextDecoderStream(); + const observable = Observable.from([65, 66, 67]); + const readable = observableSubscribeAsReadable(observable); + const numberToInt8Array = new TransformStream({ + transform(chunk, controller) { + controller.enqueue(Int8Array.from([chunk])); + } + }); + + readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); + + const reader = stream.readable.getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); + await expect(reader.read()).resolves.toEqual({ done: true }); + }); +}); diff --git a/packages/integration-test/test/importDefault/observableValues.mjs b/packages/integration-test/test/importDefault/observableValues.mjs new file mode 100644 index 0000000..4e48b5a --- /dev/null +++ b/packages/integration-test/test/importDefault/observableValues.mjs @@ -0,0 +1,15 @@ +import { expect } from 'expect'; +import { Observable, observableValues } from 'iter-fest'; + +describe('observableValues', () => { + it('should work', async () => { + const observable = Observable.from([1, 2, 3]); + const values = []; + + for await (const value of observableValues(observable)) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/importDefault/readableStreamFrom.mjs b/packages/integration-test/test/importDefault/readableStreamFrom.mjs new file mode 100644 index 0000000..0fd690c --- /dev/null +++ b/packages/integration-test/test/importDefault/readableStreamFrom.mjs @@ -0,0 +1,15 @@ +import { expect } from 'expect'; +import { readableStreamFrom } from 'iter-fest'; + +describe('readableStreamFrom', () => { + it('should work', async () => { + const iterable = [1, 2, 3].values(); + + const reader = readableStreamFrom(iterable).getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); + await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importDefault/readableStreamValues.mjs b/packages/integration-test/test/importDefault/readableStreamValues.mjs new file mode 100644 index 0000000..61adcc7 --- /dev/null +++ b/packages/integration-test/test/importDefault/readableStreamValues.mjs @@ -0,0 +1,22 @@ +import { expect } from 'expect'; +import { readableStreamValues } from 'iter-fest'; + +describe('readableStreamValues', () => { + it('should work', async () => { + const readableStream = new ReadableStream({ + start(controller) { + controller.enqueue(1); + controller.enqueue(2); + controller.close(); + } + }); + + const values = []; + + for await (const value of readableStreamValues(readableStream)) { + values.push(value); + } + + expect(values).toEqual([1, 2]); + }); +}); diff --git a/packages/integration-test/test/importDefault/symbolObservable.mjs b/packages/integration-test/test/importDefault/symbolObservable.mjs new file mode 100644 index 0000000..764cc15 --- /dev/null +++ b/packages/integration-test/test/importDefault/symbolObservable.mjs @@ -0,0 +1,10 @@ +import { expect } from 'expect'; +import { Observable, SymbolObservable } from 'iter-fest'; + +describe('SymbolObservable', () => { + it('should work', () => { + const observable = new Observable(() => {}); + + expect(observable[SymbolObservable]()).toBe(observable); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncGeneratorWithLastValue.mjs b/packages/integration-test/test/importNamed/asyncGeneratorWithLastValue.mjs new file mode 100644 index 0000000..eb69369 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncGeneratorWithLastValue.mjs @@ -0,0 +1,20 @@ +import { expect } from 'expect'; +import { asyncGeneratorWithLastValue } from 'iter-fest/asyncGeneratorWithLastValue'; + +describe('asyncGeneratorWithLastValue', () => { + it('should work', async () => { + const asyncGenerator = asyncGeneratorWithLastValue( + (async function* () { + yield 1; + + return 'end'; + })() + ); + + for await (const value of asyncGenerator) { + expect(value).toBe(1); + } + + expect(asyncGenerator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorDrop.mjs b/packages/integration-test/test/importNamed/asyncIteratorDrop.mjs new file mode 100644 index 0000000..7838bf1 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorDrop.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { asyncIteratorDrop } from 'iter-fest/asyncIteratorDrop'; + +describe('asyncIteratorDrop', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorDrop(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorEvery.mjs b/packages/integration-test/test/importNamed/asyncIteratorEvery.mjs new file mode 100644 index 0000000..62bdc60 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorEvery.mjs @@ -0,0 +1,32 @@ +import { expect } from 'expect'; +import { asyncIteratorEvery } from 'iter-fest/asyncIteratorEvery'; +import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; + +describe('asyncIteratorEvery', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 10); + + await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); + await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. + + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( + false + ); // first value is 0 + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorFilter.mjs b/packages/integration-test/test/importNamed/asyncIteratorFilter.mjs new file mode 100644 index 0000000..e0b7e86 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorFilter.mjs @@ -0,0 +1,27 @@ +import { expect } from 'expect'; +import { asyncIteratorFilter } from 'iter-fest/asyncIteratorFilter'; + +describe('asyncIteratorFilter', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorFind.mjs b/packages/integration-test/test/importNamed/asyncIteratorFind.mjs new file mode 100644 index 0000000..7c28120 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorFind.mjs @@ -0,0 +1,21 @@ +import { expect } from 'expect'; +import { asyncIteratorFind } from 'iter-fest/asyncIteratorFind'; + +describe('asyncIteratorFind', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorFlatMap.mjs b/packages/integration-test/test/importNamed/asyncIteratorFlatMap.mjs new file mode 100644 index 0000000..8766693 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorFlatMap.mjs @@ -0,0 +1,19 @@ +import { expect } from 'expect'; +import { asyncIteratorFlatMap } from 'iter-fest/asyncIteratorFlatMap'; +import { iteratorToAsync } from 'iter-fest/iteratorToAsync'; + +describe('asyncIteratorFlatMap', () => { + it('should follow TC39 proposal sample (sync)', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); + + const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); + + await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); + await expect(result.next()).resolves.toEqual({ done: false, value: '' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorForEach.mjs b/packages/integration-test/test/importNamed/asyncIteratorForEach.mjs new file mode 100644 index 0000000..a877f7b --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorForEach.mjs @@ -0,0 +1,16 @@ +import { expect } from 'expect'; +import { asyncIteratorForEach } from 'iter-fest/asyncIteratorForEach'; +import { iteratorToAsync } from 'iter-fest/iteratorToAsync'; + +describe('asyncIteratorForEach', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = async value => void log.push(value); + const iter = iteratorToAsync([1, 2, 3].values()); + + await asyncIteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorFrom.mjs b/packages/integration-test/test/importNamed/asyncIteratorFrom.mjs new file mode 100644 index 0000000..565a867 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorFrom.mjs @@ -0,0 +1,18 @@ +import { expect } from 'expect'; +import { asyncIteratorFrom } from 'iter-fest/asyncIteratorFrom'; + +describe('asyncIteratorFrom', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return Promise.resolve({ done: false, value: 1 }); + } + } + + const iter = new Iter(); + const wrapper = asyncIteratorFrom(iter); + + await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorMap.mjs b/packages/integration-test/test/importNamed/asyncIteratorMap.mjs new file mode 100644 index 0000000..c7dff5b --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorMap.mjs @@ -0,0 +1,27 @@ +import { expect } from 'expect'; +import { asyncIteratorMap } from 'iter-fest/asyncIteratorMap'; + +describe('asyncIteratorMap', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorMap(naturals(), value => { + return value * value; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorReduce.mjs b/packages/integration-test/test/importNamed/asyncIteratorReduce.mjs new file mode 100644 index 0000000..5d7150b --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorReduce.mjs @@ -0,0 +1,30 @@ +import { expect } from 'expect'; +import { asyncIteratorReduce } from 'iter-fest/asyncIteratorReduce'; +import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; + +describe('asyncIteratorReduce', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorReduce( + asyncIteratorTake(naturals(), 5), + async (sum, value) => { + return sum + value; + }, + 3 + ); + + await expect(result).resolves.toBe(13); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorSome.mjs b/packages/integration-test/test/importNamed/asyncIteratorSome.mjs new file mode 100644 index 0000000..a762b26 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorSome.mjs @@ -0,0 +1,32 @@ +import { expect } from 'expect'; +import { asyncIteratorSome } from 'iter-fest/asyncIteratorSome'; +import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; + +describe('asyncIteratorSome', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 4); + + await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); + await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. + + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual( + true + ); + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorTake.mjs b/packages/integration-test/test/importNamed/asyncIteratorTake.mjs new file mode 100644 index 0000000..1625cc1 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorTake.mjs @@ -0,0 +1,26 @@ +import { expect } from 'expect'; +import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; + +describe('asyncIteratorTake', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorTake(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorToArray.mjs b/packages/integration-test/test/importNamed/asyncIteratorToArray.mjs new file mode 100644 index 0000000..bfa659d --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorToArray.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { asyncIteratorTake } from 'iter-fest/asyncIteratorTake'; +import { asyncIteratorToArray } from 'iter-fest/asyncIteratorToArray'; + +describe('asyncIteratorToArray', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); + + await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/importNamed/asyncIteratorToIterable.mjs b/packages/integration-test/test/importNamed/asyncIteratorToIterable.mjs new file mode 100644 index 0000000..aa98326 --- /dev/null +++ b/packages/integration-test/test/importNamed/asyncIteratorToIterable.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { asyncIteratorToAsyncIterable } from 'iter-fest'; + +describe('asyncIteratorToIterable', () => { + it('should work', async () => { + const iterable = asyncIteratorToAsyncIterable( + (() => { + let value = 0; + + return { + next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) + }; + })() + ); + + const values = []; + + for await (const value of iterable) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/importNamed/generatorWithLastValue.mjs b/packages/integration-test/test/importNamed/generatorWithLastValue.mjs new file mode 100644 index 0000000..f4a5293 --- /dev/null +++ b/packages/integration-test/test/importNamed/generatorWithLastValue.mjs @@ -0,0 +1,20 @@ +import { expect } from 'expect'; +import { generatorWithLastValue } from 'iter-fest/generatorWithLastValue'; + +describe('generatorWithLastValue', () => { + it('should work', () => { + const generator = generatorWithLastValue( + (function* () { + yield 1; + + return 'end'; + })() + ); + + for (const value of generator) { + expect(value).toBe(1); + } + + expect(generator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/importNamed/iterableWritableStream.mjs b/packages/integration-test/test/importNamed/iterableWritableStream.mjs new file mode 100644 index 0000000..6eff9fe --- /dev/null +++ b/packages/integration-test/test/importNamed/iterableWritableStream.mjs @@ -0,0 +1,43 @@ +import withResolvers from 'core-js-pure/full/promise/with-resolvers.js'; +import { expect } from 'expect'; +import { IterableWritableStream } from 'iter-fest/iterableWritableStream'; +import { fake } from 'sinon'; + +describe('IterableWritableStream', () => { + it('should work', async () => { + let deferred = withResolvers(); + const done = fake(() => {}); + const iterable = new IterableWritableStream(); + const writer = iterable.getWriter(); + const values = []; + + (async function () { + for await (const value of iterable) { + values.push(value); + + deferred.resolve(); + deferred = withResolvers(); + } + + done(); + deferred.resolve(); + })(); + + expect(values).toEqual([]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(1); + await deferred.promise; + expect(values).toEqual([1]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(2); + await deferred.promise; + expect(values).toEqual([1, 2]); + expect(done).toHaveProperty('callCount', 0); + + writer.close(); + await deferred.promise; + expect(done).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorAt.mjs b/packages/integration-test/test/importNamed/iteratorAt.mjs new file mode 100644 index 0000000..2293d41 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorAt.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorAt } from 'iter-fest/iteratorAt'; + +describe('iteratorAt', () => { + it('should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); +}); diff --git a/packages/integration-test/test/importNamed/iteratorConcat.mjs b/packages/integration-test/test/importNamed/iteratorConcat.mjs new file mode 100644 index 0000000..fd43575 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorConcat.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorConcat } from 'iter-fest/iteratorConcat'; + +describe('iterableConcat', () => { + it('should work', () => expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); +}); diff --git a/packages/integration-test/test/importNamed/iteratorDrop.mjs b/packages/integration-test/test/importNamed/iteratorDrop.mjs new file mode 100644 index 0000000..ef2fe5b --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorDrop.mjs @@ -0,0 +1,23 @@ +import { expect } from 'expect'; +import { iteratorDrop } from 'iter-fest/iteratorDrop'; + +describe('iteratorDrop', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorDrop(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 3 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + expect(result.next()).toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorEntries.mjs b/packages/integration-test/test/importNamed/iteratorEntries.mjs new file mode 100644 index 0000000..649e954 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorEntries.mjs @@ -0,0 +1,11 @@ +import { expect } from 'expect'; +import { iteratorEntries } from 'iter-fest/iteratorEntries'; + +describe('iteratorEntries', () => { + it('should work', () => + expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ + [0, 'A'], + [1, 'B'], + [2, 'C'] + ])); +}); diff --git a/packages/integration-test/test/importNamed/iteratorEvery.mjs b/packages/integration-test/test/importNamed/iteratorEvery.mjs new file mode 100644 index 0000000..5cfcb8c --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorEvery.mjs @@ -0,0 +1,26 @@ +import { expect } from 'expect'; +import { iteratorEvery } from 'iter-fest/iteratorEvery'; +import { iteratorTake } from 'iter-fest/iteratorTake'; + +describe('iteratorEvery', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 10); + + expect(iteratorEvery(iter, v => v >= 0)).toBe(true); + expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. + + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorFilter.mjs b/packages/integration-test/test/importNamed/iteratorFilter.mjs new file mode 100644 index 0000000..f513063 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorFilter.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { iteratorFilter } from 'iter-fest/iteratorFilter'; + +describe('iteratorFilter', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorFind.mjs b/packages/integration-test/test/importNamed/iteratorFind.mjs new file mode 100644 index 0000000..3498604 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorFind.mjs @@ -0,0 +1,19 @@ +import { expect } from 'expect'; +import { iteratorFind } from 'iter-fest/iteratorFind'; + +describe('iteratorFind', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + expect(iteratorFind(naturals(), v => v > 1)).toBe(2); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorFindIndex.mjs b/packages/integration-test/test/importNamed/iteratorFindIndex.mjs new file mode 100644 index 0000000..db52f6e --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorFindIndex.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorFindIndex } from 'iter-fest/iteratorFindIndex'; + +describe('iteratorFindIndex', () => { + it('should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); +}); diff --git a/packages/integration-test/test/importNamed/iteratorFindLast.mjs b/packages/integration-test/test/importNamed/iteratorFindLast.mjs new file mode 100644 index 0000000..40a9c88 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorFindLast.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorFindLast } from 'iter-fest/iteratorFindLast'; + +describe('iteratorFindLast', () => { + it('should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); +}); diff --git a/packages/integration-test/test/importNamed/iteratorFindLastIndex.mjs b/packages/integration-test/test/importNamed/iteratorFindLastIndex.mjs new file mode 100644 index 0000000..5f026b9 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorFindLastIndex.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorFindLastIndex } from 'iter-fest/iteratorFindLastIndex'; + +describe('iteratorFindLastIndex', () => { + it('should work', () => expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); +}); diff --git a/packages/integration-test/test/importNamed/iteratorFlatMap.mjs b/packages/integration-test/test/importNamed/iteratorFlatMap.mjs new file mode 100644 index 0000000..e7fc011 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorFlatMap.mjs @@ -0,0 +1,18 @@ +import { expect } from 'expect'; +import { iteratorFlatMap } from 'iter-fest/iteratorFlatMap'; + +describe('iteratorFlatMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = ["It's Sunny in", '', 'California'].values(); + + const result = iteratorFlatMap(sunny, value => value.split(' ').values()); + + expect(result.next()).toEqual({ done: false, value: "It's" }); + expect(result.next()).toEqual({ done: false, value: 'Sunny' }); + expect(result.next()).toEqual({ done: false, value: 'in' }); + expect(result.next()).toEqual({ done: false, value: '' }); + expect(result.next()).toEqual({ done: false, value: 'California' }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorForEach.mjs b/packages/integration-test/test/importNamed/iteratorForEach.mjs new file mode 100644 index 0000000..48d5645 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorForEach.mjs @@ -0,0 +1,15 @@ +import { expect } from 'expect'; +import { iteratorForEach } from 'iter-fest/iteratorForEach'; + +describe('iteratorForEach', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = value => log.push(value); + const iter = [1, 2, 3].values(); + + iteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorFrom.mjs b/packages/integration-test/test/importNamed/iteratorFrom.mjs new file mode 100644 index 0000000..6c6ef5a --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorFrom.mjs @@ -0,0 +1,18 @@ +import { expect } from 'expect'; +import { iteratorFrom } from 'iter-fest/iteratorFrom'; + +describe('iteratorFrom', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return { done: false, value: 1 }; + } + } + + const iter = new Iter(); + const wrapper = iteratorFrom(iter); + + expect(wrapper.next()).toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorIncludes.mjs b/packages/integration-test/test/importNamed/iteratorIncludes.mjs new file mode 100644 index 0000000..424c24d --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorIncludes.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorIncludes } from 'iter-fest/iteratorIncludes'; + +describe('iteratorIncludes', () => { + it('should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); +}); diff --git a/packages/integration-test/test/importNamed/iteratorIndexOf.mjs b/packages/integration-test/test/importNamed/iteratorIndexOf.mjs new file mode 100644 index 0000000..8c401bb --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorIndexOf.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorIndexOf } from 'iter-fest/iteratorIndexOf'; + +describe('iteratorIndexOf', () => { + it('should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); +}); diff --git a/packages/integration-test/test/importNamed/iteratorJoin.mjs b/packages/integration-test/test/importNamed/iteratorJoin.mjs new file mode 100644 index 0000000..a43851f --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorJoin.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorJoin } from 'iter-fest/iteratorJoin'; + +describe('iteratorJoin', () => { + it('should work', () => expect(iteratorJoin([1, 2, 3].values(), ', ')).toBe('1, 2, 3')); +}); diff --git a/packages/integration-test/test/importNamed/iteratorKeys.mjs b/packages/integration-test/test/importNamed/iteratorKeys.mjs new file mode 100644 index 0000000..7afb225 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorKeys.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorKeys } from 'iter-fest/iteratorKeys'; + +describe('iteratorKeys', () => { + it('should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); +}); diff --git a/packages/integration-test/test/importNamed/iteratorMap.mjs b/packages/integration-test/test/importNamed/iteratorMap.mjs new file mode 100644 index 0000000..1a91ec5 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorMap.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { iteratorMap } from 'iter-fest/iteratorMap'; + +describe('iteratorMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorMap(naturals(), value => { + return value * value; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorReduce.mjs b/packages/integration-test/test/importNamed/iteratorReduce.mjs new file mode 100644 index 0000000..6e29118 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorReduce.mjs @@ -0,0 +1,28 @@ +import { expect } from 'expect'; +import { iteratorReduce } from 'iter-fest/iteratorReduce'; +import { iteratorTake } from 'iter-fest/iteratorTake'; + +describe('iteratorReduce', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorReduce( + iteratorTake(naturals(), 5), + (sum, value) => { + return sum + value; + }, + 3 + ); + + expect(result).toBe(13); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorSlice.mjs b/packages/integration-test/test/importNamed/iteratorSlice.mjs new file mode 100644 index 0000000..fe825bc --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorSlice.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorSlice } from 'iter-fest/iteratorSlice'; + +describe('iteratorSlice', () => { + it('should work', () => expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); +}); diff --git a/packages/integration-test/test/importNamed/iteratorSome.mjs b/packages/integration-test/test/importNamed/iteratorSome.mjs new file mode 100644 index 0000000..a0c267d --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorSome.mjs @@ -0,0 +1,26 @@ +import { expect } from 'expect'; +import { iteratorSome } from 'iter-fest/iteratorSome'; +import { iteratorTake } from 'iter-fest/iteratorTake'; + +describe('iteratorSome', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 4); + + expect(iteratorSome(iter, v => v > 1)).toEqual(true); + expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. + + expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); + expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorTake.mjs b/packages/integration-test/test/importNamed/iteratorTake.mjs new file mode 100644 index 0000000..2180a63 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorTake.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { iteratorTake } from 'iter-fest/iteratorTake'; + +describe('iteratorTake', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorTake(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorToArray.mjs b/packages/integration-test/test/importNamed/iteratorToArray.mjs new file mode 100644 index 0000000..93b6ae3 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorToArray.mjs @@ -0,0 +1,22 @@ +import { expect } from 'expect'; +import { iteratorTake } from 'iter-fest/iteratorTake'; +import { iteratorToArray } from 'iter-fest/iteratorToArray'; + +describe('iteratorToArray', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorToArray(iteratorTake(naturals(), 5)); + + expect(result).toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorToAsync.mjs b/packages/integration-test/test/importNamed/iteratorToAsync.mjs new file mode 100644 index 0000000..3ea9ac3 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorToAsync.mjs @@ -0,0 +1,14 @@ +import { expect } from 'expect'; +import { iteratorToAsync } from 'iter-fest/iteratorToAsync'; + +describe('iteratorToAsync', () => { + it('should work', async () => { + const iterator = [1, 2, 3].values(); + const asyncIterator = iteratorToAsync(iterator); + + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorToIterable.mjs b/packages/integration-test/test/importNamed/iteratorToIterable.mjs new file mode 100644 index 0000000..52a6f2e --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorToIterable.mjs @@ -0,0 +1,35 @@ +import { expect } from 'expect'; +import { iteratorToIterable } from 'iter-fest/iteratorToIterable'; +import { Observable } from 'iter-fest/observable'; +import { fake } from 'sinon'; + +describe('iteratorToIterable', () => { + it('should work', () => + expect( + Array.from( + iteratorToIterable( + (() => { + let value = 0; + + return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; + })() + ) + ) + ).toEqual([1, 2, 3])); + + it('Observable should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/importNamed/iteratorToSpliced.mjs b/packages/integration-test/test/importNamed/iteratorToSpliced.mjs new file mode 100644 index 0000000..5af2712 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorToSpliced.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorToSpliced } from 'iter-fest/iteratorToSpliced'; + +describe('iteratorToSpliced', () => { + it('should work', () => expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); +}); diff --git a/packages/integration-test/test/importNamed/iteratorToString.mjs b/packages/integration-test/test/importNamed/iteratorToString.mjs new file mode 100644 index 0000000..67aa115 --- /dev/null +++ b/packages/integration-test/test/importNamed/iteratorToString.mjs @@ -0,0 +1,6 @@ +import { expect } from 'expect'; +import { iteratorToString } from 'iter-fest/iteratorToString'; + +describe('iteratorToString', () => { + it('should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); +}); diff --git a/packages/integration-test/test/importNamed/observable.mjs b/packages/integration-test/test/importNamed/observable.mjs new file mode 100644 index 0000000..ffeec27 --- /dev/null +++ b/packages/integration-test/test/importNamed/observable.mjs @@ -0,0 +1,21 @@ +import { expect } from 'expect'; +import { Observable } from 'iter-fest/observable'; +import { fake } from 'sinon'; + +describe('Observable', () => { + it('should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/importNamed/observableFromAsync.mjs b/packages/integration-test/test/importNamed/observableFromAsync.mjs new file mode 100644 index 0000000..e53a9d6 --- /dev/null +++ b/packages/integration-test/test/importNamed/observableFromAsync.mjs @@ -0,0 +1,24 @@ +import { expect } from 'expect'; +import { observableFromAsync } from 'iter-fest/observableFromAsync'; +import { fake } from 'sinon'; + +describe('observableFromAsync', () => { + it('should work', async () => { + const observable = observableFromAsync( + (async function* () { + yield 1; + yield 2; + yield 3; + })() + ); + + const next = fake(() => {}); + + await new Promise(resolve => observable.subscribe({ complete: resolve, next })); + + expect(next).toHaveProperty('callCount', 3); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(next.getCall(1)).toHaveProperty('args', [2]); + expect(next.getCall(2)).toHaveProperty('args', [3]); + }); +}); diff --git a/packages/integration-test/test/importNamed/observableSubscribeAsReadable.mjs b/packages/integration-test/test/importNamed/observableSubscribeAsReadable.mjs new file mode 100644 index 0000000..58d6b76 --- /dev/null +++ b/packages/integration-test/test/importNamed/observableSubscribeAsReadable.mjs @@ -0,0 +1,25 @@ +import { expect } from 'expect'; +import { Observable } from 'iter-fest/observable'; +import { observableSubscribeAsReadable } from 'iter-fest/observableSubscribeAsReadable'; + +describe('observableSubscribeAsReadable', () => { + it('should work', async () => { + const stream = new TextDecoderStream(); + const observable = Observable.from([65, 66, 67]); + const readable = observableSubscribeAsReadable(observable); + const numberToInt8Array = new TransformStream({ + transform(chunk, controller) { + controller.enqueue(Int8Array.from([chunk])); + } + }); + + readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); + + const reader = stream.readable.getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); + await expect(reader.read()).resolves.toEqual({ done: true }); + }); +}); diff --git a/packages/integration-test/test/importNamed/observableValues.mjs b/packages/integration-test/test/importNamed/observableValues.mjs new file mode 100644 index 0000000..fad37ff --- /dev/null +++ b/packages/integration-test/test/importNamed/observableValues.mjs @@ -0,0 +1,16 @@ +import { expect } from 'expect'; +import { Observable } from 'iter-fest/observable'; +import { observableValues } from 'iter-fest/observableValues'; + +describe('observableValues', () => { + it('should work', async () => { + const observable = Observable.from([1, 2, 3]); + const values = []; + + for await (const value of observableValues(observable)) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/importNamed/readableStreamFrom.mjs b/packages/integration-test/test/importNamed/readableStreamFrom.mjs new file mode 100644 index 0000000..235bb83 --- /dev/null +++ b/packages/integration-test/test/importNamed/readableStreamFrom.mjs @@ -0,0 +1,15 @@ +import { expect } from 'expect'; +import { readableStreamFrom } from 'iter-fest/readableStreamFrom'; + +describe('readableStreamFrom', () => { + it('should work', async () => { + const iterable = [1, 2, 3].values(); + + const reader = readableStreamFrom(iterable).getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); + await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/importNamed/readableStreamValues.mjs b/packages/integration-test/test/importNamed/readableStreamValues.mjs new file mode 100644 index 0000000..3833b87 --- /dev/null +++ b/packages/integration-test/test/importNamed/readableStreamValues.mjs @@ -0,0 +1,22 @@ +import { expect } from 'expect'; +import { readableStreamValues } from 'iter-fest/readableStreamValues'; + +describe('readableStreamValues', () => { + it('should work', async () => { + const readableStream = new ReadableStream({ + start(controller) { + controller.enqueue(1); + controller.enqueue(2); + controller.close(); + } + }); + + const values = []; + + for await (const value of readableStreamValues(readableStream)) { + values.push(value); + } + + expect(values).toEqual([1, 2]); + }); +}); diff --git a/packages/integration-test/test/importNamed/symbolObservable.mjs b/packages/integration-test/test/importNamed/symbolObservable.mjs new file mode 100644 index 0000000..e1199aa --- /dev/null +++ b/packages/integration-test/test/importNamed/symbolObservable.mjs @@ -0,0 +1,11 @@ +import { expect } from 'expect'; +import { Observable } from 'iter-fest/observable'; +import { SymbolObservable } from 'iter-fest/symbolObservable'; + +describe('SymbolObservable', () => { + it('should work', () => { + const observable = new Observable(() => {}); + + expect(observable[SymbolObservable]()).toBe(observable); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncGeneratorWithLastValue.js b/packages/integration-test/test/requireDefault/asyncGeneratorWithLastValue.js new file mode 100644 index 0000000..ecc828d --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncGeneratorWithLastValue.js @@ -0,0 +1,20 @@ +const { expect } = require('expect'); +const { asyncGeneratorWithLastValue } = require('iter-fest'); + +describe('asyncGeneratorWithLastValue', () => { + it('should work', async () => { + const asyncGenerator = asyncGeneratorWithLastValue( + (async function* () { + yield 1; + + return 'end'; + })() + ); + + for await (const value of asyncGenerator) { + expect(value).toBe(1); + } + + expect(asyncGenerator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorDrop.js b/packages/integration-test/test/requireDefault/asyncIteratorDrop.js new file mode 100644 index 0000000..c4bc56b --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorDrop.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { asyncIteratorDrop } = require('iter-fest'); + +describe('asyncIteratorDrop', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorDrop(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorEvery.js b/packages/integration-test/test/requireDefault/asyncIteratorEvery.js new file mode 100644 index 0000000..027c97f --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorEvery.js @@ -0,0 +1,31 @@ +const { expect } = require('expect'); +const { asyncIteratorEvery, asyncIteratorTake } = require('iter-fest'); + +describe('asyncIteratorEvery', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 10); + + await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); + await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. + + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( + false + ); // first value is 0 + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorFilter.js b/packages/integration-test/test/requireDefault/asyncIteratorFilter.js new file mode 100644 index 0000000..9f0c1c1 --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorFilter.js @@ -0,0 +1,27 @@ +const { expect } = require('expect'); +const { asyncIteratorFilter } = require('iter-fest'); + +describe('asyncIteratorFilter', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorFind.js b/packages/integration-test/test/requireDefault/asyncIteratorFind.js new file mode 100644 index 0000000..ee38a0a --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorFind.js @@ -0,0 +1,21 @@ +const { expect } = require('expect'); +const { asyncIteratorFind } = require('iter-fest'); + +describe('asyncIteratorFind', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorFlatMap.js b/packages/integration-test/test/requireDefault/asyncIteratorFlatMap.js new file mode 100644 index 0000000..aac2271 --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorFlatMap.js @@ -0,0 +1,18 @@ +const { expect } = require('expect'); +const { asyncIteratorFlatMap, iteratorToAsync } = require('iter-fest'); + +describe('asyncIteratorFlatMap', () => { + it('should follow TC39 proposal sample (sync)', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); + + const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); + + await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); + await expect(result.next()).resolves.toEqual({ done: false, value: '' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorForEach.js b/packages/integration-test/test/requireDefault/asyncIteratorForEach.js new file mode 100644 index 0000000..457e585 --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorForEach.js @@ -0,0 +1,15 @@ +const { expect } = require('expect'); +const { asyncIteratorForEach, iteratorToAsync } = require('iter-fest'); + +describe('asyncIteratorForEach', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = async value => void log.push(value); + const iter = iteratorToAsync([1, 2, 3].values()); + + await asyncIteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorFrom.js b/packages/integration-test/test/requireDefault/asyncIteratorFrom.js new file mode 100644 index 0000000..ce0b7ca --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorFrom.js @@ -0,0 +1,18 @@ +const { expect } = require('expect'); +const { asyncIteratorFrom } = require('iter-fest'); + +describe('asyncIteratorFrom', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return Promise.resolve({ done: false, value: 1 }); + } + } + + const iter = new Iter(); + const wrapper = asyncIteratorFrom(iter); + + await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorMap.js b/packages/integration-test/test/requireDefault/asyncIteratorMap.js new file mode 100644 index 0000000..437377a --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorMap.js @@ -0,0 +1,27 @@ +const { expect } = require('expect'); +const { asyncIteratorMap } = require('iter-fest'); + +describe('asyncIteratorMap', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorMap(naturals(), value => { + return value * value; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorReduce.js b/packages/integration-test/test/requireDefault/asyncIteratorReduce.js new file mode 100644 index 0000000..3a3be90 --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorReduce.js @@ -0,0 +1,29 @@ +const { expect } = require('expect'); +const { asyncIteratorReduce, asyncIteratorTake } = require('iter-fest'); + +describe('asyncIteratorReduce', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorReduce( + asyncIteratorTake(naturals(), 5), + async (sum, value) => { + return sum + value; + }, + 3 + ); + + await expect(result).resolves.toBe(13); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorSome.js b/packages/integration-test/test/requireDefault/asyncIteratorSome.js new file mode 100644 index 0000000..5535fa1 --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorSome.js @@ -0,0 +1,31 @@ +const { expect } = require('expect'); +const { asyncIteratorSome, asyncIteratorTake } = require('iter-fest'); + +describe('asyncIteratorSome', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 4); + + await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); + await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. + + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual( + true + ); + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorTake.js b/packages/integration-test/test/requireDefault/asyncIteratorTake.js new file mode 100644 index 0000000..6b28717 --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorTake.js @@ -0,0 +1,26 @@ +const { expect } = require('expect'); +const { asyncIteratorTake } = require('iter-fest'); + +describe('asyncIteratorTake', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorTake(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorToArray.js b/packages/integration-test/test/requireDefault/asyncIteratorToArray.js new file mode 100644 index 0000000..a9f716e --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorToArray.js @@ -0,0 +1,23 @@ +const { expect } = require('expect'); +const { asyncIteratorTake, asyncIteratorToArray } = require('iter-fest'); + +describe('asyncIteratorToArray', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); + + await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/requireDefault/asyncIteratorToIterable.js b/packages/integration-test/test/requireDefault/asyncIteratorToIterable.js new file mode 100644 index 0000000..688a65b --- /dev/null +++ b/packages/integration-test/test/requireDefault/asyncIteratorToIterable.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { asyncIteratorToAsyncIterable } = require('iter-fest'); + +describe('asyncIteratorToIterable', () => { + it('should work', async () => { + const iterable = asyncIteratorToAsyncIterable( + (() => { + let value = 0; + + return { + next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) + }; + })() + ); + + const values = []; + + for await (const value of iterable) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/requireDefault/generatorWithLastValue.js b/packages/integration-test/test/requireDefault/generatorWithLastValue.js new file mode 100644 index 0000000..49d2e2b --- /dev/null +++ b/packages/integration-test/test/requireDefault/generatorWithLastValue.js @@ -0,0 +1,20 @@ +const { expect } = require('expect'); +const { generatorWithLastValue } = require('iter-fest'); + +describe('generatorWithLastValue', () => { + it('should work', () => { + const generator = generatorWithLastValue( + (function* () { + yield 1; + + return 'end'; + })() + ); + + for (const value of generator) { + expect(value).toBe(1); + } + + expect(generator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iterableWritableStream.js b/packages/integration-test/test/requireDefault/iterableWritableStream.js new file mode 100644 index 0000000..ab3b740 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iterableWritableStream.js @@ -0,0 +1,43 @@ +const withResolvers = require('core-js-pure/full/promise/with-resolvers.js'); +const { expect } = require('expect'); +const { IterableWritableStream } = require('iter-fest'); +const { fake } = require('sinon'); + +describe('IterableWritableStream', () => { + it('should work', async () => { + let deferred = withResolvers(); + const done = fake(() => {}); + const iterable = new IterableWritableStream(); + const writer = iterable.getWriter(); + const values = []; + + (async function () { + for await (const value of iterable) { + values.push(value); + + deferred.resolve(); + deferred = withResolvers(); + } + + done(); + deferred.resolve(); + })(); + + expect(values).toEqual([]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(1); + await deferred.promise; + expect(values).toEqual([1]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(2); + await deferred.promise; + expect(values).toEqual([1, 2]); + expect(done).toHaveProperty('callCount', 0); + + writer.close(); + await deferred.promise; + expect(done).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorAt.js b/packages/integration-test/test/requireDefault/iteratorAt.js new file mode 100644 index 0000000..d9b867f --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorAt.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorAt } = require('iter-fest'); + +describe('iteratorAt', () => { + it('should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorConcat.js b/packages/integration-test/test/requireDefault/iteratorConcat.js new file mode 100644 index 0000000..0be325b --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorConcat.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorConcat } = require('iter-fest'); + +describe('iterableConcat', () => { + it('should work', () => expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorDrop.js b/packages/integration-test/test/requireDefault/iteratorDrop.js new file mode 100644 index 0000000..390d031 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorDrop.js @@ -0,0 +1,23 @@ +const { expect } = require('expect'); +const { iteratorDrop } = require('iter-fest'); + +describe('iteratorDrop', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorDrop(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 3 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + expect(result.next()).toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorEntries.js b/packages/integration-test/test/requireDefault/iteratorEntries.js new file mode 100644 index 0000000..75abcb5 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorEntries.js @@ -0,0 +1,11 @@ +const { expect } = require('expect'); +const { iteratorEntries } = require('iter-fest'); + +describe('iteratorEntries', () => { + it('should work', () => + expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ + [0, 'A'], + [1, 'B'], + [2, 'C'] + ])); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorEvery.js b/packages/integration-test/test/requireDefault/iteratorEvery.js new file mode 100644 index 0000000..e429373 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorEvery.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { iteratorEvery, iteratorTake } = require('iter-fest'); + +describe('iteratorEvery', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 10); + + expect(iteratorEvery(iter, v => v >= 0)).toBe(true); + expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. + + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorFilter.js b/packages/integration-test/test/requireDefault/iteratorFilter.js new file mode 100644 index 0000000..b596e39 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorFilter.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { iteratorFilter } = require('iter-fest'); + +describe('iteratorFilter', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorFind.js b/packages/integration-test/test/requireDefault/iteratorFind.js new file mode 100644 index 0000000..39dff35 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorFind.js @@ -0,0 +1,19 @@ +const { expect } = require('expect'); +const { iteratorFind } = require('iter-fest'); + +describe('iteratorFind', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + expect(iteratorFind(naturals(), v => v > 1)).toBe(2); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorFindIndex.js b/packages/integration-test/test/requireDefault/iteratorFindIndex.js new file mode 100644 index 0000000..2a20670 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorFindIndex.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorFindIndex } = require('iter-fest'); + +describe('iteratorFindIndex', () => { + it('should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorFindLast.js b/packages/integration-test/test/requireDefault/iteratorFindLast.js new file mode 100644 index 0000000..fe9cee6 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorFindLast.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorFindLast } = require('iter-fest'); + +describe('iteratorFindLast', () => { + it('should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorFindLastIndex.js b/packages/integration-test/test/requireDefault/iteratorFindLastIndex.js new file mode 100644 index 0000000..f5cfb77 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorFindLastIndex.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorFindLastIndex } = require('iter-fest'); + +describe('iteratorFindLastIndex', () => { + it('should work', () => expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorFlatMap.js b/packages/integration-test/test/requireDefault/iteratorFlatMap.js new file mode 100644 index 0000000..2ea1954 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorFlatMap.js @@ -0,0 +1,18 @@ +const { expect } = require('expect'); +const { iteratorFlatMap } = require('iter-fest'); + +describe('iteratorFlatMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = ["It's Sunny in", '', 'California'].values(); + + const result = iteratorFlatMap(sunny, value => value.split(' ').values()); + + expect(result.next()).toEqual({ done: false, value: "It's" }); + expect(result.next()).toEqual({ done: false, value: 'Sunny' }); + expect(result.next()).toEqual({ done: false, value: 'in' }); + expect(result.next()).toEqual({ done: false, value: '' }); + expect(result.next()).toEqual({ done: false, value: 'California' }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorForEach.js b/packages/integration-test/test/requireDefault/iteratorForEach.js new file mode 100644 index 0000000..12e2550 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorForEach.js @@ -0,0 +1,15 @@ +const { expect } = require('expect'); +const { iteratorForEach } = require('iter-fest'); + +describe('iteratorForEach', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = value => log.push(value); + const iter = [1, 2, 3].values(); + + iteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorFrom.js b/packages/integration-test/test/requireDefault/iteratorFrom.js new file mode 100644 index 0000000..84b448e --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorFrom.js @@ -0,0 +1,18 @@ +const { expect } = require('expect'); +const { iteratorFrom } = require('iter-fest'); + +describe('iteratorFrom', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return { done: false, value: 1 }; + } + } + + const iter = new Iter(); + const wrapper = iteratorFrom(iter); + + expect(wrapper.next()).toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorIncludes.js b/packages/integration-test/test/requireDefault/iteratorIncludes.js new file mode 100644 index 0000000..f9242c8 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorIncludes.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorIncludes } = require('iter-fest'); + +describe('iteratorIncludes', () => { + it('should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorIndexOf.js b/packages/integration-test/test/requireDefault/iteratorIndexOf.js new file mode 100644 index 0000000..3053c28 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorIndexOf.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorIndexOf } = require('iter-fest'); + +describe('iteratorIndexOf', () => { + it('should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorJoin.js b/packages/integration-test/test/requireDefault/iteratorJoin.js new file mode 100644 index 0000000..a7bc63b --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorJoin.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorJoin } = require('iter-fest'); + +describe('iteratorJoin', () => { + it('should work', () => expect(iteratorJoin([1, 2, 3].values(), ', ')).toBe('1, 2, 3')); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorKeys.js b/packages/integration-test/test/requireDefault/iteratorKeys.js new file mode 100644 index 0000000..b06971d --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorKeys.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorKeys } = require('iter-fest'); + +describe('iteratorKeys', () => { + it('should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorMap.js b/packages/integration-test/test/requireDefault/iteratorMap.js new file mode 100644 index 0000000..28b9dfa --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorMap.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { iteratorMap } = require('iter-fest'); + +describe('iteratorMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorMap(naturals(), value => { + return value * value; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorReduce.js b/packages/integration-test/test/requireDefault/iteratorReduce.js new file mode 100644 index 0000000..bc7f453 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorReduce.js @@ -0,0 +1,27 @@ +const { expect } = require('expect'); +const { iteratorReduce, iteratorTake } = require('iter-fest'); + +describe('iteratorReduce', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorReduce( + iteratorTake(naturals(), 5), + (sum, value) => { + return sum + value; + }, + 3 + ); + + expect(result).toBe(13); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorSlice.js b/packages/integration-test/test/requireDefault/iteratorSlice.js new file mode 100644 index 0000000..9ba7f3f --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorSlice.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorSlice } = require('iter-fest'); + +describe('iteratorSlice', () => { + it('should work', () => expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorSome.js b/packages/integration-test/test/requireDefault/iteratorSome.js new file mode 100644 index 0000000..f6d7a34 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorSome.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { iteratorSome, iteratorTake } = require('iter-fest'); + +describe('iteratorSome', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 4); + + expect(iteratorSome(iter, v => v > 1)).toEqual(true); + expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. + + expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); + expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorTake.js b/packages/integration-test/test/requireDefault/iteratorTake.js new file mode 100644 index 0000000..78647cb --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorTake.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { iteratorTake } = require('iter-fest'); + +describe('iteratorTake', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorTake(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorToArray.js b/packages/integration-test/test/requireDefault/iteratorToArray.js new file mode 100644 index 0000000..91aa8bb --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorToArray.js @@ -0,0 +1,21 @@ +const { expect } = require('expect'); +const { iteratorTake, iteratorToArray } = require('iter-fest'); + +describe('iteratorToArray', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorToArray(iteratorTake(naturals(), 5)); + + expect(result).toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorToAsync.js b/packages/integration-test/test/requireDefault/iteratorToAsync.js new file mode 100644 index 0000000..482f5b4 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorToAsync.js @@ -0,0 +1,14 @@ +const { expect } = require('expect'); +const { iteratorToAsync } = require('iter-fest'); + +describe('iteratorToAsync', () => { + it('should work', async () => { + const iterator = [1, 2, 3].values(); + const asyncIterator = iteratorToAsync(iterator); + + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorToIterable.js b/packages/integration-test/test/requireDefault/iteratorToIterable.js new file mode 100644 index 0000000..156815e --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorToIterable.js @@ -0,0 +1,34 @@ +const { expect } = require('expect'); +const { iteratorToIterable, Observable } = require('iter-fest'); +const { fake } = require('sinon'); + +describe('iteratorToIterable', () => { + it('should work', () => + expect( + Array.from( + iteratorToIterable( + (() => { + let value = 0; + + return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; + })() + ) + ) + ).toEqual([1, 2, 3])); + + it('Observable should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorToSpliced.js b/packages/integration-test/test/requireDefault/iteratorToSpliced.js new file mode 100644 index 0000000..0244f71 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorToSpliced.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorToSpliced } = require('iter-fest'); + +describe('iteratorToSpliced', () => { + it('should work', () => expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); +}); diff --git a/packages/integration-test/test/requireDefault/iteratorToString.js b/packages/integration-test/test/requireDefault/iteratorToString.js new file mode 100644 index 0000000..d739c57 --- /dev/null +++ b/packages/integration-test/test/requireDefault/iteratorToString.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorToString } = require('iter-fest'); + +describe('iteratorToString', () => { + it('should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); +}); diff --git a/packages/integration-test/test/requireDefault/observable.js b/packages/integration-test/test/requireDefault/observable.js new file mode 100644 index 0000000..3a51b9a --- /dev/null +++ b/packages/integration-test/test/requireDefault/observable.js @@ -0,0 +1,21 @@ +const { expect } = require('expect'); +const { Observable } = require('iter-fest'); +const { fake } = require('sinon'); + +describe('Observable', () => { + it('should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/requireDefault/observableFromAsync.js b/packages/integration-test/test/requireDefault/observableFromAsync.js new file mode 100644 index 0000000..f44daab --- /dev/null +++ b/packages/integration-test/test/requireDefault/observableFromAsync.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { observableFromAsync } = require('iter-fest'); +const { fake } = require('sinon'); + +describe('observableFromAsync', () => { + it('should work', async () => { + const observable = observableFromAsync( + (async function* () { + yield 1; + yield 2; + yield 3; + })() + ); + + const next = fake(() => {}); + + await new Promise(resolve => observable.subscribe({ complete: resolve, next })); + + expect(next).toHaveProperty('callCount', 3); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(next.getCall(1)).toHaveProperty('args', [2]); + expect(next.getCall(2)).toHaveProperty('args', [3]); + }); +}); diff --git a/packages/integration-test/test/requireDefault/observableSubscribeAsReadable.js b/packages/integration-test/test/requireDefault/observableSubscribeAsReadable.js new file mode 100644 index 0000000..1cd6eed --- /dev/null +++ b/packages/integration-test/test/requireDefault/observableSubscribeAsReadable.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { Observable, observableSubscribeAsReadable } = require('iter-fest'); + +describe('observableSubscribeAsReadable', () => { + it('should work', async () => { + const stream = new TextDecoderStream(); + const observable = Observable.from([65, 66, 67]); + const readable = observableSubscribeAsReadable(observable); + const numberToInt8Array = new TransformStream({ + transform(chunk, controller) { + controller.enqueue(Int8Array.from([chunk])); + } + }); + + readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); + + const reader = stream.readable.getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); + await expect(reader.read()).resolves.toEqual({ done: true }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/observableValues.js b/packages/integration-test/test/requireDefault/observableValues.js new file mode 100644 index 0000000..4a73f13 --- /dev/null +++ b/packages/integration-test/test/requireDefault/observableValues.js @@ -0,0 +1,15 @@ +const { expect } = require('expect'); +const { Observable, observableValues } = require('iter-fest'); + +describe('observableValues', () => { + it('should work', async () => { + const observable = Observable.from([1, 2, 3]); + const values = []; + + for await (const value of observableValues(observable)) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/requireDefault/readableStreamFrom.js b/packages/integration-test/test/requireDefault/readableStreamFrom.js new file mode 100644 index 0000000..5e5691e --- /dev/null +++ b/packages/integration-test/test/requireDefault/readableStreamFrom.js @@ -0,0 +1,15 @@ +const { expect } = require('expect'); +const { readableStreamFrom } = require('iter-fest'); + +describe('readableStreamFrom', () => { + it('should work', async () => { + const iterable = [1, 2, 3].values(); + + const reader = readableStreamFrom(iterable).getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); + await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireDefault/readableStreamValues.js b/packages/integration-test/test/requireDefault/readableStreamValues.js new file mode 100644 index 0000000..070753a --- /dev/null +++ b/packages/integration-test/test/requireDefault/readableStreamValues.js @@ -0,0 +1,22 @@ +const { expect } = require('expect'); +const { readableStreamValues } = require('iter-fest'); + +describe('readableStreamValues', () => { + it('should work', async () => { + const readableStream = new ReadableStream({ + start(controller) { + controller.enqueue(1); + controller.enqueue(2); + controller.close(); + } + }); + + const values = []; + + for await (const value of readableStreamValues(readableStream)) { + values.push(value); + } + + expect(values).toEqual([1, 2]); + }); +}); diff --git a/packages/integration-test/test/requireDefault/symbolObservable.js b/packages/integration-test/test/requireDefault/symbolObservable.js new file mode 100644 index 0000000..c21aeaa --- /dev/null +++ b/packages/integration-test/test/requireDefault/symbolObservable.js @@ -0,0 +1,10 @@ +const { expect } = require('expect'); +const { Observable, SymbolObservable } = require('iter-fest'); + +describe('SymbolObservable', () => { + it('should work', () => { + const observable = new Observable(() => {}); + + expect(observable[SymbolObservable]()).toBe(observable); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncGeneratorWithLastValue.js b/packages/integration-test/test/requireNamed/asyncGeneratorWithLastValue.js new file mode 100644 index 0000000..730aa27 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncGeneratorWithLastValue.js @@ -0,0 +1,20 @@ +const { expect } = require('expect'); +const { asyncGeneratorWithLastValue } = require('iter-fest/asyncGeneratorWithLastValue'); + +describe('asyncGeneratorWithLastValue', () => { + it('should work', async () => { + const asyncGenerator = asyncGeneratorWithLastValue( + (async function* () { + yield 1; + + return 'end'; + })() + ); + + for await (const value of asyncGenerator) { + expect(value).toBe(1); + } + + expect(asyncGenerator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorDrop.js b/packages/integration-test/test/requireNamed/asyncIteratorDrop.js new file mode 100644 index 0000000..13b0879 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorDrop.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { asyncIteratorDrop } = require('iter-fest/asyncIteratorDrop'); + +describe('asyncIteratorDrop', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorDrop(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorEvery.js b/packages/integration-test/test/requireNamed/asyncIteratorEvery.js new file mode 100644 index 0000000..74e5a23 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorEvery.js @@ -0,0 +1,32 @@ +const { expect } = require('expect'); +const { asyncIteratorEvery } = require('iter-fest/asyncIteratorEvery'); +const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); + +describe('asyncIteratorEvery', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 10); + + await expect(asyncIteratorEvery(iter, v => Promise.resolve(v >= 0))).resolves.toBe(true); + await expect(asyncIteratorEvery(iter, () => Promise.resolve(false))).resolves.toBe(true); // iterator is already consumed. + + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 0))).resolves.toEqual( + false + ); // first value is 0 + await expect(asyncIteratorEvery(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v >= 0))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorFilter.js b/packages/integration-test/test/requireNamed/asyncIteratorFilter.js new file mode 100644 index 0000000..73b9b75 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorFilter.js @@ -0,0 +1,27 @@ +const { expect } = require('expect'); +const { asyncIteratorFilter } = require('iter-fest/asyncIteratorFilter'); + +describe('asyncIteratorFilter', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorFind.js b/packages/integration-test/test/requireNamed/asyncIteratorFind.js new file mode 100644 index 0000000..37bd03b --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorFind.js @@ -0,0 +1,21 @@ +const { expect } = require('expect'); +const { asyncIteratorFind } = require('iter-fest/asyncIteratorFind'); + +describe('asyncIteratorFind', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + await expect(asyncIteratorFind(naturals(), v => Promise.resolve(v > 1))).resolves.toBe(2); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorFlatMap.js b/packages/integration-test/test/requireNamed/asyncIteratorFlatMap.js new file mode 100644 index 0000000..02315c3 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorFlatMap.js @@ -0,0 +1,19 @@ +const { expect } = require('expect'); +const { asyncIteratorFlatMap } = require('iter-fest/asyncIteratorFlatMap'); +const { iteratorToAsync } = require('iter-fest/iteratorToAsync'); + +describe('asyncIteratorFlatMap', () => { + it('should follow TC39 proposal sample (sync)', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = iteratorToAsync(["It's Sunny in", '', 'California'].values()); + + const result = asyncIteratorFlatMap(sunny, value => Promise.resolve(value.split(' ').values())); + + await expect(result.next()).resolves.toEqual({ done: false, value: "It's" }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'Sunny' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'in' }); + await expect(result.next()).resolves.toEqual({ done: false, value: '' }); + await expect(result.next()).resolves.toEqual({ done: false, value: 'California' }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorForEach.js b/packages/integration-test/test/requireNamed/asyncIteratorForEach.js new file mode 100644 index 0000000..7b7d049 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorForEach.js @@ -0,0 +1,16 @@ +const { expect } = require('expect'); +const { asyncIteratorForEach } = require('iter-fest/asyncIteratorForEach'); +const { iteratorToAsync } = require('iter-fest/iteratorToAsync'); + +describe('asyncIteratorForEach', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = async value => void log.push(value); + const iter = iteratorToAsync([1, 2, 3].values()); + + await asyncIteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorFrom.js b/packages/integration-test/test/requireNamed/asyncIteratorFrom.js new file mode 100644 index 0000000..e10b668 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorFrom.js @@ -0,0 +1,18 @@ +const { expect } = require('expect'); +const { asyncIteratorFrom } = require('iter-fest/asyncIteratorFrom'); + +describe('asyncIteratorFrom', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return Promise.resolve({ done: false, value: 1 }); + } + } + + const iter = new Iter(); + const wrapper = asyncIteratorFrom(iter); + + await expect(wrapper.next()).resolves.toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorMap.js b/packages/integration-test/test/requireNamed/asyncIteratorMap.js new file mode 100644 index 0000000..c937d03 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorMap.js @@ -0,0 +1,27 @@ +const { expect } = require('expect'); +const { asyncIteratorMap } = require('iter-fest/asyncIteratorMap'); + +describe('asyncIteratorMap', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorMap(naturals(), value => { + return value * value; + }); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorReduce.js b/packages/integration-test/test/requireNamed/asyncIteratorReduce.js new file mode 100644 index 0000000..692160b --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorReduce.js @@ -0,0 +1,30 @@ +const { expect } = require('expect'); +const { asyncIteratorReduce } = require('iter-fest/asyncIteratorReduce'); +const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); + +describe('asyncIteratorReduce', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorReduce( + asyncIteratorTake(naturals(), 5), + async (sum, value) => { + return sum + value; + }, + 3 + ); + + await expect(result).resolves.toBe(13); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorSome.js b/packages/integration-test/test/requireNamed/asyncIteratorSome.js new file mode 100644 index 0000000..03f1001 --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorSome.js @@ -0,0 +1,32 @@ +const { expect } = require('expect'); +const { asyncIteratorSome } = require('iter-fest/asyncIteratorSome'); +const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); + +describe('asyncIteratorSome', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const iter = asyncIteratorTake(naturals(), 4); + + await expect(asyncIteratorSome(iter, v => Promise.resolve(v > 1))).resolves.toEqual(true); + await expect(asyncIteratorSome(iter, () => Promise.resolve(true))).resolves.toEqual(false); // iterator is already consumed. + + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v > 1))).resolves.toEqual( + true + ); + await expect(asyncIteratorSome(asyncIteratorTake(naturals(), 4), v => Promise.resolve(v == 1))).resolves.toEqual( + true + ); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorTake.js b/packages/integration-test/test/requireNamed/asyncIteratorTake.js new file mode 100644 index 0000000..e3cf43e --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorTake.js @@ -0,0 +1,26 @@ +const { expect } = require('expect'); +const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); + +describe('asyncIteratorTake', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorTake(naturals(), 3); + + await expect(result.next()).resolves.toEqual({ done: false, value: 0 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(result.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(result.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorToArray.js b/packages/integration-test/test/requireNamed/asyncIteratorToArray.js new file mode 100644 index 0000000..7b4e87a --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorToArray.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { asyncIteratorTake } = require('iter-fest/asyncIteratorTake'); +const { asyncIteratorToArray } = require('iter-fest/asyncIteratorToArray'); + +describe('asyncIteratorToArray', () => { + it('should work', async () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + async function* naturals() { + await 0; + let i = 0; + + while (true) { + await 0; + yield i; + + i += 1; + } + } + + const result = asyncIteratorToArray(asyncIteratorTake(naturals(), 5)); + + await expect(result).resolves.toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/requireNamed/asyncIteratorToIterable.js b/packages/integration-test/test/requireNamed/asyncIteratorToIterable.js new file mode 100644 index 0000000..4aa498c --- /dev/null +++ b/packages/integration-test/test/requireNamed/asyncIteratorToIterable.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { asyncIteratorToAsyncIterable } = require('iter-fest/asyncIteratorToAsyncIterable'); + +describe('asyncIteratorToIterable', () => { + it('should work', async () => { + const iterable = asyncIteratorToAsyncIterable( + (() => { + let value = 0; + + return { + next: () => Promise.resolve(++value <= 3 ? { done: false, value } : { done: true, value: undefined }) + }; + })() + ); + + const values = []; + + for await (const value of iterable) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/requireNamed/generatorWithLastValue.js b/packages/integration-test/test/requireNamed/generatorWithLastValue.js new file mode 100644 index 0000000..a4e26e2 --- /dev/null +++ b/packages/integration-test/test/requireNamed/generatorWithLastValue.js @@ -0,0 +1,20 @@ +const { expect } = require('expect'); +const { generatorWithLastValue } = require('iter-fest/generatorWithLastValue'); + +describe('generatorWithLastValue', () => { + it('should work', () => { + const generator = generatorWithLastValue( + (function* () { + yield 1; + + return 'end'; + })() + ); + + for (const value of generator) { + expect(value).toBe(1); + } + + expect(generator.lastValue()).toEqual('end'); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iterableWritableStream.js b/packages/integration-test/test/requireNamed/iterableWritableStream.js new file mode 100644 index 0000000..6def5aa --- /dev/null +++ b/packages/integration-test/test/requireNamed/iterableWritableStream.js @@ -0,0 +1,43 @@ +const withResolvers = require('core-js-pure/full/promise/with-resolvers.js'); +const { expect } = require('expect'); +const { IterableWritableStream } = require('iter-fest/iterableWritableStream'); +const { fake } = require('sinon'); + +describe('IterableWritableStream', () => { + it('should work', async () => { + let deferred = withResolvers(); + const done = fake(() => {}); + const iterable = new IterableWritableStream(); + const writer = iterable.getWriter(); + const values = []; + + (async function () { + for await (const value of iterable) { + values.push(value); + + deferred.resolve(); + deferred = withResolvers(); + } + + done(); + deferred.resolve(); + })(); + + expect(values).toEqual([]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(1); + await deferred.promise; + expect(values).toEqual([1]); + expect(done).toHaveProperty('callCount', 0); + + writer.write(2); + await deferred.promise; + expect(values).toEqual([1, 2]); + expect(done).toHaveProperty('callCount', 0); + + writer.close(); + await deferred.promise; + expect(done).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorAt.js b/packages/integration-test/test/requireNamed/iteratorAt.js new file mode 100644 index 0000000..803e220 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorAt.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorAt } = require('iter-fest/iteratorAt'); + +describe('iteratorAt', () => { + it('should work', () => expect(iteratorAt([1, 2, 3].values(), 1)).toBe(2)); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorConcat.js b/packages/integration-test/test/requireNamed/iteratorConcat.js new file mode 100644 index 0000000..fee075c --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorConcat.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorConcat } = require('iter-fest/iteratorConcat'); + +describe('iterableConcat', () => { + it('should work', () => expect(Array.from(iteratorConcat([1, 2].values(), [3, 4].values()))).toEqual([1, 2, 3, 4])); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorDrop.js b/packages/integration-test/test/requireNamed/iteratorDrop.js new file mode 100644 index 0000000..50a7c56 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorDrop.js @@ -0,0 +1,23 @@ +const { expect } = require('expect'); +const { iteratorDrop } = require('iter-fest/iteratorDrop'); + +describe('iteratorDrop', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorDrop(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 3 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + expect(result.next()).toEqual({ done: false, value: 5 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorEntries.js b/packages/integration-test/test/requireNamed/iteratorEntries.js new file mode 100644 index 0000000..22da721 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorEntries.js @@ -0,0 +1,11 @@ +const { expect } = require('expect'); +const { iteratorEntries } = require('iter-fest/iteratorEntries'); + +describe('iteratorEntries', () => { + it('should work', () => + expect(Array.from(iteratorEntries(['A', 'B', 'C'].values()))).toEqual([ + [0, 'A'], + [1, 'B'], + [2, 'C'] + ])); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorEvery.js b/packages/integration-test/test/requireNamed/iteratorEvery.js new file mode 100644 index 0000000..09b3bb8 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorEvery.js @@ -0,0 +1,26 @@ +const { expect } = require('expect'); +const { iteratorEvery } = require('iter-fest/iteratorEvery'); +const { iteratorTake } = require('iter-fest/iteratorTake'); + +describe('iteratorEvery', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 10); + + expect(iteratorEvery(iter, v => v >= 0)).toBe(true); + expect(iteratorEvery(iter, () => false)).toBe(true); // iterator is already consumed. + + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v > 0)).toEqual(false); // first value is 0 + expect(iteratorEvery(iteratorTake(naturals(), 4), v => v >= 0)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorFilter.js b/packages/integration-test/test/requireNamed/iteratorFilter.js new file mode 100644 index 0000000..f986e89 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorFilter.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { iteratorFilter } = require('iter-fest/iteratorFilter'); + +describe('iteratorFilter', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorFilter(naturals(), value => { + return value % 2 == 0; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorFind.js b/packages/integration-test/test/requireNamed/iteratorFind.js new file mode 100644 index 0000000..2c43d72 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorFind.js @@ -0,0 +1,19 @@ +const { expect } = require('expect'); +const { iteratorFind } = require('iter-fest/iteratorFind'); + +describe('iteratorFind', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + expect(iteratorFind(naturals(), v => v > 1)).toBe(2); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorFindIndex.js b/packages/integration-test/test/requireNamed/iteratorFindIndex.js new file mode 100644 index 0000000..e84a115 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorFindIndex.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorFindIndex } = require('iter-fest/iteratorFindIndex'); + +describe('iteratorFindIndex', () => { + it('should work', () => expect(iteratorFindIndex([1, 2, 3].values(), value => value % 2)).toBe(0)); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorFindLast.js b/packages/integration-test/test/requireNamed/iteratorFindLast.js new file mode 100644 index 0000000..96be9d0 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorFindLast.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorFindLast } = require('iter-fest/iteratorFindLast'); + +describe('iteratorFindLast', () => { + it('should work', () => expect(iteratorFindLast([1, 2, 3].values(), value => value % 2)).toBe(3)); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorFindLastIndex.js b/packages/integration-test/test/requireNamed/iteratorFindLastIndex.js new file mode 100644 index 0000000..ed92da4 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorFindLastIndex.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorFindLastIndex } = require('iter-fest/iteratorFindLastIndex'); + +describe('iteratorFindLastIndex', () => { + it('should work', () => expect(iteratorFindLastIndex([1, 2, 3].values(), value => value % 2)).toBe(2)); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorFlatMap.js b/packages/integration-test/test/requireNamed/iteratorFlatMap.js new file mode 100644 index 0000000..b534519 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorFlatMap.js @@ -0,0 +1,18 @@ +const { expect } = require('expect'); +const { iteratorFlatMap } = require('iter-fest/iteratorFlatMap'); + +describe('iteratorFlatMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const sunny = ["It's Sunny in", '', 'California'].values(); + + const result = iteratorFlatMap(sunny, value => value.split(' ').values()); + + expect(result.next()).toEqual({ done: false, value: "It's" }); + expect(result.next()).toEqual({ done: false, value: 'Sunny' }); + expect(result.next()).toEqual({ done: false, value: 'in' }); + expect(result.next()).toEqual({ done: false, value: '' }); + expect(result.next()).toEqual({ done: false, value: 'California' }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorForEach.js b/packages/integration-test/test/requireNamed/iteratorForEach.js new file mode 100644 index 0000000..12f941b --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorForEach.js @@ -0,0 +1,15 @@ +const { expect } = require('expect'); +const { iteratorForEach } = require('iter-fest/iteratorForEach'); + +describe('iteratorForEach', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + const log = []; + const fn = value => log.push(value); + const iter = [1, 2, 3].values(); + + iteratorForEach(iter, fn); + + expect(log.join(', ')).toBe('1, 2, 3'); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorFrom.js b/packages/integration-test/test/requireNamed/iteratorFrom.js new file mode 100644 index 0000000..5ac5d43 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorFrom.js @@ -0,0 +1,18 @@ +const { expect } = require('expect'); +const { iteratorFrom } = require('iter-fest/iteratorFrom'); + +describe('iteratorFrom', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + class Iter { + next() { + return { done: false, value: 1 }; + } + } + + const iter = new Iter(); + const wrapper = iteratorFrom(iter); + + expect(wrapper.next()).toEqual({ done: false, value: 1 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorIncludes.js b/packages/integration-test/test/requireNamed/iteratorIncludes.js new file mode 100644 index 0000000..09d6694 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorIncludes.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorIncludes } = require('iter-fest/iteratorIncludes'); + +describe('iteratorIncludes', () => { + it('should work', () => expect(iteratorIncludes([1, 2, 3].values(), 2)).toBe(true)); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorIndexOf.js b/packages/integration-test/test/requireNamed/iteratorIndexOf.js new file mode 100644 index 0000000..f3398a1 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorIndexOf.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorIndexOf } = require('iter-fest/iteratorIndexOf'); + +describe('iteratorIndexOf', () => { + it('should work', () => expect(iteratorIndexOf([1, 2, 3].values(), 2)).toBe(1)); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorJoin.js b/packages/integration-test/test/requireNamed/iteratorJoin.js new file mode 100644 index 0000000..4473ead --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorJoin.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorJoin } = require('iter-fest/iteratorJoin'); + +describe('iteratorJoin', () => { + it('should work', () => expect(iteratorJoin([1, 2, 3].values(), ', ')).toBe('1, 2, 3')); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorKeys.js b/packages/integration-test/test/requireNamed/iteratorKeys.js new file mode 100644 index 0000000..8d8782d --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorKeys.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorKeys } = require('iter-fest/iteratorKeys'); + +describe('iteratorKeys', () => { + it('should work', () => expect(Array.from(iteratorKeys(['A', 'B', 'C'].values()))).toEqual([0, 1, 2])); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorMap.js b/packages/integration-test/test/requireNamed/iteratorMap.js new file mode 100644 index 0000000..769a099 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorMap.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { iteratorMap } = require('iter-fest/iteratorMap'); + +describe('iteratorMap', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorMap(naturals(), value => { + return value * value; + }); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 4 }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorReduce.js b/packages/integration-test/test/requireNamed/iteratorReduce.js new file mode 100644 index 0000000..cc307be --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorReduce.js @@ -0,0 +1,28 @@ +const { expect } = require('expect'); +const { iteratorReduce } = require('iter-fest/iteratorReduce'); +const { iteratorTake } = require('iter-fest/iteratorTake'); + +describe('iteratorReduce', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorReduce( + iteratorTake(naturals(), 5), + (sum, value) => { + return sum + value; + }, + 3 + ); + + expect(result).toBe(13); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorSlice.js b/packages/integration-test/test/requireNamed/iteratorSlice.js new file mode 100644 index 0000000..149eb85 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorSlice.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorSlice } = require('iter-fest/iteratorSlice'); + +describe('iteratorSlice', () => { + it('should work', () => expect(Array.from(iteratorSlice([1, 2, 3, 4, 5].values(), 1, 4))).toEqual([2, 3, 4])); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorSome.js b/packages/integration-test/test/requireNamed/iteratorSome.js new file mode 100644 index 0000000..a049d61 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorSome.js @@ -0,0 +1,26 @@ +const { expect } = require('expect'); +const { iteratorSome } = require('iter-fest/iteratorSome'); +const { iteratorTake } = require('iter-fest/iteratorTake'); + +describe('iteratorSome', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const iter = iteratorTake(naturals(), 4); + + expect(iteratorSome(iter, v => v > 1)).toEqual(true); + expect(iteratorSome(iter, () => true)).toEqual(false); // iterator is already consumed. + + expect(iteratorSome(iteratorTake(naturals(), 4), v => v > 1)).toEqual(true); + expect(iteratorSome(iteratorTake(naturals(), 4), v => v == 1)).toEqual(true); // acting on a new iterator + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorTake.js b/packages/integration-test/test/requireNamed/iteratorTake.js new file mode 100644 index 0000000..84f2e4d --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorTake.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { iteratorTake } = require('iter-fest/iteratorTake'); + +describe('iteratorTake', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorTake(naturals(), 3); + + expect(result.next()).toEqual({ done: false, value: 0 }); + expect(result.next()).toEqual({ done: false, value: 1 }); + expect(result.next()).toEqual({ done: false, value: 2 }); + expect(result.next()).toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorToArray.js b/packages/integration-test/test/requireNamed/iteratorToArray.js new file mode 100644 index 0000000..b186cee --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorToArray.js @@ -0,0 +1,22 @@ +const { expect } = require('expect'); +const { iteratorTake } = require('iter-fest/iteratorTake'); +const { iteratorToArray } = require('iter-fest/iteratorToArray'); + +describe('iteratorToArray', () => { + it('should work', () => { + // Copied from https://github.com/tc39/proposal-iterator-helpers. + function* naturals() { + let i = 0; + + while (true) { + yield i; + + i += 1; + } + } + + const result = iteratorToArray(iteratorTake(naturals(), 5)); + + expect(result).toEqual([0, 1, 2, 3, 4]); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorToAsync.js b/packages/integration-test/test/requireNamed/iteratorToAsync.js new file mode 100644 index 0000000..ca3cc45 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorToAsync.js @@ -0,0 +1,14 @@ +const { expect } = require('expect'); +const { iteratorToAsync } = require('iter-fest/iteratorToAsync'); + +describe('iteratorToAsync', () => { + it('should work', async () => { + const iterator = [1, 2, 3].values(); + const asyncIterator = iteratorToAsync(iterator); + + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 1 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 2 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: false, value: 3 }); + await expect(asyncIterator.next()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorToIterable.js b/packages/integration-test/test/requireNamed/iteratorToIterable.js new file mode 100644 index 0000000..1157dd1 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorToIterable.js @@ -0,0 +1,35 @@ +const { expect } = require('expect'); +const { iteratorToIterable } = require('iter-fest/iteratorToIterable'); +const { Observable } = require('iter-fest/observable'); +const { fake } = require('sinon'); + +describe('iteratorToIterable', () => { + it('should work', () => + expect( + Array.from( + iteratorToIterable( + (() => { + let value = 0; + + return { next: () => (++value <= 3 ? { done: false, value } : { done: true, value: undefined }) }; + })() + ) + ) + ).toEqual([1, 2, 3])); + + it('Observable should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorToSpliced.js b/packages/integration-test/test/requireNamed/iteratorToSpliced.js new file mode 100644 index 0000000..1af8c54 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorToSpliced.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorToSpliced } = require('iter-fest/iteratorToSpliced'); + +describe('iteratorToSpliced', () => { + it('should work', () => expect(Array.from(iteratorToSpliced([1, 2, 3].values(), 1, 1, 9))).toEqual([1, 9, 3])); +}); diff --git a/packages/integration-test/test/requireNamed/iteratorToString.js b/packages/integration-test/test/requireNamed/iteratorToString.js new file mode 100644 index 0000000..4dcac01 --- /dev/null +++ b/packages/integration-test/test/requireNamed/iteratorToString.js @@ -0,0 +1,6 @@ +const { expect } = require('expect'); +const { iteratorToString } = require('iter-fest/iteratorToString'); + +describe('iteratorToString', () => { + it('should work', () => expect(iteratorToString([1, 2, 3].values())).toBe('1,2,3')); +}); diff --git a/packages/integration-test/test/requireNamed/observable.js b/packages/integration-test/test/requireNamed/observable.js new file mode 100644 index 0000000..5d04964 --- /dev/null +++ b/packages/integration-test/test/requireNamed/observable.js @@ -0,0 +1,21 @@ +const { expect } = require('expect'); +const { Observable } = require('iter-fest/observable'); +const { fake } = require('sinon'); + +describe('Observable', () => { + it('should work', () => { + const next = fake(() => {}); + const complete = fake(() => {}); + + const observable = new Observable(observer => { + observer.next(1); + observer.complete(); + }); + + observable.subscribe({ complete, next }); + + expect(next).toHaveProperty('callCount', 1); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(complete).toHaveProperty('callCount', 1); + }); +}); diff --git a/packages/integration-test/test/requireNamed/observableFromAsync.js b/packages/integration-test/test/requireNamed/observableFromAsync.js new file mode 100644 index 0000000..94e20bf --- /dev/null +++ b/packages/integration-test/test/requireNamed/observableFromAsync.js @@ -0,0 +1,24 @@ +const { expect } = require('expect'); +const { observableFromAsync } = require('iter-fest/observableFromAsync'); +const { fake } = require('sinon'); + +describe('observableFromAsync', () => { + it('should work', async () => { + const observable = observableFromAsync( + (async function* () { + yield 1; + yield 2; + yield 3; + })() + ); + + const next = fake(() => {}); + + await new Promise(resolve => observable.subscribe({ complete: resolve, next })); + + expect(next).toHaveProperty('callCount', 3); + expect(next.getCall(0)).toHaveProperty('args', [1]); + expect(next.getCall(1)).toHaveProperty('args', [2]); + expect(next.getCall(2)).toHaveProperty('args', [3]); + }); +}); diff --git a/packages/integration-test/test/requireNamed/observableSubscribeAsReadable.js b/packages/integration-test/test/requireNamed/observableSubscribeAsReadable.js new file mode 100644 index 0000000..3e58372 --- /dev/null +++ b/packages/integration-test/test/requireNamed/observableSubscribeAsReadable.js @@ -0,0 +1,25 @@ +const { expect } = require('expect'); +const { Observable } = require('iter-fest/observable'); +const { observableSubscribeAsReadable } = require('iter-fest/observableSubscribeAsReadable'); + +describe('observableSubscribeAsReadable', () => { + it('should work', async () => { + const stream = new TextDecoderStream(); + const observable = Observable.from([65, 66, 67]); + const readable = observableSubscribeAsReadable(observable); + const numberToInt8Array = new TransformStream({ + transform(chunk, controller) { + controller.enqueue(Int8Array.from([chunk])); + } + }); + + readable.pipeThrough(numberToInt8Array).pipeTo(stream.writable); + + const reader = stream.readable.getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 'A' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'B' }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 'C' }); + await expect(reader.read()).resolves.toEqual({ done: true }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/observableValues.js b/packages/integration-test/test/requireNamed/observableValues.js new file mode 100644 index 0000000..e3e21f7 --- /dev/null +++ b/packages/integration-test/test/requireNamed/observableValues.js @@ -0,0 +1,16 @@ +const { expect } = require('expect'); +const { Observable } = require('iter-fest/observable'); +const { observableValues } = require('iter-fest/observableValues'); + +describe('observableValues', () => { + it('should work', async () => { + const observable = Observable.from([1, 2, 3]); + const values = []; + + for await (const value of observableValues(observable)) { + values.push(value); + } + + expect(values).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/integration-test/test/requireNamed/readableStreamFrom.js b/packages/integration-test/test/requireNamed/readableStreamFrom.js new file mode 100644 index 0000000..eb423b6 --- /dev/null +++ b/packages/integration-test/test/requireNamed/readableStreamFrom.js @@ -0,0 +1,15 @@ +const { expect } = require('expect'); +const { readableStreamFrom } = require('iter-fest/readableStreamFrom'); + +describe('readableStreamFrom', () => { + it('should work', async () => { + const iterable = [1, 2, 3].values(); + + const reader = readableStreamFrom(iterable).getReader(); + + await expect(reader.read()).resolves.toEqual({ done: false, value: 1 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 2 }); + await expect(reader.read()).resolves.toEqual({ done: false, value: 3 }); + await expect(reader.read()).resolves.toEqual({ done: true, value: undefined }); + }); +}); diff --git a/packages/integration-test/test/requireNamed/readableStreamValues.js b/packages/integration-test/test/requireNamed/readableStreamValues.js new file mode 100644 index 0000000..12a895a --- /dev/null +++ b/packages/integration-test/test/requireNamed/readableStreamValues.js @@ -0,0 +1,22 @@ +const { expect } = require('expect'); +const { readableStreamValues } = require('iter-fest/readableStreamValues'); + +describe('readableStreamValues', () => { + it('should work', async () => { + const readableStream = new ReadableStream({ + start(controller) { + controller.enqueue(1); + controller.enqueue(2); + controller.close(); + } + }); + + const values = []; + + for await (const value of readableStreamValues(readableStream)) { + values.push(value); + } + + expect(values).toEqual([1, 2]); + }); +}); diff --git a/packages/integration-test/test/requireNamed/symbolObservable.js b/packages/integration-test/test/requireNamed/symbolObservable.js new file mode 100644 index 0000000..6107f09 --- /dev/null +++ b/packages/integration-test/test/requireNamed/symbolObservable.js @@ -0,0 +1,11 @@ +const { expect } = require('expect'); +const { Observable } = require('iter-fest/observable'); +const { SymbolObservable } = require('iter-fest/symbolObservable'); + +describe('SymbolObservable', () => { + it('should work', () => { + const observable = new Observable(() => {}); + + expect(observable[SymbolObservable]()).toBe(observable); + }); +}); diff --git a/packages/iter-fest/src/Observable.fromOf.spec.ts b/packages/iter-fest/src/Observable.fromOf.spec.ts index d184c1b..ead3827 100644 --- a/packages/iter-fest/src/Observable.fromOf.spec.ts +++ b/packages/iter-fest/src/Observable.fromOf.spec.ts @@ -6,8 +6,8 @@ import { type Observer, type StartFunction, type Subscription -} from './Observable'; -import type { JestMockOf } from './private/JestMockOf'; +} from './Observable.ts'; +import type { JestMockOf } from './private/JestMockOf.js'; describe('comprehensive', () => { let complete: JestMockOf; diff --git a/packages/iter-fest/src/Observable.spec.ts b/packages/iter-fest/src/Observable.spec.ts index f174cd4..b925b8f 100644 --- a/packages/iter-fest/src/Observable.spec.ts +++ b/packages/iter-fest/src/Observable.spec.ts @@ -7,9 +7,9 @@ import { type StartFunction, type SubscriberFunction, type Subscription -} from './Observable'; -import { SymbolObservable } from './SymbolObservable'; -import type { JestMockOf } from './private/JestMockOf'; +} from './Observable.ts'; +import { SymbolObservable } from './SymbolObservable.ts'; +import type { JestMockOf } from './private/JestMockOf.js'; describe('comprehensive', () => { let complete: JestMockOf; diff --git a/packages/iter-fest/src/Observable.ts b/packages/iter-fest/src/Observable.ts index a82481d..2f4e52f 100644 --- a/packages/iter-fest/src/Observable.ts +++ b/packages/iter-fest/src/Observable.ts @@ -1,7 +1,7 @@ // @ts-expect-error core-js is not typed. -import CoreJSObservable from 'core-js-pure/full/observable'; +import CoreJSObservable from 'core-js-pure/full/observable/index.js'; -import { SymbolObservable } from './SymbolObservable'; +import { SymbolObservable } from './SymbolObservable.ts'; export interface SubscriptionObserver { /** Sends the next value in the sequence */ diff --git a/packages/iter-fest/src/SymbolObservable.ts b/packages/iter-fest/src/SymbolObservable.ts index 42e1942..b9f4f47 100644 --- a/packages/iter-fest/src/SymbolObservable.ts +++ b/packages/iter-fest/src/SymbolObservable.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js is not typed. -import CoreJSSymbolObservable from 'core-js-pure/features/symbol/observable'; +import CoreJSSymbolObservable from 'core-js-pure/features/symbol/observable.js'; const SymbolObservable: unique symbol = CoreJSSymbolObservable; diff --git a/packages/iter-fest/src/asyncIteratorDrop.ts b/packages/iter-fest/src/asyncIteratorDrop.ts index a6fabc4..b840e96 100644 --- a/packages/iter-fest/src/asyncIteratorDrop.ts +++ b/packages/iter-fest/src/asyncIteratorDrop.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import drop from 'core-js-pure/full/async-iterator/drop'; +import drop from 'core-js-pure/full/async-iterator/drop.js'; /** * `drop` takes an integer as an argument. It skips the given number of elements produced by the underlying iterator before itself producing any remaining elements. diff --git a/packages/iter-fest/src/asyncIteratorEvery.ts b/packages/iter-fest/src/asyncIteratorEvery.ts index daa0feb..1a3529d 100644 --- a/packages/iter-fest/src/asyncIteratorEvery.ts +++ b/packages/iter-fest/src/asyncIteratorEvery.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import every from 'core-js-pure/full/async-iterator/every'; +import every from 'core-js-pure/full/async-iterator/every.js'; /** * Determines whether all the members of an iterator satisfy the specified test. diff --git a/packages/iter-fest/src/asyncIteratorFilter.ts b/packages/iter-fest/src/asyncIteratorFilter.ts index 23e8a53..0ff522d 100644 --- a/packages/iter-fest/src/asyncIteratorFilter.ts +++ b/packages/iter-fest/src/asyncIteratorFilter.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import filter from 'core-js-pure/full/async-iterator/filter'; +import filter from 'core-js-pure/full/async-iterator/filter.js'; /** * Returns the elements of an iterator that meet the condition specified in a callback function. diff --git a/packages/iter-fest/src/asyncIteratorFind.ts b/packages/iter-fest/src/asyncIteratorFind.ts index f290706..182ab8d 100644 --- a/packages/iter-fest/src/asyncIteratorFind.ts +++ b/packages/iter-fest/src/asyncIteratorFind.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import find from 'core-js-pure/full/async-iterator/find'; +import find from 'core-js-pure/full/async-iterator/find.js'; /** * Returns the value of the first element in the iterator where predicate is true, and undefined diff --git a/packages/iter-fest/src/asyncIteratorFlatMap.ts b/packages/iter-fest/src/asyncIteratorFlatMap.ts index aa983ad..d1fed81 100644 --- a/packages/iter-fest/src/asyncIteratorFlatMap.ts +++ b/packages/iter-fest/src/asyncIteratorFlatMap.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import flatMap from 'core-js-pure/full/async-iterator/flat-map'; +import flatMap from 'core-js-pure/full/async-iterator/flat-map.js'; /** * `.flatMap` takes a mapping function as an argument. It returns an iterator that produces all elements of the iterators produced by applying the mapping function to the elements produced by the underlying iterator. diff --git a/packages/iter-fest/src/asyncIteratorForEach.ts b/packages/iter-fest/src/asyncIteratorForEach.ts index ea56e26..c6a32b4 100644 --- a/packages/iter-fest/src/asyncIteratorForEach.ts +++ b/packages/iter-fest/src/asyncIteratorForEach.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import forEach from 'core-js-pure/full/async-iterator/for-each'; +import forEach from 'core-js-pure/full/async-iterator/for-each.js'; /** * Performs the specified action for each element in an iterator. diff --git a/packages/iter-fest/src/asyncIteratorFrom.ts b/packages/iter-fest/src/asyncIteratorFrom.ts index 5d32d02..1bc8992 100644 --- a/packages/iter-fest/src/asyncIteratorFrom.ts +++ b/packages/iter-fest/src/asyncIteratorFrom.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import from from 'core-js-pure/full/async-iterator/from'; +import from from 'core-js-pure/full/async-iterator/from.js'; /** * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping "iterator-like" objects with an iterator. diff --git a/packages/iter-fest/src/asyncIteratorMap.ts b/packages/iter-fest/src/asyncIteratorMap.ts index bb5127a..92bde13 100644 --- a/packages/iter-fest/src/asyncIteratorMap.ts +++ b/packages/iter-fest/src/asyncIteratorMap.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import map from 'core-js-pure/full/async-iterator/map'; +import map from 'core-js-pure/full/async-iterator/map.js'; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. diff --git a/packages/iter-fest/src/asyncIteratorReduce.ts b/packages/iter-fest/src/asyncIteratorReduce.ts index 9588730..afd7d35 100644 --- a/packages/iter-fest/src/asyncIteratorReduce.ts +++ b/packages/iter-fest/src/asyncIteratorReduce.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import reduce from 'core-js-pure/full/async-iterator/reduce'; +import reduce from 'core-js-pure/full/async-iterator/reduce.js'; /** * Calls the specified callback function for all the elements in an iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. diff --git a/packages/iter-fest/src/asyncIteratorSome.ts b/packages/iter-fest/src/asyncIteratorSome.ts index 9d04c6f..fa8b9a1 100644 --- a/packages/iter-fest/src/asyncIteratorSome.ts +++ b/packages/iter-fest/src/asyncIteratorSome.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import some from 'core-js-pure/full/async-iterator/some'; +import some from 'core-js-pure/full/async-iterator/some.js'; /** * Determines whether the specified callback function returns true for any element of an iterable. diff --git a/packages/iter-fest/src/asyncIteratorTake.ts b/packages/iter-fest/src/asyncIteratorTake.ts index 115ab90..3159f44 100644 --- a/packages/iter-fest/src/asyncIteratorTake.ts +++ b/packages/iter-fest/src/asyncIteratorTake.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import take from 'core-js-pure/full/async-iterator/take'; +import take from 'core-js-pure/full/async-iterator/take.js'; /** * `take` takes an integer as an argument. It returns an iterator that produces, at most, the given number of elements produced by the underlying iterator. diff --git a/packages/iter-fest/src/asyncIteratorToArray.ts b/packages/iter-fest/src/asyncIteratorToArray.ts index e156f7b..a7fa1fd 100644 --- a/packages/iter-fest/src/asyncIteratorToArray.ts +++ b/packages/iter-fest/src/asyncIteratorToArray.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import toArray from 'core-js-pure/full/async-iterator/to-array'; +import toArray from 'core-js-pure/full/async-iterator/to-array.js'; /** * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method. diff --git a/packages/iter-fest/src/index.ts b/packages/iter-fest/src/index.ts index 8a04f28..dc72f12 100644 --- a/packages/iter-fest/src/index.ts +++ b/packages/iter-fest/src/index.ts @@ -1,50 +1,50 @@ -export * from './Observable'; -export * from './SymbolObservable'; -export * from './asyncGeneratorWithLastValue'; -export * from './asyncIteratorDrop'; -export * from './asyncIteratorEvery'; -export * from './asyncIteratorFilter'; -export * from './asyncIteratorFind'; -export * from './asyncIteratorFlatMap'; -export * from './asyncIteratorForEach'; -export * from './asyncIteratorFrom'; -export * from './asyncIteratorMap'; -export * from './asyncIteratorReduce'; -export * from './asyncIteratorSome'; -export * from './asyncIteratorTake'; -export * from './asyncIteratorToArray'; -export * from './asyncIteratorToAsyncIterable'; -export * from './generatorWithLastValue'; -export * from './iterableWritableStream'; -export * from './iteratorAt'; -export * from './iteratorConcat'; -export * from './iteratorDrop'; -export * from './iteratorEntries'; -export * from './iteratorEvery'; -export * from './iteratorFilter'; -export * from './iteratorFind'; -export * from './iteratorFindIndex'; -export * from './iteratorFindLast'; -export * from './iteratorFindLastIndex'; -export * from './iteratorFlatMap'; -export * from './iteratorForEach'; -export * from './iteratorFrom'; -export * from './iteratorIncludes'; -export * from './iteratorIndexOf'; -export * from './iteratorJoin'; -export * from './iteratorKeys'; -export * from './iteratorMap'; -export * from './iteratorReduce'; -export * from './iteratorSlice'; -export * from './iteratorSome'; -export * from './iteratorTake'; -export * from './iteratorToArray'; -export * from './iteratorToAsync'; -export * from './iteratorToIterable'; -export * from './iteratorToSpliced'; -export * from './iteratorToString'; -export * from './observableFromAsync'; -export * from './observableSubscribeAsReadable'; -export * from './observableValues'; -export * from './readableStreamFrom'; -export * from './readableStreamValues'; +export * from './Observable.js'; +export * from './SymbolObservable.js'; +export * from './asyncGeneratorWithLastValue.js'; +export * from './asyncIteratorDrop.js'; +export * from './asyncIteratorEvery.js'; +export * from './asyncIteratorFilter.js'; +export * from './asyncIteratorFind.js'; +export * from './asyncIteratorFlatMap.js'; +export * from './asyncIteratorForEach.js'; +export * from './asyncIteratorFrom.js'; +export * from './asyncIteratorMap.js'; +export * from './asyncIteratorReduce.js'; +export * from './asyncIteratorSome.js'; +export * from './asyncIteratorTake.js'; +export * from './asyncIteratorToArray.js'; +export * from './asyncIteratorToAsyncIterable.js'; +export * from './generatorWithLastValue.js'; +export * from './iterableWritableStream.js'; +export * from './iteratorAt.js'; +export * from './iteratorConcat.js'; +export * from './iteratorDrop.js'; +export * from './iteratorEntries.js'; +export * from './iteratorEvery.js'; +export * from './iteratorFilter.js'; +export * from './iteratorFind.js'; +export * from './iteratorFindIndex.js'; +export * from './iteratorFindLast.js'; +export * from './iteratorFindLastIndex.js'; +export * from './iteratorFlatMap.js'; +export * from './iteratorForEach.js'; +export * from './iteratorFrom.js'; +export * from './iteratorIncludes.js'; +export * from './iteratorIndexOf.js'; +export * from './iteratorJoin.js'; +export * from './iteratorKeys.js'; +export * from './iteratorMap.js'; +export * from './iteratorReduce.js'; +export * from './iteratorSlice.js'; +export * from './iteratorSome.js'; +export * from './iteratorTake.js'; +export * from './iteratorToArray.js'; +export * from './iteratorToAsync.js'; +export * from './iteratorToIterable.js'; +export * from './iteratorToSpliced.js'; +export * from './iteratorToString.js'; +export * from './observableFromAsync.js'; +export * from './observableSubscribeAsReadable.js'; +export * from './observableValues.js'; +export * from './readableStreamFrom.js'; +export * from './readableStreamValues.js'; diff --git a/packages/iter-fest/src/iteratorDrop.ts b/packages/iter-fest/src/iteratorDrop.ts index 4ad3bad..ea01a50 100644 --- a/packages/iter-fest/src/iteratorDrop.ts +++ b/packages/iter-fest/src/iteratorDrop.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import drop from 'core-js-pure/full/iterator/drop'; +import drop from 'core-js-pure/full/iterator/drop.js'; /** * `drop` takes an integer as an argument. It skips the given number of elements produced by the underlying iterator before itself producing any remaining elements. diff --git a/packages/iter-fest/src/iteratorEvery.ts b/packages/iter-fest/src/iteratorEvery.ts index 57b7707..3c7a0ef 100644 --- a/packages/iter-fest/src/iteratorEvery.ts +++ b/packages/iter-fest/src/iteratorEvery.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import every from 'core-js-pure/full/iterator/every'; +import every from 'core-js-pure/full/iterator/every.js'; /** * Determines whether all the members of an iterator satisfy the specified test. diff --git a/packages/iter-fest/src/iteratorFilter.ts b/packages/iter-fest/src/iteratorFilter.ts index 2aef6c6..d1bbf77 100644 --- a/packages/iter-fest/src/iteratorFilter.ts +++ b/packages/iter-fest/src/iteratorFilter.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import filter from 'core-js-pure/full/iterator/filter'; +import filter from 'core-js-pure/full/iterator/filter.js'; /** * Returns the elements of an iterator that meet the condition specified in a callback function. diff --git a/packages/iter-fest/src/iteratorFind.ts b/packages/iter-fest/src/iteratorFind.ts index c470f51..858a70a 100644 --- a/packages/iter-fest/src/iteratorFind.ts +++ b/packages/iter-fest/src/iteratorFind.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import find from 'core-js-pure/full/iterator/find'; +import find from 'core-js-pure/full/iterator/find.js'; /** * Returns the value of the first element in the iterator where predicate is true, and undefined diff --git a/packages/iter-fest/src/iteratorFlatMap.ts b/packages/iter-fest/src/iteratorFlatMap.ts index 840859e..854494a 100644 --- a/packages/iter-fest/src/iteratorFlatMap.ts +++ b/packages/iter-fest/src/iteratorFlatMap.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import flatMap from 'core-js-pure/full/iterator/flat-map'; +import flatMap from 'core-js-pure/full/iterator/flat-map.js'; /** * `.flatMap` takes a mapping function as an argument. It returns an iterator that produces all elements of the iterators produced by applying the mapping function to the elements produced by the underlying iterator. diff --git a/packages/iter-fest/src/iteratorForEach.ts b/packages/iter-fest/src/iteratorForEach.ts index d39a755..b1f91ce 100644 --- a/packages/iter-fest/src/iteratorForEach.ts +++ b/packages/iter-fest/src/iteratorForEach.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import forEach from 'core-js-pure/full/iterator/for-each'; +import forEach from 'core-js-pure/full/iterator/for-each.js'; /** * Performs the specified action for each element in an iterator. diff --git a/packages/iter-fest/src/iteratorFrom.ts b/packages/iter-fest/src/iteratorFrom.ts index ff9f138..66c2b9e 100644 --- a/packages/iter-fest/src/iteratorFrom.ts +++ b/packages/iter-fest/src/iteratorFrom.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import from from 'core-js-pure/full/iterator/from'; +import from from 'core-js-pure/full/iterator/from.js'; /** * `.from` is a static method (unlike the others listed above) which takes an object as an argument. This method allows wrapping "iterator-like" objects with an iterator. diff --git a/packages/iter-fest/src/iteratorMap.ts b/packages/iter-fest/src/iteratorMap.ts index 133294a..530cfda 100644 --- a/packages/iter-fest/src/iteratorMap.ts +++ b/packages/iter-fest/src/iteratorMap.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import map from 'core-js-pure/full/iterator/map'; +import map from 'core-js-pure/full/iterator/map.js'; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. diff --git a/packages/iter-fest/src/iteratorReduce.ts b/packages/iter-fest/src/iteratorReduce.ts index 7250c6e..656398b 100644 --- a/packages/iter-fest/src/iteratorReduce.ts +++ b/packages/iter-fest/src/iteratorReduce.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import reduce from 'core-js-pure/full/iterator/reduce'; +import reduce from 'core-js-pure/full/iterator/reduce.js'; /** * Calls the specified callback function for all the elements in an iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. diff --git a/packages/iter-fest/src/iteratorSome.ts b/packages/iter-fest/src/iteratorSome.ts index d9fcb35..3f36136 100644 --- a/packages/iter-fest/src/iteratorSome.ts +++ b/packages/iter-fest/src/iteratorSome.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import some from 'core-js-pure/full/iterator/some'; +import some from 'core-js-pure/full/iterator/some.js'; /** * Determines whether the specified callback function returns true for any element of an iterable. diff --git a/packages/iter-fest/src/iteratorTake.ts b/packages/iter-fest/src/iteratorTake.ts index 33faaa4..7d4e654 100644 --- a/packages/iter-fest/src/iteratorTake.ts +++ b/packages/iter-fest/src/iteratorTake.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import take from 'core-js-pure/full/iterator/take'; +import take from 'core-js-pure/full/iterator/take.js'; /** * `take` takes an integer as an argument. It returns an iterator that produces, at most, the given number of elements produced by the underlying iterator. diff --git a/packages/iter-fest/src/iteratorToArray.ts b/packages/iter-fest/src/iteratorToArray.ts index 486f534..f512f01 100644 --- a/packages/iter-fest/src/iteratorToArray.ts +++ b/packages/iter-fest/src/iteratorToArray.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import toArray from 'core-js-pure/full/iterator/to-array'; +import toArray from 'core-js-pure/full/iterator/to-array.js'; /** * When you have a non-infinite iterator which you wish to transform into an array, you can do so with the builtin toArray method. diff --git a/packages/iter-fest/src/iteratorToAsync.ts b/packages/iter-fest/src/iteratorToAsync.ts index 2b2d1b8..1299968 100644 --- a/packages/iter-fest/src/iteratorToAsync.ts +++ b/packages/iter-fest/src/iteratorToAsync.ts @@ -1,5 +1,5 @@ // @ts-expect-error core-js-pure is not typed. -import toAsync from 'core-js-pure/full/iterator/to-async'; +import toAsync from 'core-js-pure/full/iterator/to-async.js'; /** * Converts an iterator into async iterator. diff --git a/packages/iter-fest/src/observableFromAsync.spec.ts b/packages/iter-fest/src/observableFromAsync.spec.ts index 71a8290..4380a9f 100644 --- a/packages/iter-fest/src/observableFromAsync.spec.ts +++ b/packages/iter-fest/src/observableFromAsync.spec.ts @@ -1,8 +1,8 @@ -import type { CompleteFunction, ErrorFunction, NextFunction, Observable, StartFunction } from './Observable'; -import { observableFromAsync } from './observableFromAsync'; +import type { CompleteFunction, ErrorFunction, NextFunction, Observable, StartFunction } from './Observable.ts'; +import { observableFromAsync } from './observableFromAsync.ts'; -import { type JestMockOf } from './private/JestMockOf'; -import withResolvers from './private/withResolvers'; +import { type JestMockOf } from './private/JestMockOf.js'; +import withResolvers from './private/withResolvers.ts'; describe('comprehensive', () => { let complete: JestMockOf; diff --git a/packages/iter-fest/src/observableFromAsync.ts b/packages/iter-fest/src/observableFromAsync.ts index bf12831..48b5150 100644 --- a/packages/iter-fest/src/observableFromAsync.ts +++ b/packages/iter-fest/src/observableFromAsync.ts @@ -1,4 +1,4 @@ -import { Observable } from './Observable'; +import { Observable } from './Observable.ts'; export function observableFromAsync(iterable: AsyncIterable): Observable { return new Observable(subscriber => { diff --git a/packages/iter-fest/src/observableSubscribeAsReadable.spec.ts b/packages/iter-fest/src/observableSubscribeAsReadable.spec.ts index 76997ea..62c73bf 100644 --- a/packages/iter-fest/src/observableSubscribeAsReadable.spec.ts +++ b/packages/iter-fest/src/observableSubscribeAsReadable.spec.ts @@ -1,7 +1,7 @@ -import { Observable, type SubscriberFunction, type SubscriptionObserver } from './Observable'; -import { observableSubscribeAsReadable } from './observableSubscribeAsReadable'; -import type { JestMockOf } from './private/JestMockOf'; -import hasResolved from './private/hasResolved'; +import { Observable, type SubscriberFunction, type SubscriptionObserver } from './Observable.ts'; +import { observableSubscribeAsReadable } from './observableSubscribeAsReadable.ts'; +import type { JestMockOf } from './private/JestMockOf.js'; +import hasResolved from './private/hasResolved.ts'; describe('comprehensive', () => { let observable: Observable; diff --git a/packages/iter-fest/src/observableSubscribeAsReadable.ts b/packages/iter-fest/src/observableSubscribeAsReadable.ts index 486b8e3..b7332c4 100644 --- a/packages/iter-fest/src/observableSubscribeAsReadable.ts +++ b/packages/iter-fest/src/observableSubscribeAsReadable.ts @@ -1,4 +1,4 @@ -import type { Observable, Subscription } from './Observable'; +import type { Observable, Subscription } from './Observable.js'; export function observableSubscribeAsReadable(observable: Observable): ReadableStream { let subscription: Subscription; diff --git a/packages/iter-fest/src/observableValues.spec.ts b/packages/iter-fest/src/observableValues.spec.ts index 7edc5fd..194bee4 100644 --- a/packages/iter-fest/src/observableValues.spec.ts +++ b/packages/iter-fest/src/observableValues.spec.ts @@ -1,6 +1,6 @@ -import { Observable, type SubscriberFunction, type SubscriptionObserver } from './Observable'; -import { observableValues } from './observableValues'; -import type { JestMockOf } from './private/JestMockOf'; +import { Observable, type SubscriberFunction, type SubscriptionObserver } from './Observable.ts'; +import { observableValues } from './observableValues.ts'; +import type { JestMockOf } from './private/JestMockOf.js'; describe('comprehensive', () => { describe('step-by-step', () => { diff --git a/packages/iter-fest/src/observableValues.ts b/packages/iter-fest/src/observableValues.ts index e706bfa..d5a210a 100644 --- a/packages/iter-fest/src/observableValues.ts +++ b/packages/iter-fest/src/observableValues.ts @@ -1,6 +1,6 @@ -import type { Observable } from './Observable'; -import { observableSubscribeAsReadable } from './observableSubscribeAsReadable'; -import { readableStreamValues } from './readableStreamValues'; +import type { Observable } from './Observable.js'; +import { observableSubscribeAsReadable } from './observableSubscribeAsReadable.ts'; +import { readableStreamValues } from './readableStreamValues.ts'; export function observableValues(observable: Observable): AsyncIterableIterator { const readable = observableSubscribeAsReadable(observable); diff --git a/packages/iter-fest/src/private/withResolvers.ts b/packages/iter-fest/src/private/withResolvers.ts index 80cdad2..333c320 100644 --- a/packages/iter-fest/src/private/withResolvers.ts +++ b/packages/iter-fest/src/private/withResolvers.ts @@ -1,5 +1,5 @@ // @ts-expect-error "core-js" is not typed. -import coreJSPromiseWithResolvers from 'core-js-pure/full/promise/with-resolvers'; +import coreJSPromiseWithResolvers from 'core-js-pure/full/promise/with-resolvers.js'; export default function withResolvers(): PromiseWithResolvers { return coreJSPromiseWithResolvers(); diff --git a/packages/iter-fest/src/tsconfig.json b/packages/iter-fest/src/tsconfig.json index ebe1e5a..2221ed4 100644 --- a/packages/iter-fest/src/tsconfig.json +++ b/packages/iter-fest/src/tsconfig.json @@ -1,6 +1,7 @@ // This configuration file is for VSCode only. { "compilerOptions": { + "allowImportingTsExtensions": true, "esModuleInterop": true, "jsx": "react", "module": "ESNext", diff --git a/packages/iter-fest/src/tsconfig.precommit.production.json b/packages/iter-fest/src/tsconfig.precommit.production.json index 40cc24f..da317fd 100644 --- a/packages/iter-fest/src/tsconfig.precommit.production.json +++ b/packages/iter-fest/src/tsconfig.precommit.production.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "allowImportingTsExtensions": true, "esModuleInterop": true, "jsx": "react", "module": "ESNext", diff --git a/packages/iter-fest/src/tsconfig.precommit.test.json b/packages/iter-fest/src/tsconfig.precommit.test.json index 7f4ffb7..8854991 100644 --- a/packages/iter-fest/src/tsconfig.precommit.test.json +++ b/packages/iter-fest/src/tsconfig.precommit.test.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "allowImportingTsExtensions": true, "esModuleInterop": true, "jsx": "react", "module": "ESNext",