Skip to content

Commit

Permalink
style: update linting
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Aug 4, 2024
1 parent e1e6e3e commit 96ff8cc
Show file tree
Hide file tree
Showing 139 changed files with 245 additions and 190 deletions.
6 changes: 3 additions & 3 deletions benchmarks/src/async.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {testIterOps} from './tests/iter-ops';
import {testRXJS} from './tests/rxjs';
import {toAsync} from '../../dist';
import {toAsync} from '../../';

// tslint:disable:no-console

Expand All @@ -16,8 +16,8 @@ const input: AsyncIterable<number> = {
[Symbol.asyncIterator](): AsyncIterator<number> {
const i = data.values();
return {
async next(): Promise<IteratorResult<number>> {
return i.next();
next(): Promise<IteratorResult<number>> {
return Promise.resolve(i.next());
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/tests/iter-ops.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UnknownIterable, filter, map, pipe, toArray} from '../../../dist';
import {type UnknownIterable, filter, map, pipe, toArray} from '../../../';

export async function testIterOps(input: UnknownIterable<number>) {
const start = Date.now();
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/tests/rxjs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UnknownIterable} from '../../../dist';
import type {UnknownIterable} from '../../../';
import {filter, firstValueFrom, from, map, toArray} from 'rxjs';

export async function testRXJS(
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
isIndexed,
isArrayLike
} from './typeguards';
import {$A, $S, UnknownIterable} from './types';
import {$A, $S, type UnknownIterable} from './types';
import {indexedAsyncIterable} from './utils';

/**
Expand Down
21 changes: 13 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {
export type {
AsyncIterableExt,
IErrorContext,
IterableExt,
Expand All @@ -18,7 +18,7 @@ export {pipe, pipeSync, pipeAsync} from './pipe';
export {aggregate} from './ops/aggregate';
export {catchError} from './ops/catch-error';
export {concat} from './ops/concat';
export {concurrencyFork, IConcurrencyWork} from './ops/concurrency-fork';
export {concurrencyFork, type IConcurrencyWork} from './ops/concurrency-fork';
export {consume} from './ops/consume';
export {count} from './ops/count';
export {defaultEmpty} from './ops/default-empty';
Expand All @@ -31,15 +31,15 @@ export {filter} from './ops/filter';
export {first} from './ops/first';
export {flat} from './ops/flat';
export {flatMap} from './ops/flat-map';
export {indexBy, IIndexedValue} from './ops/index-by';
export {indexBy, type IIndexedValue} from './ops/index-by';
export {isEmpty} from './ops/is-empty';
export {last} from './ops/last';
export {map} from './ops/map';
export {
onEnd,
IIterationSummary,
IDuration,
IValueDuration
type IIterationSummary,
type IDuration,
type IValueDuration
} from './ops/on-end';
export {page} from './ops/page';
export {reduce} from './ops/reduce';
Expand All @@ -49,7 +49,12 @@ export {skip} from './ops/skip';
export {skipUntil} from './ops/skip-until';
export {skipWhile} from './ops/skip-while';
export {some} from './ops/some';
export {split, ISplitIndex, ISplitOptions, SplitValueCarry} from './ops/split';
export {
split,
type ISplitIndex,
type ISplitOptions,
SplitValueCarry
} from './ops/split';
export {spread} from './ops/spread';
export {take} from './ops/take';
export {takeLast} from './ops/take-last';
Expand All @@ -58,7 +63,7 @@ export {takeWhile} from './ops/take-while';
export {tap} from './ops/tap';
export {throttle} from './ops/async/throttle';
export {timeout} from './ops/timeout';
export {timing, IValueTiming} from './ops/timing';
export {timing, type IValueTiming} from './ops/timing';
export {toArray} from './ops/to-array';
export {wait} from './ops/async/wait';
export {waitRace} from './ops/async/wait-race';
Expand Down
2 changes: 1 addition & 1 deletion src/ops/aggregate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation} from '../utils';
import {isPromiseLike} from '../typeguards';

Expand Down
2 changes: 1 addition & 1 deletion src/ops/async/delay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, Operation, IterationState} from '../../types';
import {$A, type Operation, type IterationState} from '../../types';
import {createOperation, throwOnSync} from '../../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/async/throttle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, IterationState, Operation} from '../../types';
import {$A, type IterationState, type Operation} from '../../types';
import {createOperation, throwOnSync} from '../../utils';

/**
Expand Down
3 changes: 2 additions & 1 deletion src/ops/async/wait-race.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, Operation} from '../../types';
import {$A, type Operation} from '../../types';
import {isPromiseLike} from '../../typeguards';
import {createOperation, throwOnSync} from '../../utils';

Expand Down Expand Up @@ -114,6 +114,7 @@ export function waitRaceAsync<T>(
},
(err) => {
// handle rejections from calling `i.next()`
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
resolvers.shift()?.(Promise.reject(err));
finished = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ops/async/wait.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, Operation} from '../../types';
import {$A, type Operation} from '../../types';
import {isPromiseLike} from '../../typeguards';
import {createOperation, throwOnSync} from '../../utils';

Expand Down
8 changes: 7 additions & 1 deletion src/ops/catch-error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {$A, $S, IErrorContext, IterationState, Operation} from '../types';
import {
$A,
$S,
type IErrorContext,
type IterationState,
type Operation
} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
8 changes: 4 additions & 4 deletions src/ops/concat.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
$A,
$S,
Value,
SyncValue,
Operation,
UnknownIterableOrIterator
type Value,
type SyncValue,
type Operation,
type UnknownIterableOrIterator
} from '../types';
import {createOperation} from '../utils';
import {isPromiseLike} from '../typeguards';
Expand Down
1 change: 1 addition & 0 deletions src/ops/concurrency-fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function concurrencyForkAsync<T, R>(
return Promise.resolve({value: undefined, done});
}
done = true;
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
return Promise.reject(err); // now catchError operator can handle the error
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/ops/count.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
10 changes: 5 additions & 5 deletions src/ops/default-empty.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
Value,
SyncValue,
UnknownIterable,
UnknownIterator,
Operation,
type Value,
type SyncValue,
type UnknownIterable,
type UnknownIterator,
type Operation,
$S,
$A
} from '../types';
Expand Down
2 changes: 1 addition & 1 deletion src/ops/distinct.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/drain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/empty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/every.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/ops/filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/ops/first.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
8 changes: 7 additions & 1 deletion src/ops/flat-map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {$A, $S, IterationState, Operation, UnknownIterable} from '../types';
import {
$A,
$S,
type IterationState,
type Operation,
type UnknownIterable
} from '../types';
import {createOperation} from '../utils';
import {isPromiseLike} from '../typeguards';

Expand Down
34 changes: 20 additions & 14 deletions src/ops/flat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {$A, $S, Decrement, Operation, UnknownIterable} from '../types';
import {
$A,
$S,
type Decrement,
type Operation,
type UnknownIterable
} from '../types';
import {createOperation} from '../utils';

/**
Expand All @@ -9,19 +15,19 @@ export type Flatten<T, N extends number> =
`${N}` extends `-${string}`
? T
: // N = 0
N extends 0
? T
: // N = 1
N extends 1
? T extends UnknownIterable<infer E>
? E
: T
: // N > 20 or N is unknown
Decrement[number] extends Decrement[N]
? unknown
: T extends UnknownIterable<infer E>
? Flatten<E, Decrement[N]>
: Flatten<T, Decrement[N]>;
N extends 0
? T
: // N = 1
N extends 1
? T extends UnknownIterable<infer E>
? E
: T
: // N > 20 or N is unknown
Decrement[number] extends Decrement[N]
? unknown
: T extends UnknownIterable<infer E>
? Flatten<E, Decrement[N]>
: Flatten<T, Decrement[N]>;

/**
* Expands / flattens sub-iterables up to the specified `depth` (default is 1), with support for `skip` logic.
Expand Down
2 changes: 1 addition & 1 deletion src/ops/index-by.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/ops/is-empty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/last.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/ops/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/on-end.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation, iterateOnce} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/reduce.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {isPromiseLike} from '../typeguards';
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/repeat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
8 changes: 6 additions & 2 deletions src/ops/retry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down Expand Up @@ -153,7 +153,10 @@ function retryAsync<T>(
(e) => {
if (cb) {
const b = (f: any) =>
f ? this.next() : Promise.reject(e);
f
? this.next()
: // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
Promise.reject(e);
const r = cb(
index++,
attempts++,
Expand All @@ -165,6 +168,7 @@ function retryAsync<T>(
leftTries--;
return this.next();
}
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
return Promise.reject(e);
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/ops/skip-until.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/ops/skip-while.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/ops/skip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, Operation} from '../types';
import {$A, $S, type Operation} from '../types';
import {createOperation} from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ops/some.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$A, $S, IterationState, Operation} from '../types';
import {$A, $S, type IterationState, type Operation} from '../types';
import {isPromiseLike} from '../typeguards';
import {createOperation} from '../utils';

Expand Down
Loading

0 comments on commit 96ff8cc

Please sign in to comment.