Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aborter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aborter - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

5

dist/controller.js

@@ -11,3 +11,6 @@ /* IMPORT */

abort() {
return this.signal.abort();
if (this.signal.aborted)
return;
this.signal.aborted = true;
this.signal.dispatchEvent('abort');
}

@@ -14,0 +17,0 @@ }

1

dist/signal.d.ts

@@ -8,4 +8,3 @@ import type { Event, Listener } from './types';

dispatchEvent(event: Event): boolean;
abort(): void;
}
export default AbortSignal;

@@ -7,31 +7,23 @@ /* IMPORT */

this.aborted = false;
this.listeners = {};
this.listeners = new Set();
}
/* EVENTS API */
addEventListener(event, listener) {
const listeners = this.listeners[event] || (this.listeners[event] = []);
listeners.push(listener);
if (event !== 'abort')
return;
this.listeners.add(listener);
}
removeEventListener(event, listener) {
const listeners = this.listeners[event];
if (!listeners)
if (event !== 'abort')
return;
listeners.splice(listeners.indexOf(listener), 1);
this.listeners.delete(listener);
}
dispatchEvent(event) {
const listeners = this.listeners[event];
if (!listeners)
return true;
listeners.slice().forEach(listener => listener());
if (event !== 'abort')
return false;
[...this.listeners].forEach(listener => listener());
return true;
}
/* API */
abort() {
if (this.aborted)
return;
this.aborted = true;
this.dispatchEvent('abort');
}
}
/* EXPORT */
export default AbortSignal;

@@ -1,3 +0,3 @@

declare type Event = 'abort';
declare type Listener = () => void;
type Event = 'abort';
type Listener = () => void;
export type { Event, Listener };

@@ -5,3 +5,3 @@ {

"description": "A minimal reimplementation of AbortController and AbortSignal.",
"version": "2.0.0",
"version": "3.0.0",
"type": "module",

@@ -17,3 +17,3 @@ "main": "dist/index.js",

"test:watch": "tsex test --watch",
"prepublishOnly": "npm run clean && npm run compile && npm run test"
"prepublishOnly": "tsex prepare"
},

@@ -29,6 +29,6 @@ "keywords": [

"devDependencies": {
"fava": "^0.0.6",
"tsex": "^1.1.1",
"typescript": "^4.6.3"
"fava": "^0.1.0",
"tsex": "^2.1.0",
"typescript": "^4.9.5"
}
}

@@ -5,3 +5,3 @@ # Aborter

This library is only 0.8kb minified, but it's not strictly spec-compliant, if you need that go with [`abort-controller`](https://www.npmjs.com/package/abort-controller).
This library is only 0.5kb minified, but it's not strictly spec-compliant, if you need that go with [`abort-controller`](https://www.npmjs.com/package/abort-controller).

@@ -8,0 +8,0 @@ ## Install

@@ -12,3 +12,3 @@

signal: AbortSignal = new AbortSignal ();
public signal: AbortSignal = new AbortSignal ();

@@ -19,4 +19,7 @@ /* API */

return this.signal.abort ();
if ( this.signal.aborted ) return;
this.signal.aborted = true;
this.signal.dispatchEvent ( 'abort' );
}

@@ -23,0 +26,0 @@

@@ -13,3 +13,3 @@

public aborted: boolean = false;
private listeners: Partial<Record<Event, Listener[]>> = {};
private listeners: Set<Listener> = new Set ();

@@ -20,5 +20,5 @@ /* EVENTS API */

const listeners = this.listeners[event] || ( this.listeners[event] = [] );
if ( event !== 'abort' ) return;
listeners.push ( listener );
this.listeners.add ( listener );

@@ -29,8 +29,6 @@ }

const listeners = this.listeners[event];
if ( event !== 'abort' ) return;
if ( !listeners ) return;
this.listeners.delete ( listener );
listeners.splice ( listeners.indexOf ( listener ), 1 );
}

@@ -40,8 +38,6 @@

const listeners = this.listeners[event];
if ( event !== 'abort' ) return false;
if ( !listeners ) return true;
[...this.listeners].forEach ( listener => listener () );
listeners.slice ().forEach ( listener => listener () );
return true;

@@ -51,13 +47,2 @@

/* API */
abort (): void {
if ( this.aborted ) return;
this.aborted = true;
this.dispatchEvent ( 'abort' );
}
}

@@ -64,0 +49,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc