Comparing version 1.1.0 to 2.0.0
@@ -6,8 +6,2 @@ import AbortSignal from './signal'; | ||
} | ||
declare const _default: typeof AbortController & { | ||
default: typeof AbortController; | ||
} | ||
declare namespace _default { | ||
export type type = AbortController; | ||
} | ||
export = _default; | ||
export default AbortController; |
@@ -1,19 +0,15 @@ | ||
"use strict"; | ||
/* IMPORT */ | ||
var signal_1 = require("./signal"); | ||
/* ABORT CONTROLLER */ | ||
var AbortController = /** @class */ (function () { | ||
function AbortController() { | ||
import AbortSignal from './signal.js'; | ||
/* MAIN */ | ||
class AbortController { | ||
constructor() { | ||
/* VARIABLES */ | ||
this.signal = new signal_1.default(); | ||
this.signal = new AbortSignal(); | ||
} | ||
/* API */ | ||
AbortController.prototype.abort = function () { | ||
abort() { | ||
return this.signal.abort(); | ||
}; | ||
return AbortController; | ||
}()); | ||
} | ||
} | ||
/* EXPORT */ | ||
module.exports = AbortController; | ||
module.exports.default = AbortController; | ||
Object.defineProperty(module.exports, "__esModule", { value: true }); | ||
export default AbortController; |
@@ -1,2 +0,2 @@ | ||
import { Event, Listener } from './types'; | ||
import type { Event, Listener } from './types'; | ||
declare class AbortSignal { | ||
@@ -3,0 +3,0 @@ aborted: boolean; |
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
/* IMPORT */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* ABORT SIGNAL */ | ||
var AbortSignal = /** @class */ (function () { | ||
function AbortSignal() { | ||
/* MAIN */ | ||
class AbortSignal { | ||
constructor() { | ||
/* VARIABLES */ | ||
@@ -12,21 +10,21 @@ this.aborted = false; | ||
/* EVENTS API */ | ||
AbortSignal.prototype.addEventListener = function (event, listener) { | ||
var listeners = this.listeners[event] || (this.listeners[event] = []); | ||
addEventListener(event, listener) { | ||
const listeners = this.listeners[event] || (this.listeners[event] = []); | ||
listeners.push(listener); | ||
}; | ||
AbortSignal.prototype.removeEventListener = function (event, listener) { | ||
var listeners = this.listeners[event]; | ||
} | ||
removeEventListener(event, listener) { | ||
const listeners = this.listeners[event]; | ||
if (!listeners) | ||
return; | ||
listeners.splice(listeners.indexOf(listener), 1); | ||
}; | ||
AbortSignal.prototype.dispatchEvent = function (event) { | ||
var listeners = this.listeners[event]; | ||
} | ||
dispatchEvent(event) { | ||
const listeners = this.listeners[event]; | ||
if (!listeners) | ||
return true; | ||
listeners.slice().forEach(function (listener) { return listener(); }); | ||
listeners.slice().forEach(listener => listener()); | ||
return true; | ||
}; | ||
} | ||
/* API */ | ||
AbortSignal.prototype.abort = function () { | ||
abort() { | ||
if (this.aborted) | ||
@@ -36,6 +34,5 @@ return; | ||
this.dispatchEvent('abort'); | ||
}; | ||
return AbortSignal; | ||
}()); | ||
} | ||
} | ||
/* EXPORT */ | ||
exports.default = AbortSignal; | ||
export default AbortSignal; |
declare type Event = 'abort'; | ||
declare type Listener = () => any; | ||
export { Event, Listener }; | ||
declare type Listener = () => void; | ||
export type { Event, Listener }; |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
/* TYPES */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* MAIN */ | ||
export {}; |
{ | ||
"name": "aborter", | ||
"repository": "github:fabiospampinato/aborter", | ||
"description": "A minimal reimplementation of AbortController and AbortSignal.", | ||
"version": "1.1.0", | ||
"main": "dist/controller.js", | ||
"types": "dist/controller.d.ts", | ||
"version": "2.0.0", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"exports": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"clean:dist": "rimraf dist", | ||
"clean:coverage": "rimraf coverage .nyc_output", | ||
"clean": "npm run clean:dist && npm run clean:coverage", | ||
"compile": "tsc --skipLibCheck && tstei", | ||
"compile:watch": "tsc --skipLibCheck --watch", | ||
"test": "ava", | ||
"test:watch": "ava --watch", | ||
"coverage": "nyc --reporter=html ava", | ||
"report": "nyc report", | ||
"report:html": "open coverage/index.html", | ||
"prepublishOnly": "npm run clean && npm run compile && npm run coverage" | ||
"clean": "tsex clean", | ||
"compile": "tsex compile", | ||
"compile:watch": "tsex compile --watch", | ||
"test": "tsex test", | ||
"test:watch": "tsex test --watch", | ||
"prepublishOnly": "npm run clean && npm run compile && npm run test" | ||
}, | ||
"ava": { | ||
"files": [ | ||
"test/index.js" | ||
] | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/fabiospampinato/aborter/issues" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "Fabio Spampinato", | ||
"email": "spampinabio@gmail.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fabiospampinato/aborter.git" | ||
}, | ||
"keywords": [ | ||
@@ -45,12 +26,7 @@ "abort", | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.16", | ||
"ava": "^2.4.0", | ||
"ava-spec": "^1.1.1", | ||
"nyc": "^15.1.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.1.3", | ||
"typescript-transform-export-interop": "^1.0.2" | ||
"fava": "^0.0.6", | ||
"tsex": "^1.1.1", | ||
"typescript": "^4.6.3" | ||
} | ||
} |
@@ -6,3 +6,3 @@ | ||
/* ABORT CONTROLLER */ | ||
/* MAIN */ | ||
@@ -9,0 +9,0 @@ class AbortController { |
/* IMPORT */ | ||
import {Event, Listener} from './types'; | ||
import type {Event, Listener} from './types'; | ||
/* ABORT SIGNAL */ | ||
/* MAIN */ | ||
@@ -8,0 +8,0 @@ class AbortSignal { |
/* TYPES */ | ||
/* MAIN */ | ||
type Event = 'abort'; | ||
type Listener = () => any; | ||
type Listener = () => void; | ||
/* EXPORT */ | ||
export {Event, Listener}; | ||
export type {Event, Listener}; |
/* IMPORT */ | ||
import {describe} from 'ava-spec'; | ||
import {default as Aborter} from '../dist/controller'; | ||
import {describe} from 'fava'; | ||
import Aborter from '../dist/index.js'; | ||
/* ABORTER */ | ||
/* MAIN */ | ||
@@ -9,0 +9,0 @@ describe ( 'Aborter', it => { |
{ | ||
"compilerOptions": { | ||
"alwaysStrict": true, | ||
"declaration": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"inlineSourceMap": false, | ||
"jsx": "react", | ||
"lib": ["dom", "scripthost", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020"], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"newLine": "LF", | ||
"noFallthroughCasesInSwitch": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": false, | ||
"outDir": "dist", | ||
"pretty": true, | ||
"strictNullChecks": true, | ||
"target": "es5" | ||
}, | ||
"include": [ | ||
"src" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
"extends": "tsex/tsconfig.json" | ||
} |
Sorry, the diff of this file is not supported yet
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
3
18
Yes
6932
156
2
1