0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-25 11:17:50 +01:00
posthog/plugin-server/tests/helpers/promises.ts
James Greenhill 434e379f9a Add 'plugin-server/' from commit '01a99a4e26b0b11f068a7073d6b94e53a7214d33'
git-subtree-dir: plugin-server
git-subtree-mainline: 776b056b6d
git-subtree-split: 01a99a4e26
2021-10-28 14:59:19 -07:00

16 lines
402 B
TypeScript

interface MockPromise<T> {
promise: Promise<T>
resolve: (value?: any) => void
reject: (error: any) => void
}
export function createPromise<T = void>(): MockPromise<T> {
const result: Partial<MockPromise<T>> = {}
result.promise = new Promise<T>((_resolve, _reject) => {
result.resolve = _resolve
result.reject = _reject
})
return result as MockPromise<T>
}