Skip to content

Commit e13a6d3

Browse files
mattpodwysockimpodwysockitrxcllnt
authored
chore(types): Fixing types (#341)
* chore(types): Fixing types * fix(from/as): Remove from/as as separate factories * fix(from/as): remove iterable from/as * test: fix minification issues affecting tests * chore(sourcemaps): fix sourcemap errors during build * style: asIterable() and asAsyncIterable() -> as() * build(tests): update jest and ts-jest versions Co-authored-by: Matthew Podwysocki <[email protected]> Co-authored-by: ptaylor <[email protected]>
1 parent b06a217 commit e13a6d3

Some content is hidden

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

64 files changed

+732
-879
lines changed

.github/workflows/main.pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
node: [14.x, 16.x, 18.x]
5959
module: [cjs, esm, umd]
6060
target: [es5, es2015, esnext]
61+
exclude:
62+
- {node: 14.x, target: esnext}
6163
steps:
6264
- name: Setup node v${{ matrix.node }}
6365
uses: actions/setup-node@v3

gulp/closure-task.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Symbol.iterator;
162162
Symbol.observable;
163163
/** @type {symbol} */
164164
Symbol.asyncIterator;
165+
/** @type {symbol} */
166+
var symbolObservable = function() {};
165167
`);
166168
}
167169

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@
7070
"eslint-plugin-jest": "26.1.1",
7171
"esm": "https://github.com/jsg2021/esm/releases/download/v3.x.x-pr883/esm-3.x.x-pr883.tgz",
7272
"glob": "7.1.6",
73-
"google-closure-compiler": "20220202.0.0",
73+
"google-closure-compiler": "20220601.0.0",
7474
"gulp": "4.0.2",
7575
"gulp-json-transform": "0.4.7",
7676
"gulp-rename": "2.0.0",
7777
"gulp-sourcemaps": "2.6.5",
7878
"gulp-typescript": "5.0.1",
7979
"husky": "4.2.3",
80-
"jest": "27.5.1",
80+
"jest": "28.1.3",
8181
"jest-environment-node-debug": "2.0.0",
8282
"jest-silent-reporter": "0.5.0",
8383
"json": "9.0.6",
@@ -95,7 +95,7 @@
9595
"source-map-loader": "0.2.4",
9696
"terser": "4.6.4",
9797
"terser-webpack-plugin": "2.3.5",
98-
"ts-jest": "27.1.3",
98+
"ts-jest": "28.0.7",
9999
"ts-node": "8.6.2",
100100
"typedoc": "0.16.10",
101101
"typescript": "4.6.2",

spec/asynciterable-operators/groupby-spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { hasNext, noNext } from '../asynciterablehelpers';
2-
import { empty, from } from 'ix/asynciterable';
2+
import { empty, AsyncIterableX } from 'ix/asynciterable';
33
import { groupBy } from 'ix/asynciterable/operators';
44

55
interface Employee {
@@ -17,7 +17,7 @@ test('AsyncIterable#groupBy normal', async () => {
1717
{ name: 'Lisa', age: 23 },
1818
{ name: 'Eric', age: 42 },
1919
];
20-
const xss = from<Employee, Employee>(xs);
20+
const xss = AsyncIterableX.from<Employee, Employee>(xs);
2121
const ys = xss.pipe(groupBy(async (x) => Math.floor(x.age / 10)));
2222

2323
const it = ys[Symbol.asyncIterator]();
@@ -65,7 +65,7 @@ test('AsyncIterable#groupBy normal can get results later', async () => {
6565
{ name: 'Lisa', age: 23 },
6666
{ name: 'Eric', age: 42 },
6767
];
68-
const xss = from<Employee, Employee>(xs);
68+
const xss = AsyncIterableX.from<Employee, Employee>(xs);
6969
const ys = xss.pipe(groupBy(async (x) => Math.floor(x.age / 10)));
7070

7171
const it = ys[Symbol.asyncIterator]();
@@ -117,7 +117,7 @@ test('AsyncIterable#groupBy empty', async () => {
117117

118118
test('AsyncIterable#groupBy element selector', async () => {
119119
const xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
120-
const xss = from<number, number>(xs);
120+
const xss = AsyncIterableX.from<number, number>(xs);
121121
const ys = xss.pipe(
122122
groupBy(
123123
async (x) => x % 3,

spec/asynciterable-operators/repeat-spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import '../asynciterablehelpers';
22
import { sum } from 'ix/iterable';
3-
import { from, every, of, toArray } from 'ix/asynciterable';
3+
import { as, every, of, toArray } from 'ix/asynciterable';
44
import { buffer, map, repeat, tap, take } from 'ix/asynciterable/operators';
55

66
test('AsyncIterable#repeat infinite', async () => {
@@ -18,7 +18,7 @@ test('AsyncIterable#repeat infinite', async () => {
1818
expect(10).toBe(res.length);
1919
expect(
2020
every(
21-
from(res).pipe(
21+
as(res).pipe(
2222
buffer(2),
2323
map((b) => sum(b))
2424
),
@@ -40,7 +40,7 @@ test('AsyncIterable#repeat finite', async () => {
4040
expect(10).toBe(res.length);
4141
expect(
4242
every(
43-
from(res).pipe(
43+
as(res).pipe(
4444
buffer(2),
4545
map((b) => sum(b))
4646
),

spec/asynciterable-operators/slice-spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { hasNext, noNext } from '../asynciterablehelpers';
22
import { slice } from 'ix/asynciterable/operators';
3-
import { from } from 'ix/asynciterable';
3+
import { as } from 'ix/asynciterable';
44

55
test('AsyncIterable#slice slices at zero with one item', async () => {
6-
const xs = from([1, 2, 3, 4]);
6+
const xs = as([1, 2, 3, 4]);
77
const ys = xs.pipe(slice(0, 1));
88

99
const it = ys[Symbol.asyncIterator]();
@@ -12,7 +12,7 @@ test('AsyncIterable#slice slices at zero with one item', async () => {
1212
});
1313

1414
test('AsyncIterable#slice slices at one with one item', async () => {
15-
const xs = from([1, 2, 3, 4]);
15+
const xs = as([1, 2, 3, 4]);
1616
const ys = xs.pipe(slice(1, 1));
1717

1818
const it = ys[Symbol.asyncIterator]();
@@ -21,7 +21,7 @@ test('AsyncIterable#slice slices at one with one item', async () => {
2121
});
2222

2323
test('AsyncIterable#slice slices at one with multiple items', async () => {
24-
const xs = from([1, 2, 3, 4]);
24+
const xs = as([1, 2, 3, 4]);
2525
const ys = xs.pipe(slice(1, 2));
2626

2727
const it = ys[Symbol.asyncIterator]();
@@ -31,7 +31,7 @@ test('AsyncIterable#slice slices at one with multiple items', async () => {
3131
});
3232

3333
test('AsyncIterable#slice slices at one with no end', async () => {
34-
const xs = from([1, 2, 3, 4]);
34+
const xs = as([1, 2, 3, 4]);
3535
const ys = xs.pipe(slice(1));
3636

3737
const it = ys[Symbol.asyncIterator]();
@@ -42,7 +42,7 @@ test('AsyncIterable#slice slices at one with no end', async () => {
4242
});
4343

4444
test('AsyncIterable#slice slices at zero with no end', async () => {
45-
const xs = from([1, 2, 3, 4]);
45+
const xs = as([1, 2, 3, 4]);
4646
const ys = xs.pipe(slice(0));
4747

4848
const it = ys[Symbol.asyncIterator]();

spec/asynciterable-operators/takeuntil-spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { hasNext, noNext, delayValue } from '../asynciterablehelpers';
22
import { takeUntil } from 'ix/asynciterable/operators';
3-
import { as } from 'ix/asynciterable';
4-
import { AsyncSink } from 'ix/asynciterable';
3+
import { as, AsyncSink } from 'ix/asynciterable';
54

65
test('AsyncIterable#takeUntil hits', async () => {
76
const xs = async function* () {

spec/asynciterable-operators/todomstream-spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '../asynciterablehelpers';
2-
import { from } from 'ix/asynciterable';
2+
import { as } from 'ix/asynciterable';
33
import { map, toDOMStream } from 'ix/asynciterable/operators';
44

55
// eslint-disable-next-line consistent-return
@@ -10,7 +10,7 @@ import { map, toDOMStream } from 'ix/asynciterable/operators';
1010
});
1111
}
1212

13-
const stringsItr = () => from([1, 2, 3]).pipe(map((i) => `${i}`));
13+
const stringsItr = () => as([1, 2, 3]).pipe(map((i) => `${i}`));
1414
const buffersItr = () => stringsItr().pipe(map((val) => Buffer.from(val)));
1515
const objectsItr = () => stringsItr().pipe(map((val) => ({ val })));
1616
const compare = <T>(a: T, b: T) => {
@@ -31,17 +31,17 @@ import { map, toDOMStream } from 'ix/asynciterable/operators';
3131
const expectedObjects = expectedStrings.map((val) => ({ val }));
3232
const expectedBuffers = expectedStrings.map((x) => Buffer.from(x));
3333
test('yields Strings', async () => {
34-
const expected = from(expectedStrings);
34+
const expected = as(expectedStrings);
3535
const actual = stringsItr().pipe(toDOMStream());
3636
await expect(actual).toEqualStream(expected, compare);
3737
});
3838
test('yields Buffers', async () => {
39-
const expected = from(expectedBuffers);
39+
const expected = as(expectedBuffers);
4040
const actual = buffersItr().pipe(toDOMStream());
4141
await expect(actual).toEqualStream(expected, compare);
4242
});
4343
test('yields Objects', async () => {
44-
const expected = from(expectedObjects);
44+
const expected = as(expectedObjects);
4545
const actual = objectsItr().pipe(toDOMStream());
4646
await expect(actual).toEqualStream(expected, compare);
4747
});
@@ -51,14 +51,14 @@ import { map, toDOMStream } from 'ix/asynciterable/operators';
5151
const expectedStrings = ['123'];
5252
const expectedBuffers = expectedStrings.map((x) => Buffer.from(x));
5353
test('yields Strings', async () => {
54-
const expected = from(expectedBuffers);
54+
const expected = as(expectedBuffers);
5555
const actual = stringsItr()
5656
.pipe(map((x) => Buffer.from(x)))
5757
.pipe(toDOMStream({ type: 'bytes' }));
5858
await expect(actual).toEqualStream(expected, compare);
5959
});
6060
test('yields Buffers', async () => {
61-
const expected = from(expectedBuffers);
61+
const expected = as(expectedBuffers);
6262
const actual = buffersItr().pipe(toDOMStream({ type: 'bytes' }));
6363
await expect(actual).toEqualStream(expected, compare);
6464
});
@@ -68,14 +68,14 @@ import { map, toDOMStream } from 'ix/asynciterable/operators';
6868
const expectedStrings = ['123'];
6969
const expectedBuffers = expectedStrings.map((x) => Buffer.from(x));
7070
test('yields Strings', async () => {
71-
const expected = from(expectedBuffers);
71+
const expected = as(expectedBuffers);
7272
const actual = stringsItr()
7373
.pipe(map((x) => Buffer.from(x)))
7474
.pipe(toDOMStream({ type: 'bytes', autoAllocateChunkSize: 1024 }));
7575
await expect(actual).toEqualStream(expected, compare);
7676
});
7777
test('yields Buffers', async () => {
78-
const expected = from(expectedBuffers);
78+
const expected = as(expectedBuffers);
7979
const actual = buffersItr().pipe(
8080
toDOMStream({ type: 'bytes', autoAllocateChunkSize: 1024 })
8181
);

spec/asynciterable/as-spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { hasNext, noNext } from '../asynciterablehelpers';
2-
import { as } from 'ix/asynciterable';
2+
import { AsyncIterableX } from 'ix/asynciterable';
33

44
test('AsyncIterable#as from non-iterable', async () => {
55
const xs = {};
6-
const res = as(xs);
6+
const res = AsyncIterableX.as(xs);
77

88
const it = res[Symbol.asyncIterator]();
99
await hasNext(it, xs);
@@ -12,7 +12,7 @@ test('AsyncIterable#as from non-iterable', async () => {
1212

1313
test('AsyncIterable#as from string emits the string, not chars', async () => {
1414
const x = 'foo';
15-
const res = as(x);
15+
const res = AsyncIterableX.as(x);
1616
const it = res[Symbol.asyncIterator]();
1717
await hasNext(it, x);
1818
await noNext(it);
@@ -24,7 +24,7 @@ test('AsyncIterable#as from promise list', async () => {
2424
Promise.resolve(2),
2525
Promise.resolve(3),
2626
];
27-
const res = as(xs);
27+
const res = AsyncIterableX.as(xs);
2828

2929
const it = res[Symbol.asyncIterator]();
3030
await hasNext(it, 1);
@@ -41,7 +41,7 @@ async function* getData(): AsyncIterable<number> {
4141

4242
test('AsyncIterable#as from async generator', async () => {
4343
const xs = getData();
44-
const res = as(xs);
44+
const res = AsyncIterableX.as(xs);
4545

4646
const it = res[Symbol.asyncIterator]();
4747
await hasNext(it, 1);
@@ -52,7 +52,7 @@ test('AsyncIterable#as from async generator', async () => {
5252

5353
test('AsyncIterable#as from array/iterable', async () => {
5454
const xs = [1, 2, 3];
55-
const res = as(xs);
55+
const res = AsyncIterableX.as(xs);
5656

5757
const it = res[Symbol.asyncIterator]();
5858
await hasNext(it, 1);
@@ -63,15 +63,15 @@ test('AsyncIterable#as from array/iterable', async () => {
6363

6464
test('AsyncIterable#as from empty array/iterable', async () => {
6565
const xs: number[] = [];
66-
const res = as(xs);
66+
const res = AsyncIterableX.as(xs);
6767

6868
const it = res[Symbol.asyncIterator]();
6969
await noNext(it);
7070
});
7171

7272
test('AsyncIterable#as from array-like', async () => {
7373
const xs = { length: 3 };
74-
const res = as(xs);
74+
const res = AsyncIterableX.as(xs);
7575

7676
const it = res[Symbol.asyncIterator]();
7777
await hasNext(it, undefined);
@@ -82,7 +82,7 @@ test('AsyncIterable#as from array-like', async () => {
8282

8383
test('AsyncIterable#as from promise', async () => {
8484
const xs = Promise.resolve(42);
85-
const res = as(xs);
85+
const res = AsyncIterableX.as(xs);
8686

8787
const it = res[Symbol.asyncIterator]();
8888
await hasNext(it, 42);

spec/asynciterable/asasynciterable-spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '../asynciterablehelpers';
2-
import { from } from 'ix/asynciterable';
2+
import { as } from 'ix/asynciterable';
33
import { Readable, ReadableOptions } from 'stream';
44
import { asAsyncIterable } from 'ix/asynciterable/asasynciterable';
55

@@ -34,7 +34,7 @@ import { asAsyncIterable } from 'ix/asynciterable/asasynciterable';
3434
const xs = c.pipe(
3535
asAsyncIterable<string>({ objectMode: true })
3636
);
37-
const expected = from(['1', '2', '3']);
37+
const expected = as(['1', '2', '3']);
3838
await expect(xs).toEqualStream(expected, compare);
3939
});
4040

@@ -43,7 +43,7 @@ import { asAsyncIterable } from 'ix/asynciterable/asasynciterable';
4343
const xs = c.pipe(
4444
asAsyncIterable<string>({ objectMode: false })
4545
);
46-
const expected = from(['123']);
46+
const expected = as(['123']);
4747
await expect(xs).toEqualStream(expected, compare);
4848
});
4949
});

0 commit comments

Comments
 (0)