@inheritdoc
(
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,
)
| 56 | |
| 57 | /** @inheritdoc */ |
| 58 | public then<TResult1 = T, TResult2 = never>( |
| 59 | onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, |
| 60 | onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null, |
| 61 | ): PromiseLike<TResult1 | TResult2> { |
| 62 | return new SyncPromise((resolve, reject) => { |
| 63 | this._handlers.push([ |
| 64 | false, |
| 65 | result => { |
| 66 | if (!onfulfilled) { |
| 67 | // TODO: ¯\_(ツ)_/¯ |
| 68 | // TODO: FIXME |
| 69 | resolve(result as any); |
| 70 | } else { |
| 71 | try { |
| 72 | resolve(onfulfilled(result)); |
| 73 | } catch (e) { |
| 74 | reject(e); |
| 75 | } |
| 76 | } |
| 77 | }, |
| 78 | reason => { |
| 79 | if (!onrejected) { |
| 80 | reject(reason); |
| 81 | } else { |
| 82 | try { |
| 83 | resolve(onrejected(reason)); |
| 84 | } catch (e) { |
| 85 | reject(e); |
| 86 | } |
| 87 | } |
| 88 | }, |
| 89 | ]); |
| 90 | this._executeHandlers(); |
| 91 | }); |
| 92 | } |
| 93 | |
| 94 | /** @inheritdoc */ |
| 95 | public catch<TResult = never>( |