Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Jul 11, 2023
1 parent 4ccb7be commit 1224b8c
Show file tree
Hide file tree
Showing 160 changed files with 4,246 additions and 3,829 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const input = [1, 2, 3, 4, 5];
const i = pipe(
input,
filter((a) => a % 2 === 0), // find even numbers
map((value) => ({value})) // remap into objects
map((value) => ({value})), // remap into objects
);

console.log(...i); //=> {value: 2}, {value: 4}
Expand All @@ -50,7 +50,7 @@ const input = [1, 2, 2, 3, 3, 4];
const i = pipe(
toAsync(input), // make asynchronous
distinct(), // emit unique numbers
delay(1000) // delay each value by 1s
delay(1000), // delay each value by 1s
);
// or you can replace `pipe` + `toAsync` with just `pipeAsync`

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/tests/iter-ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function testIterOps(input: UnknownIterable<number>) {
input,
filter((a) => a % 2 === 0),
map((b) => ({value: b})),
toArray()
toArray(),
);
const {length} = (await i.first)!;
const duration = Date.now() - start;
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/tests/rxjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {filter, firstValueFrom, from, map, toArray} from 'rxjs';

export async function testRXJS(
input: UnknownIterable<number>,
withSubscription?: boolean
withSubscription?: boolean,
) {
const start = Date.now();
const i = from(input).pipe(
filter((a) => a % 2 === 0),
map((b) => ({value: b})),
toArray()
toArray(),
);
if (withSubscription) {
// key to measuring RXJS correctly;
Expand Down
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iter-ops",
"version": "3.0.7",
"version": "3.0.8",
"description": "Basic operations on iterables",
"keywords": [
"typescript",
Expand Down Expand Up @@ -65,39 +65,39 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@rollup/plugin-node-resolve": "15.0.1",
"@rollup/plugin-typescript": "10.0.1",
"@types/chai": "4.3.4",
"@types/estree": "1.0.0",
"@rollup/plugin-node-resolve": "15.1.0",
"@rollup/plugin-typescript": "11.1.2",
"@types/chai": "4.3.5",
"@types/estree": "1.0.1",
"@types/mocha": "10.0.1",
"@types/node": "18.11.17",
"@types/node": "20.4.1",
"@types/rollup-plugin-auto-external": "2.0.2",
"@typescript-eslint/eslint-plugin": "5.47.0",
"@typescript-eslint/parser": "5.47.0",
"@typescript-eslint/eslint-plugin": "6.0.0",
"@typescript-eslint/parser": "6.0.0",
"chai": "4.3.7",
"cross-env": "7.0.3",
"cspell": "6.18.0",
"eslint": "8.30.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"cspell": "6.31.1",
"eslint": "8.44.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "5.0.0",
"mocha": "10.2.0",
"nyc": "15.1.0",
"prettier": "2.8.1",
"prettier-plugin-packagejson": "2.3.0",
"rimraf": "3.0.2",
"prettier": "3.0.0",
"prettier-plugin-packagejson": "2.4.5",
"rimraf": "5.0.1",
"rollup": "2.79.1",
"rollup-plugin-auto-external": "2.0.0",
"rollup-plugin-dts": "4.2.3",
"rollup-plugin-dts": "5.3.0",
"rollup-plugin-gzip": "3.1.0",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-terser": "6.1.0",
"ts-node": "10.9.1",
"tsd": "0.25.0",
"tslib": "2.4.1",
"typedoc": "0.23.23",
"typescript": "4.9.4"
"tsd": "0.28.1",
"tslib": "2.6.0",
"typedoc": "0.24.8",
"typescript": "5.1.6"
},
"packageManager": "yarn@3.2.4",
"engines": {
"node": ">=14"
"node": ">=16"
}
}
4 changes: 2 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function toIterable<T>(i: unknown) {
export function reverse<T>(input: ArrayLike<T>): Iterable<T> {
if (typeof input?.length !== 'number') {
throw new TypeError(
`An array-like value was expected: ${JSON.stringify(input)}`
`An array-like value was expected: ${JSON.stringify(input)}`,
);
}
return {
Expand Down Expand Up @@ -261,7 +261,7 @@ function toSyncIterable<T>(value: T): Iterable<T> {
* Create an async iterable that has the awaited given value as its only element.
*/
function toSingleAsyncIterable<T>(
asyncValue: PromiseLike<T>
asyncValue: PromiseLike<T>,
): AsyncIterable<T> {
return {
[$A](): AsyncIterator<T> {
Expand Down
6 changes: 3 additions & 3 deletions src/ops/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {isPromiseLike} from '../typeguards';
* @category Sync+Async
*/
export function aggregate<T, R>(
cb: (arr: T[]) => R | Promise<R>
cb: (arr: T[]) => R | Promise<R>,
): Operation<T, R>;

export function aggregate(...args: unknown[]) {
Expand All @@ -41,7 +41,7 @@ export function aggregate(...args: unknown[]) {

function aggregateSync<T, R>(
iterable: Iterable<T>,
cb: (arr: T[]) => R
cb: (arr: T[]) => R,
): Iterable<R> {
return {
[$S](): Iterator<R> {
Expand All @@ -67,7 +67,7 @@ function aggregateSync<T, R>(

function aggregateAsync<T, R>(
iterable: AsyncIterable<T>,
cb: (arr: T[]) => R | Promise<R>
cb: (arr: T[]) => R | Promise<R>,
): AsyncIterable<R> {
return {
[$A](): AsyncIterator<R> {
Expand Down
8 changes: 4 additions & 4 deletions src/ops/async/delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function delay<T>(timeout: number): Operation<T, T>;
* @category Async-only
*/
export function delay<T>(
cb: (value: T, index: number, state: IterationState) => number
cb: (value: T, index: number, state: IterationState) => number,
): Operation<T, T>;

export function delay(...args: unknown[]) {
Expand All @@ -52,12 +52,12 @@ function delayAsync<T>(
iterable: AsyncIterable<T>,
timeout:
| number
| ((value: T, index: number, state: IterationState) => number)
| ((value: T, index: number, state: IterationState) => number),
): AsyncIterable<T> {
return {
[$A](): AsyncIterator<T> {
const i = iterable[$A]();
if (timeout < 0) {
if (typeof timeout === 'number' && timeout < 0) {
return i; // use no delay;
}
const cb = typeof timeout === 'function' && timeout;
Expand All @@ -75,7 +75,7 @@ function delayAsync<T>(
return delay < 0
? a
: new Promise((resolve) =>
setTimeout(() => resolve(a), delay)
setTimeout(() => resolve(a), delay),
);
});
},
Expand Down
12 changes: 6 additions & 6 deletions src/ops/async/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export function retry<T>(
cb: (
index: number,
attempts: number,
state: IterationState
) => boolean | Promise<boolean>
state: IterationState,
) => boolean | Promise<boolean>,
): Operation<T, T>;

export function retry(...args: unknown[]) {
Expand All @@ -74,8 +74,8 @@ function retryAsync<T>(
| ((
index: number,
attempts: number,
state: IterationState
) => boolean | Promise<boolean>)
state: IterationState,
) => boolean | Promise<boolean>),
): AsyncIterable<T> {
return {
[$A](): AsyncIterator<T> {
Expand All @@ -102,7 +102,7 @@ function retryAsync<T>(
const r = cb(
index,
attempts++,
state
state,
) as Promise<boolean>;
return isPromiseLike(r) ? r.then(b) : b(r);
}
Expand All @@ -111,7 +111,7 @@ function retryAsync<T>(
return this.next();
}
return Promise.reject(e);
}
},
);
},
};
Expand Down
6 changes: 3 additions & 3 deletions src/ops/async/throttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {createOperation, throwOnSync} from '../../utils';
* @category Async-only
*/
export function throttle<T>(
cb: (value: T, index: number, state: IterationState) => Promise<any>
cb: (value: T, index: number, state: IterationState) => Promise<any>,
): Operation<T, T>;

export function throttle(...args: unknown[]) {
Expand All @@ -36,7 +36,7 @@ export function throttle(...args: unknown[]) {

function throttleAsync<T>(
iterable: AsyncIterable<T>,
cb: (value: T, index: number, state: IterationState) => Promise<any>
cb: (value: T, index: number, state: IterationState) => Promise<any>,
): AsyncIterable<T> {
return {
[$A](): AsyncIterator<T> {
Expand All @@ -50,7 +50,7 @@ function throttleAsync<T>(
.then((a) =>
a.done
? a
: cb(a.value, index++, state).then(() => a)
: cb(a.value, index++, state).then(() => a),
);
},
};
Expand Down
12 changes: 6 additions & 6 deletions src/ops/async/wait-race.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function waitRace(...args: unknown[]) {
// implemented by: https://stackoverflow.com/users/1048572/bergi
export function waitRaceAsync<T>(
iterable: AsyncIterable<Promise<T> | T>,
cacheSize: number
cacheSize: number,
): AsyncIterable<T> {
cacheSize = cacheSize >= 2 ? cacheSize : 1;
return {
Expand All @@ -75,7 +75,7 @@ export function waitRaceAsync<T>(
let finished = false;
// resolvers for currently active tasks, that are racing to remove and call the first one:
const resolvers: ((
res: IteratorResult<T> | Promise<never>
res: IteratorResult<T> | Promise<never>,
) => void)[] = [];
// cache of promises to be resolved or to be returned by `.next()` to the destination:
const promises: Promise<IteratorResult<T>>[] = [];
Expand All @@ -101,10 +101,10 @@ export function waitRaceAsync<T>(
},
() => {
resolvers.shift()?.(
promise as Promise<never>
promise as Promise<never>,
);
kickOffMore();
}
},
);
} else {
resolvers.shift()?.(a as IteratorResult<T>);
Expand All @@ -115,9 +115,9 @@ export function waitRaceAsync<T>(
// handle rejections from calling `i.next()`
resolvers.shift()?.(Promise.reject(err));
finished = true;
}
},
);
})
}),
);
}
function kickOffMore() {
Expand Down
2 changes: 1 addition & 1 deletion src/ops/async/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function wait() {
}

export function waitAsync<T>(
iterable: AsyncIterable<Promise<T> | T>
iterable: AsyncIterable<Promise<T> | T>,
): AsyncIterable<T> {
return {
[$A](): AsyncIterator<T> {
Expand Down
8 changes: 4 additions & 4 deletions src/ops/catch-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {createOperation} from '../utils';
* @category Diagnostics
*/
export function catchError<T>(
cb: (error: any, ctx: IErrorContext<T>) => void
cb: (error: any, ctx: IErrorContext<T>) => void,
): Operation<T, T>;

export function catchError(...args: unknown[]) {
Expand All @@ -64,7 +64,7 @@ export function catchError(...args: unknown[]) {

function catchErrorSync<T>(
iterable: Iterable<T>,
cb: (error: any, ctx: IErrorContext<T>) => void
cb: (error: any, ctx: IErrorContext<T>) => void,
): Iterable<T> {
return {
[$S](): Iterator<T> {
Expand Down Expand Up @@ -111,7 +111,7 @@ function catchErrorSync<T>(

function catchErrorAsync<T>(
iterable: AsyncIterable<T>,
cb: (error: any, ctx: IErrorContext<T>) => void
cb: (error: any, ctx: IErrorContext<T>) => void,
): AsyncIterable<T> {
return {
[$A](): AsyncIterator<T> {
Expand Down Expand Up @@ -144,7 +144,7 @@ function catchErrorAsync<T>(
},
});
return emitted ? {value, done: false} : this.next();
}
},
);
},
};
Expand Down
6 changes: 3 additions & 3 deletions src/ops/concurrency-fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface IConcurrencyWork<T, R> {
* @category Sync+Async
*/
export function concurrencyFork<T, R = T>(
work: IConcurrencyWork<T, R>
work: IConcurrencyWork<T, R>,
): Operation<T, R>;

export function concurrencyFork(...args: unknown[]) {
Expand All @@ -86,7 +86,7 @@ export function concurrencyFork(...args: unknown[]) {

function concurrencyForkSync<T, R>(
iterable: Iterable<T>,
work: IConcurrencyWork<T, R>
work: IConcurrencyWork<T, R>,
): Iterable<R> {
try {
return work.onSync?.(iterable) ?? (iterable as Iterable<any>);
Expand All @@ -110,7 +110,7 @@ function concurrencyForkSync<T, R>(

function concurrencyForkAsync<T, R>(
iterable: AsyncIterable<T>,
work: IConcurrencyWork<T, R>
work: IConcurrencyWork<T, R>,
): AsyncIterable<R> {
try {
return work.onAsync?.(iterable) ?? (iterable as AsyncIterable<any>);
Expand Down
6 changes: 3 additions & 3 deletions src/ops/consume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {isPromiseLike} from '../typeguards';
* @category Sync+Async
*/
export function consume<T, R>(
consumer: (data: UnknownIterable<T>, sync: boolean) => R | Promise<R>
consumer: (data: UnknownIterable<T>, sync: boolean) => R | Promise<R>,
): Operation<T, R>;

export function consume(...args: unknown[]) {
Expand All @@ -36,7 +36,7 @@ export function consume(...args: unknown[]) {

function consumeSync<T, R>(
iterable: Iterable<T>,
consumer: (data: Iterable<T>, sync: boolean) => R
consumer: (data: Iterable<T>, sync: boolean) => R,
): Iterable<R> {
return {
[$S](): Iterator<R> {
Expand All @@ -56,7 +56,7 @@ function consumeSync<T, R>(

function consumeAsync<T, R>(
iterable: AsyncIterable<T>,
consumer: (data: AsyncIterable<T>, sync: boolean) => R | Promise<R>
consumer: (data: AsyncIterable<T>, sync: boolean) => R | Promise<R>,
): AsyncIterable<R> {
return {
[$A](): AsyncIterator<R> {
Expand Down

0 comments on commit 1224b8c

Please sign in to comment.