Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Commit

Permalink
Remove duplicate code in test file (#1976)
Browse files Browse the repository at this point in the history
  • Loading branch information
snario authored and cf19drofxots committed Jul 23, 2019
1 parent 6f70c4a commit e730d77
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions packages/node/test/machine/integration/message-router.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
import { Deferred } from "../../../src/deferred";
import { Opcode } from "../../../src/machine";

import { MiniNode } from "./mininode";

/// copied from node
/// see also: https://twitter.com/joseph_silber/status/809176159858655234
class Deferred<T> {
private internalPromise: Promise<T>;
private internalResolve!: (value?: T | PromiseLike<T>) => void;
private internalReject!: (reason?: any) => void;

constructor() {
this.internalPromise = new Promise<T>((resolve, reject) => {
this.internalResolve = resolve;
this.internalReject = reject;
});
}

get promise(): Promise<T> {
return this.internalPromise;
}

resolve = (value?: T | PromiseLike<T>): void => {
this.internalResolve(value);
};

reject = (reason?: any): void => {
this.internalReject(reason);
};
}

export class MessageRouter {
private nodesMap: Map<string, MiniNode>;
private deferrals: Map<string, Deferred<any>>;
Expand Down

0 comments on commit e730d77

Please sign in to comment.