diff options
Diffstat (limited to 'cli/js/workers_test.ts')
-rw-r--r-- | cli/js/workers_test.ts | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/cli/js/workers_test.ts b/cli/js/workers_test.ts index 7dbd316ec..5b8b1ef97 100644 --- a/cli/js/workers_test.ts +++ b/cli/js/workers_test.ts @@ -1,23 +1,11 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test, testPerm, assert, assertEquals } from "./test_util.ts"; - -export interface ResolvableMethods<T> { - resolve: (value?: T | PromiseLike<T>) => void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - reject: (reason?: any) => void; -} - -export type Resolvable<T> = Promise<T> & ResolvableMethods<T>; - -export function createResolvable<T>(): Resolvable<T> { - let methods: ResolvableMethods<T>; - const promise = new Promise<T>((resolve, reject): void => { - methods = { resolve, reject }; - }); - // TypeScript doesn't know that the Promise callback occurs synchronously - // therefore use of not null assertion (`!`) - return Object.assign(promise, methods!) as Resolvable<T>; -} +import { + test, + testPerm, + assert, + assertEquals, + createResolvable +} from "./test_util.ts"; test(async function workersBasic(): Promise<void> { const promise = createResolvable(); |