Revert "Refactor outbound delivery state"

This reverts commit 9c48a95eb5.
This commit is contained in:
Fedor Indutny 2021-07-12 16:51:45 -07:00 committed by GitHub
parent 77668c3247
commit ad217c808d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 694 additions and 3197 deletions

View file

@ -119,9 +119,6 @@ export function groupBy<T>(
return result;
}
export const isEmpty = (iterable: Iterable<unknown>): boolean =>
Boolean(iterable[Symbol.iterator]().next().done);
export function map<T, ResultT>(
iterable: Iterable<T>,
fn: (value: T) => ResultT
@ -170,33 +167,6 @@ export function reduce<T, TResult>(
return result;
}
export function repeat<T>(value: T): Iterable<T> {
return new RepeatIterable(value);
}
class RepeatIterable<T> implements Iterable<T> {
constructor(private readonly value: T) {}
[Symbol.iterator](): Iterator<T> {
return new RepeatIterator(this.value);
}
}
class RepeatIterator<T> implements Iterator<T> {
private readonly iteratorResult: IteratorResult<T>;
constructor(value: Readonly<T>) {
this.iteratorResult = {
done: false,
value,
};
}
next(): IteratorResult<T> {
return this.iteratorResult;
}
}
export function take<T>(iterable: Iterable<T>, amount: number): Iterable<T> {
return new TakeIterable(iterable, amount);
}
@ -224,29 +194,3 @@ class TakeIterator<T> implements Iterator<T> {
return nextIteration;
}
}
// In the future, this could support number and symbol property names.
export function zipObject<ValueT>(
props: Iterable<string>,
values: Iterable<ValueT>
): Record<string, ValueT> {
const result: Record<string, ValueT> = {};
const propsIterator = props[Symbol.iterator]();
const valuesIterator = values[Symbol.iterator]();
// eslint-disable-next-line no-constant-condition
while (true) {
const propIteration = propsIterator.next();
if (propIteration.done) {
break;
}
const valueIteration = valuesIterator.next();
if (valueIteration.done) {
break;
}
result[propIteration.value] = valueIteration.value;
}
return result;
}