From e751b8fff8528b2f92c6fbf997d0fab78cc8e796 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sat, 27 Mar 2021 20:53:10 +0100 Subject: [PATCH] Type corrections --- .gitignore | 4 ++++ package.json | 2 +- src/index.ts | 12 +++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e00d3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/@types/ +/lib/ +/node_modules/ +/package-lock.json diff --git a/package.json b/package.json index ff4c881..3492b15 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "license": "ISC", "dependencies": { "@types/node": "^14.14.19", - "emittery": "^0.8.0" + "emittery": "^0.8.1" }, "devDependencies": { "typescript": "^4.1.3" diff --git a/src/index.ts b/src/index.ts index aade98f..35df517 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import Emittery from "emittery"; -import { promisify } from "util"; //needed to pass information on wether or not the promise has been aborted witout 'this' class AbortableEmittery extends Emittery { @@ -11,19 +10,22 @@ class AbortableEmittery extends Emittery { } } -class AbortablePromise extends Promise { +export default class AbortablePromise extends Promise { private emitter: AbortableEmittery; constructor( make_generator: ( await_or_abort: ( promise: Promise, - on_abort: () => void - ) => Promise + on_abort: () => Promise + ) => Promise ) => AsyncGenerator ) { const emitter = new AbortableEmittery(); - const await_or_abort = (promise: Promise, on_abort: () => void) => { + const await_or_abort = ( + promise: Promise, + on_abort: () => Promise + ) => { return new Promise((resolve, reject) => { let resolved = false; emitter.on("abort", () => {