(
fn: BipedalGenerator<This, T, A>,
bindThis?: This,
)
| 28 | |
| 29 | /* #__NO_SIDE_EFFECTS__ */ |
| 30 | export function bipedal<This, T, A extends unknown[]>( |
| 31 | fn: BipedalGenerator<This, T, A>, |
| 32 | bindThis?: This, |
| 33 | ): { (this: This, ...args: A): MaybePromiseLike<T> } { |
| 34 | function result(this: This, ...args: A): MaybePromiseLike<T> { |
| 35 | const iterator = fn.call( |
| 36 | this, |
| 37 | function* <U>( |
| 38 | value: MaybePromiseLike<U>, |
| 39 | ): Generator< |
| 40 | PromiseLike<U>, |
| 41 | U, |
| 42 | { resolved: U } | { error: unknown } |
| 43 | > { |
| 44 | if (isPromiseLike(value)) { |
| 45 | const result = yield value; |
| 46 | if ("resolved" in result) { |
| 47 | return result.resolved; |
| 48 | } else { |
| 49 | throw result.error; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return value; |
| 54 | }, |
| 55 | ...args, |
| 56 | ) as never; |
| 57 | return advance(iterator, undefined); |
| 58 | } |
| 59 | |
| 60 | if (bindThis) { |
| 61 | return result.bind(bindThis); |
| 62 | } else { |
| 63 | return result; |
| 64 | } |
| 65 | } |
no outgoing calls
no test coverage detected