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", () => {