Skip to content

Commit

Permalink
rm iterator option
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Nov 29, 2023
1 parent 867a591 commit dccc3ac
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ function isIterable<T>(it: unknown): it is Iterable<T> {
* @param operator the operation, promise, async function, or generator funnction to call as part of this operation
*/
export function call<T>(callable: () => Operation<T>): Operation<T>;
export function call<T>(callable: () => Iterator<T>): Operation<T>;
export function call<T>(callable: () => Promise<T>): Operation<T>;
export function call<T>(callable: () => T): Operation<T>;
export function call<T>(callable: Operation<T>): Operation<T>;
export function call<T>(callable: Iterator<T>): Operation<T>;
export function call<T>(callable: Promise<T>): Operation<T>;
export function call<T>(callable: T): Operation<T>;
export function call<T>(callable: Callable<T>): Operation<T> {
return action(function* (resolve, reject) {
try {
if (typeof callable === "function") {
let fn = callable as () => Operation<T> | Iterator<T> | Promise<T> | T;
let fn = callable as () => Operation<T> | Promise<T> | T;
resolve(yield* toop(fn()));
} else {
resolve(yield* toop(callable));
Expand All @@ -86,7 +84,7 @@ export function call<T>(callable: Callable<T>): Operation<T> {
}

function toop<T>(
op: Operation<T> | Iterator<T> | Promise<T> | T,
op: Operation<T> | Promise<T> | T,
): Operation<T> {
if (isPromise(op)) {
return expect(op);
Expand Down Expand Up @@ -121,10 +119,8 @@ function expect<T>(promise: Promise<T>): Operation<T> {

export type Callable<T> =
| Operation<T>
| Iterator<T>
| Promise<T>
| T
| (() => Operation<T>)
| (() => Iterator<T>)
| (() => Promise<T>)
| (() => T);

0 comments on commit dccc3ac

Please sign in to comment.