Last active
January 6, 2023 19:23
-
-
Save MijinkoSD/9bc78b6487b9e54021762e76656a077e to your computer and use it in GitHub Desktop.
非推奨につき使用しないでください。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference no-default-lib="true" /> | |
/// <reference lib="esnext" /> | |
export interface OutsidePromise<Res> { | |
promise: Promise<Res>; | |
resolve: (value: Res) => void; | |
// deno-lint-ignore no-explicit-any | |
reject: (reason?: any) => void; | |
} | |
export function createNewPromise<Res>(): OutsidePromise<Res> { | |
let resolve, reject; | |
const promise = new Promise((res: (value: Res) => void, rej) => { | |
[resolve, reject] = [res, rej]; | |
}); | |
return { | |
promise: promise, | |
resolve: (resolve ? resolve : () => {}), | |
reject: (reject ? reject : () => {}), | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
非推奨につき、こちらのコードは使用しないでください。
もう既に更新もしておりません。
こちらのコードは将来的に削除される可能性がございます。
移行先:https://github.com/MijinkoSD/outsidePromise.ts