Skip to content

Commit

Permalink
introduce a named type to represent the untyped teardown function to …
Browse files Browse the repository at this point in the history
…be exported with the public API
  • Loading branch information
shtaif committed Sep 4, 2023
1 parent b07fbea commit aeb5d52
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import {
iterified,
type Iterified,
type ExecutorFunction,

Check failure on line 3 in src/index.ts

View workflow job for this annotation

GitHub Actions / ts_build_test

Module '"./iterified"' has no exported member 'ExecutorFunction'.

Check failure on line 3 in src/index.ts

View workflow job for this annotation

GitHub Actions / run_tests

Module '"./iterified"' has no exported member 'ExecutorFunction'.
type IterifiedIterable,
type IterifiedIterator,
type ExecutorFn,
type Iterified,
} from './iterified';
import { iterifiedUnwrapped, type IterifiedUnwrapped } from './iterifiedUnwrapped';
import { type ExecutorFn } from './utils/types/ExecutorFn';

export {
iterified,
iterifiedUnwrapped,
type ExecutorFn,
type Iterified,
type ExecutorFunction,
type IterifiedIterable,
type IterifiedUnwrapped,
type IterifiedIterator,
type ExecutorFn,
type Iterified,
};

// TODO: Should implement such that when an instance is ended (or all has all its active iterators closed), it can always be reinitialized by just consuming it again, similarly with RxJS observables?
Expand Down
16 changes: 11 additions & 5 deletions src/iterified.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type MaybePromise } from './utils/types/MaybePromise';
import { MulticastChannel, createMulticastChannel } from './utils/createMulticastChannel';
import { type ExecutorFn } from './utils/types/ExecutorFn';

export {
iterified,
Expand Down Expand Up @@ -97,6 +97,10 @@ function iterified<TNext>(executorFn: ExecutorFn<TNext>): IterifiedIterable<TNex
}
}

type IterifiedIterable<TNextValue, TDoneValue = undefined | void> = {
[Symbol.asyncIterator](): IterifiedIterator<TNextValue, TDoneValue>;
};

/**
* @deprecated This type is deprecated - use {@link IterifiedIterable} instead.
* @see {@link IterifiedIterable}
Expand All @@ -106,11 +110,13 @@ type Iterified<TNextValue, TDoneValue = undefined | void> = IterifiedIterable<
TDoneValue
>;

type IterifiedIterable<TNextValue, TDoneValue = undefined | void> = {
[Symbol.asyncIterator](): IterifiedIterator<TNextValue, TDoneValue>;
};

type IterifiedIterator<TNextValue, TDoneValue = undefined | void> = {
next(): Promise<IteratorResult<TNextValue, TDoneValue>>;
return(): Promise<IteratorReturnResult<TDoneValue>>;
};

type ExecutorFn<TNext> = (
nextCb: (nextValue: TNext) => void,
doneCb: () => void,
errorCb: (error: unknown) => void
) => MaybePromise<void | (() => MaybePromise<void>)>;
9 changes: 0 additions & 9 deletions src/utils/types/ExecutorFn.ts

This file was deleted.

0 comments on commit aeb5d52

Please sign in to comment.