Skip to content

Instantly share code, notes, and snippets.

@MijinkoSD
Last active January 6, 2023 19:23
Show Gist options
  • Save MijinkoSD/9bc78b6487b9e54021762e76656a077e to your computer and use it in GitHub Desktop.
Save MijinkoSD/9bc78b6487b9e54021762e76656a077e to your computer and use it in GitHub Desktop.
非推奨につき使用しないでください。
/// <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 : () => {}),
};
}
@MijinkoSD
Copy link
Author

MijinkoSD commented Jan 6, 2023

非推奨につき、こちらのコードは使用しないでください。
もう既に更新もしておりません。
こちらのコードは将来的に削除される可能性がございます。

移行先:https://github.com/MijinkoSD/outsidePromise.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment