Comparing version 1.0.0 to 1.1.0
@@ -12,4 +12,3 @@ "use strict"; | ||
AbortController.prototype.abort = function () { | ||
this.signal.aborted = true; | ||
this.signal.dispatchEvent('abort'); | ||
return this.signal.abort(); | ||
}; | ||
@@ -16,0 +15,0 @@ return AbortController; |
import { Event, Listener } from './types'; | ||
declare class AbortSignal { | ||
aborted: boolean; | ||
listeners: Partial<Record<Event, Listener[]>>; | ||
private listeners; | ||
addEventListener(event: Event, listener: Listener): void; | ||
removeEventListener(event: Event, listener: Listener): void; | ||
dispatchEvent(event: Event): boolean; | ||
abort(): void; | ||
} | ||
export default AbortSignal; |
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
/* API */ | ||
/* EVENTS API */ | ||
AbortSignal.prototype.addEventListener = function (event, listener) { | ||
@@ -30,2 +30,9 @@ var listeners = this.listeners[event] || (this.listeners[event] = []); | ||
}; | ||
/* API */ | ||
AbortSignal.prototype.abort = function () { | ||
if (this.aborted) | ||
return; | ||
this.aborted = true; | ||
this.dispatchEvent('abort'); | ||
}; | ||
return AbortSignal; | ||
@@ -32,0 +39,0 @@ }()); |
{ | ||
"name": "aborter", | ||
"description": "A minimal reimplementation of AbortController and AbortSignal.", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "dist/controller.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/controller.d.ts", |
@@ -18,4 +18,3 @@ | ||
this.signal.aborted = true; | ||
this.signal.dispatchEvent ( 'abort' ); | ||
return this.signal.abort (); | ||
@@ -22,0 +21,0 @@ } |
@@ -12,6 +12,6 @@ | ||
aborted: boolean = false; | ||
listeners: Partial<Record<Event, Listener[]>> = {}; | ||
public aborted: boolean = false; | ||
private listeners: Partial<Record<Event, Listener[]>> = {}; | ||
/* API */ | ||
/* EVENTS API */ | ||
@@ -48,2 +48,13 @@ addEventListener ( event: Event, listener: Listener ): void { | ||
/* API */ | ||
abort (): void { | ||
if ( this.aborted ) return; | ||
this.aborted = true; | ||
this.dispatchEvent ( 'abort' ); | ||
} | ||
} | ||
@@ -50,0 +61,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8819
185