abort-controller-x
Advanced tools
Comparing version 0.2.7 to 0.3.0
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Wrap a promise to reject with `AbortError` once `signal` is aborted. |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.abortable = void 0; | ||
const execute_1 = require("./execute"); | ||
import { execute } from './execute.js'; | ||
/** | ||
@@ -11,3 +8,3 @@ * Wrap a promise to reject with `AbortError` once `signal` is aborted. | ||
*/ | ||
function abortable(signal, promise) { | ||
export function abortable(signal, promise) { | ||
if (signal.aborted) { | ||
@@ -18,3 +15,3 @@ // prevent unhandled rejection | ||
} | ||
return execute_1.execute(signal, (resolve, reject) => { | ||
return execute(signal, (resolve, reject) => { | ||
promise.then(resolve, reject); | ||
@@ -24,3 +21,2 @@ return () => { }; | ||
} | ||
exports.abortable = abortable; | ||
//# sourceMappingURL=abortable.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Thrown when an abortable function was aborted. |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.catchAbortError = exports.rethrowAbortError = exports.throwIfAborted = exports.isAbortError = exports.AbortError = void 0; | ||
/** | ||
@@ -10,3 +7,3 @@ * Thrown when an abortable function was aborted. | ||
*/ | ||
class AbortError extends Error { | ||
export class AbortError extends Error { | ||
constructor() { | ||
@@ -21,7 +18,6 @@ super('The operation has been aborted'); | ||
} | ||
exports.AbortError = AbortError; | ||
/** | ||
* Checks whether given `error` is an `AbortError`. | ||
*/ | ||
function isAbortError(error) { | ||
export function isAbortError(error) { | ||
return (typeof error === 'object' && | ||
@@ -31,7 +27,6 @@ error !== null && | ||
} | ||
exports.isAbortError = isAbortError; | ||
/** | ||
* If `signal` is aborted, throws `AbortError`. Otherwise does nothing. | ||
*/ | ||
function throwIfAborted(signal) { | ||
export function throwIfAborted(signal) { | ||
if (signal.aborted) { | ||
@@ -41,3 +36,2 @@ throw new AbortError(); | ||
} | ||
exports.throwIfAborted = throwIfAborted; | ||
/** | ||
@@ -56,3 +50,3 @@ * If `error` is `AbortError`, throws it. Otherwise does nothing. | ||
*/ | ||
function rethrowAbortError(error) { | ||
export function rethrowAbortError(error) { | ||
if (isAbortError(error)) { | ||
@@ -63,3 +57,2 @@ throw error; | ||
} | ||
exports.rethrowAbortError = rethrowAbortError; | ||
/** | ||
@@ -75,3 +68,3 @@ * If `error` is `AbortError`, does nothing. Otherwise throws it. | ||
*/ | ||
function catchAbortError(error) { | ||
export function catchAbortError(error) { | ||
if (isAbortError(error)) { | ||
@@ -82,3 +75,2 @@ return; | ||
} | ||
exports.catchAbortError = catchAbortError; | ||
//# sourceMappingURL=AbortError.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Abortable version of `Promise.all`. |
@@ -1,13 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.all = void 0; | ||
const node_abort_controller_1 = require("node-abort-controller"); | ||
const AbortError_1 = require("./AbortError"); | ||
function all(signal, executor) { | ||
import { AbortError, isAbortError } from './AbortError.js'; | ||
export function all(signal, executor) { | ||
return new Promise((resolve, reject) => { | ||
if (signal.aborted) { | ||
reject(new AbortError_1.AbortError()); | ||
reject(new AbortError()); | ||
return; | ||
} | ||
const innerAbortController = new node_abort_controller_1.default(); | ||
const innerAbortController = new AbortController(); | ||
const promises = executor(innerAbortController.signal); | ||
@@ -44,3 +40,3 @@ if (promises.length === 0) { | ||
if (rejection == null || | ||
(!AbortError_1.isAbortError(reason) && AbortError_1.isAbortError(rejection.reason))) { | ||
(!isAbortError(reason) && isAbortError(rejection.reason))) { | ||
rejection = { reason }; | ||
@@ -53,3 +49,2 @@ } | ||
} | ||
exports.all = all; | ||
//# sourceMappingURL=all.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Returns a promise that fulfills after delay and rejects with |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.delay = void 0; | ||
const execute_1 = require("./execute"); | ||
import { execute } from './execute.js'; | ||
/** | ||
@@ -34,4 +31,4 @@ * Returns a promise that fulfills after delay and rejects with | ||
*/ | ||
function delay(signal, dueTime) { | ||
return execute_1.execute(signal, resolve => { | ||
export function delay(signal, dueTime) { | ||
return execute(signal, resolve => { | ||
const ms = typeof dueTime === 'number' ? dueTime : dueTime.getTime() - Date.now(); | ||
@@ -44,3 +41,2 @@ const timer = setTimeout(resolve, ms); | ||
} | ||
exports.delay = delay; | ||
//# sourceMappingURL=delay.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Similar to `new Promise(executor)`, but allows executor to return abort |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.execute = void 0; | ||
const AbortError_1 = require("./AbortError"); | ||
import { AbortError } from './AbortError.js'; | ||
/** | ||
@@ -15,6 +12,6 @@ * Similar to `new Promise(executor)`, but allows executor to return abort | ||
*/ | ||
function execute(signal, executor) { | ||
export function execute(signal, executor) { | ||
return new Promise((resolve, reject) => { | ||
if (signal.aborted) { | ||
reject(new AbortError_1.AbortError()); | ||
reject(new AbortError()); | ||
return; | ||
@@ -43,7 +40,7 @@ } | ||
if (callbackResult == null) { | ||
reject(new AbortError_1.AbortError()); | ||
reject(new AbortError()); | ||
} | ||
else { | ||
callbackResult.then(() => { | ||
reject(new AbortError_1.AbortError()); | ||
reject(new AbortError()); | ||
}, reason => { | ||
@@ -62,3 +59,2 @@ reject(reason); | ||
} | ||
exports.execute = execute; | ||
//# sourceMappingURL=execute.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Return a promise that never fulfills and only rejects with `AbortError` once |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.forever = void 0; | ||
const execute_1 = require("./execute"); | ||
import { execute } from './execute.js'; | ||
/** | ||
@@ -9,6 +6,5 @@ * Return a promise that never fulfills and only rejects with `AbortError` once | ||
*/ | ||
function forever(signal) { | ||
return execute_1.execute(signal, () => () => { }); | ||
export function forever(signal) { | ||
return execute(signal, () => () => { }); | ||
} | ||
exports.forever = forever; | ||
//# sourceMappingURL=forever.js.map |
@@ -1,11 +0,11 @@ | ||
export * from './abortable'; | ||
export * from './AbortError'; | ||
export * from './delay'; | ||
export * from './execute'; | ||
export * from './forever'; | ||
export * from './waitForEvent'; | ||
export * from './all'; | ||
export * from './race'; | ||
export * from './retry'; | ||
export * from './spawn'; | ||
export * from './run'; | ||
export * from './abortable.js'; | ||
export * from './AbortError.js'; | ||
export * from './delay.js'; | ||
export * from './execute.js'; | ||
export * from './forever.js'; | ||
export * from './waitForEvent.js'; | ||
export * from './all.js'; | ||
export * from './race.js'; | ||
export * from './retry.js'; | ||
export * from './spawn.js'; | ||
export * from './run.js'; |
@@ -1,24 +0,12 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./abortable"), exports); | ||
__exportStar(require("./AbortError"), exports); | ||
__exportStar(require("./delay"), exports); | ||
__exportStar(require("./execute"), exports); | ||
__exportStar(require("./forever"), exports); | ||
__exportStar(require("./waitForEvent"), exports); | ||
__exportStar(require("./all"), exports); | ||
__exportStar(require("./race"), exports); | ||
__exportStar(require("./retry"), exports); | ||
__exportStar(require("./spawn"), exports); | ||
__exportStar(require("./run"), exports); | ||
export * from './abortable.js'; | ||
export * from './AbortError.js'; | ||
export * from './delay.js'; | ||
export * from './execute.js'; | ||
export * from './forever.js'; | ||
export * from './waitForEvent.js'; | ||
export * from './all.js'; | ||
export * from './race.js'; | ||
export * from './retry.js'; | ||
export * from './spawn.js'; | ||
export * from './run.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Abortable version of `Promise.race`. |
@@ -1,6 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.race = void 0; | ||
const node_abort_controller_1 = require("node-abort-controller"); | ||
const AbortError_1 = require("./AbortError"); | ||
import { AbortError, isAbortError } from './AbortError.js'; | ||
/** | ||
@@ -34,9 +30,9 @@ * Abortable version of `Promise.race`. | ||
*/ | ||
function race(signal, executor) { | ||
export function race(signal, executor) { | ||
return new Promise((resolve, reject) => { | ||
if (signal.aborted) { | ||
reject(new AbortError_1.AbortError()); | ||
reject(new AbortError()); | ||
return; | ||
} | ||
const innerAbortController = new node_abort_controller_1.default(); | ||
const innerAbortController = new AbortController(); | ||
const promises = executor(innerAbortController.signal); | ||
@@ -70,4 +66,4 @@ const abortListener = () => { | ||
if (result == null || | ||
(!AbortError_1.isAbortError(reason) && | ||
(result.status === 'fulfilled' || AbortError_1.isAbortError(result.reason)))) { | ||
(!isAbortError(reason) && | ||
(result.status === 'fulfilled' || isAbortError(result.reason)))) { | ||
result = { status: 'rejected', reason }; | ||
@@ -80,3 +76,2 @@ } | ||
} | ||
exports.race = race; | ||
//# sourceMappingURL=race.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
export declare type RetryOptions = { | ||
@@ -15,3 +14,3 @@ /** | ||
* | ||
* Defaults to 15 seconds. | ||
* Defaults to 30 seconds. | ||
* | ||
@@ -18,0 +17,0 @@ * Example: if `baseMs` is 1000 and `maxDelayMs` is 3000, then retries will be |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.retry = void 0; | ||
const delay_1 = require("./delay"); | ||
const AbortError_1 = require("./AbortError"); | ||
import { delay } from './delay.js'; | ||
import { rethrowAbortError } from './AbortError.js'; | ||
/** | ||
@@ -13,4 +10,4 @@ * Retry function with exponential backoff. | ||
*/ | ||
async function retry(signal, fn, options = {}) { | ||
const { baseMs = 1000, maxDelayMs = 15000, onError, maxAttempts = Infinity, } = options; | ||
export async function retry(signal, fn, options = {}) { | ||
const { baseMs = 1000, maxDelayMs = 30000, onError, maxAttempts = Infinity, } = options; | ||
let attempt = 0; | ||
@@ -25,3 +22,3 @@ const reset = () => { | ||
catch (error) { | ||
AbortError_1.rethrowAbortError(error); | ||
rethrowAbortError(error); | ||
if (attempt >= maxAttempts) { | ||
@@ -43,3 +40,3 @@ throw error; | ||
if (delayMs !== 0) { | ||
await delay_1.delay(signal, delayMs); | ||
await delay(signal, delayMs); | ||
} | ||
@@ -50,3 +47,2 @@ attempt += 1; | ||
} | ||
exports.retry = retry; | ||
//# sourceMappingURL=retry.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
/** | ||
@@ -3,0 +2,0 @@ * Invokes an abortable function with implicitly created `AbortSignal`. |
@@ -1,6 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.run = void 0; | ||
const node_abort_controller_1 = require("node-abort-controller"); | ||
const AbortError_1 = require("./AbortError"); | ||
import { catchAbortError } from './AbortError.js'; | ||
/** | ||
@@ -31,5 +27,5 @@ * Invokes an abortable function with implicitly created `AbortSignal`. | ||
*/ | ||
function run(fn) { | ||
const abortController = new node_abort_controller_1.default(); | ||
const promise = fn(abortController.signal).catch(AbortError_1.catchAbortError); | ||
export function run(fn) { | ||
const abortController = new AbortController(); | ||
const promise = fn(abortController.signal).catch(catchAbortError); | ||
return () => { | ||
@@ -40,3 +36,2 @@ abortController.abort(); | ||
} | ||
exports.run = run; | ||
//# sourceMappingURL=run.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
export declare type SpawnEffects = { | ||
@@ -3,0 +2,0 @@ /** |
@@ -1,6 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.spawn = void 0; | ||
const node_abort_controller_1 = require("node-abort-controller"); | ||
const AbortError_1 = require("./AbortError"); | ||
import { AbortError, catchAbortError, isAbortError } from './AbortError.js'; | ||
/** | ||
@@ -89,5 +85,5 @@ * Run an abortable function with `fork` and `defer` effects attached to it. | ||
*/ | ||
function spawn(signal, fn) { | ||
export function spawn(signal, fn) { | ||
if (signal.aborted) { | ||
return Promise.reject(new AbortError_1.AbortError()); | ||
return Promise.reject(new AbortError()); | ||
} | ||
@@ -100,3 +96,3 @@ const deferredFunctions = []; | ||
*/ | ||
const spawnAbortController = new node_abort_controller_1.default(); | ||
const spawnAbortController = new AbortController(); | ||
const spawnSignal = spawnAbortController.signal; | ||
@@ -135,3 +131,3 @@ const abortSpawn = () => { | ||
spawnAbortController.abort(); | ||
if (!AbortError_1.isAbortError(error) || failure == null) { | ||
if (!isAbortError(error) || failure == null) { | ||
failure = { error }; | ||
@@ -146,7 +142,7 @@ } | ||
async join() { | ||
throw new AbortError_1.AbortError(); | ||
throw new AbortError(); | ||
}, | ||
}; | ||
} | ||
const taskAbortController = new node_abort_controller_1.default(); | ||
const taskAbortController = new AbortController(); | ||
const taskSignal = taskAbortController.signal; | ||
@@ -162,3 +158,3 @@ const taskPromise = forkFn(taskSignal); | ||
taskPromise | ||
.catch(AbortError_1.catchAbortError) | ||
.catch(catchAbortError) | ||
.catch(error => { | ||
@@ -194,3 +190,2 @@ failure = { error }; | ||
} | ||
exports.spawn = spawn; | ||
//# sourceMappingURL=spawn.js.map |
@@ -1,2 +0,1 @@ | ||
import { AbortSignal } from 'node-abort-controller'; | ||
export declare type EventTargetLike<T> = EventTargetLike.HasEventTargetAddRemove<T> | EventTargetLike.NodeStyleEventEmitter | EventTargetLike.NodeCompatibleEventEmitter | EventTargetLike.JQueryStyleEventEmitter<any, T>; | ||
@@ -3,0 +2,0 @@ /** |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.waitForEvent = void 0; | ||
const execute_1 = require("./execute"); | ||
import { execute } from './execute.js'; | ||
/** | ||
@@ -24,4 +21,4 @@ * Returns a promise that fulfills when an event of specific type is emitted | ||
*/ | ||
function waitForEvent(signal, target, eventName, options) { | ||
return execute_1.execute(signal, resolve => { | ||
export function waitForEvent(signal, target, eventName, options) { | ||
return execute(signal, resolve => { | ||
let unlisten; | ||
@@ -48,3 +45,2 @@ let finished = false; | ||
} | ||
exports.waitForEvent = waitForEvent; | ||
function listen(target, eventName, handler, options) { | ||
@@ -51,0 +47,0 @@ if (isEventTarget(target)) { |
{ | ||
"name": "abort-controller-x", | ||
"version": "0.2.7", | ||
"version": "0.3.0", | ||
"description": "Abortable async function helpers", | ||
@@ -17,16 +17,13 @@ "keywords": [ | ||
"sideEffects": false, | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"typings": "lib/index.d.ts", | ||
"type": "module", | ||
"exports": "./lib/index.js", | ||
"typings": "./lib/index.d.ts", | ||
"files": [ | ||
"src", | ||
"lib", | ||
"es" | ||
"lib" | ||
], | ||
"scripts": { | ||
"clean": "rimraf lib es", | ||
"clean": "rimraf lib", | ||
"test": "jest", | ||
"build:lib": "tsc -P tsconfig.build.json", | ||
"build:es": "tsc -P tsconfig.es.json", | ||
"build": "npm run build:lib && npm run build:es", | ||
"build": "tsc -P tsconfig.build.json", | ||
"prepublishOnly": "npm test && npm run clean && npm run build" | ||
@@ -38,13 +35,11 @@ }, | ||
"@types/defer-promise": "^1.0.0", | ||
"@types/jest": "^26.0.14", | ||
"@types/jest": "^28.1.6", | ||
"@types/node": "^14.17.0", | ||
"defer-promise": "^2.0.1", | ||
"jest": "^26.5.0", | ||
"jest": "^28.1.3", | ||
"prettier": "^2.1.2", | ||
"rimraf": "^2.6.3", | ||
"ts-jest": "^26.4.1", | ||
"typescript": "^4.0.3" | ||
}, | ||
"dependencies": { | ||
"node-abort-controller": "^1.2.1 || ^2.0.0" | ||
"ts-jest": "^28.0.7", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
@@ -37,5 +37,6 @@ # Abort Controller Extras [![npm version][npm-image]][npm-url] | ||
[`AbortController` MDN page](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). | ||
Use | ||
[`node-abort-controller`](https://www.npmjs.com/package/node-abort-controller) | ||
to polyfill `AbortController` in NodeJS. | ||
AbortController is | ||
[available in NodeJS](https://nodejs.org/api/globals.html#class-abortcontroller), | ||
a [polyfill](https://www.npmjs.com/package/abort-controller) is available for | ||
older versions. | ||
@@ -42,0 +43,0 @@ ## Abortable Functions |
@@ -1,4 +0,3 @@ | ||
import AbortController from 'node-abort-controller'; | ||
import {abortable} from './abortable'; | ||
import {nextTick} from './utils/nextTick'; | ||
import {abortable} from './abortable.js'; | ||
import {nextTick} from './utils/nextTick.js'; | ||
@@ -5,0 +4,0 @@ test('abortable endless promise', async () => { |
@@ -1,3 +0,2 @@ | ||
import {AbortSignal} from 'node-abort-controller'; | ||
import {execute} from './execute'; | ||
import {execute} from './execute.js'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -1,2 +0,1 @@ | ||
import AbortController from 'node-abort-controller'; | ||
import { | ||
@@ -8,3 +7,3 @@ AbortError, | ||
throwIfAborted, | ||
} from './AbortError'; | ||
} from './AbortError.js'; | ||
@@ -11,0 +10,0 @@ test('isAbortError', () => { |
@@ -1,3 +0,1 @@ | ||
import {AbortSignal} from 'node-abort-controller'; | ||
/** | ||
@@ -4,0 +2,0 @@ * Thrown when an abortable function was aborted. |
@@ -1,6 +0,5 @@ | ||
import AbortController, {AbortSignal} from 'node-abort-controller'; | ||
import defer = require('defer-promise'); | ||
import {AbortError} from './AbortError'; | ||
import {all} from './all'; | ||
import {nextTick} from './utils/nextTick'; | ||
import defer from 'defer-promise'; | ||
import {AbortError} from './AbortError.js'; | ||
import {all} from './all.js'; | ||
import {nextTick} from './utils/nextTick.js'; | ||
@@ -7,0 +6,0 @@ test('external abort', async () => { |
@@ -1,3 +0,2 @@ | ||
import AbortController, {AbortSignal} from 'node-abort-controller'; | ||
import {AbortError, isAbortError} from './AbortError'; | ||
import {AbortError, isAbortError} from './AbortError.js'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -1,3 +0,2 @@ | ||
import {execute} from './execute'; | ||
import {AbortSignal} from 'node-abort-controller'; | ||
import {execute} from './execute.js'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -1,5 +0,4 @@ | ||
import AbortController from 'node-abort-controller'; | ||
import defer = require('defer-promise'); | ||
import {execute} from './execute'; | ||
import {nextTick} from './utils/nextTick'; | ||
import defer from 'defer-promise'; | ||
import {execute} from './execute.js'; | ||
import {nextTick} from './utils/nextTick.js'; | ||
@@ -6,0 +5,0 @@ test('resolve immediately', async () => { |
@@ -1,3 +0,2 @@ | ||
import {AbortError} from './AbortError'; | ||
import {AbortSignal} from 'node-abort-controller'; | ||
import {AbortError} from './AbortError.js'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -1,4 +0,3 @@ | ||
import AbortController from 'node-abort-controller'; | ||
import {forever} from './forever'; | ||
import {nextTick} from './utils/nextTick'; | ||
import {forever} from './forever.js'; | ||
import {nextTick} from './utils/nextTick.js'; | ||
@@ -5,0 +4,0 @@ test('forever', async () => { |
@@ -1,3 +0,2 @@ | ||
import {AbortSignal} from 'node-abort-controller'; | ||
import {execute} from './execute'; | ||
import {execute} from './execute.js'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -1,11 +0,11 @@ | ||
export * from './abortable'; | ||
export * from './AbortError'; | ||
export * from './delay'; | ||
export * from './execute'; | ||
export * from './forever'; | ||
export * from './waitForEvent'; | ||
export * from './all'; | ||
export * from './race'; | ||
export * from './retry'; | ||
export * from './spawn'; | ||
export * from './run'; | ||
export * from './abortable.js'; | ||
export * from './AbortError.js'; | ||
export * from './delay.js'; | ||
export * from './execute.js'; | ||
export * from './forever.js'; | ||
export * from './waitForEvent.js'; | ||
export * from './all.js'; | ||
export * from './race.js'; | ||
export * from './retry.js'; | ||
export * from './spawn.js'; | ||
export * from './run.js'; |
@@ -1,6 +0,5 @@ | ||
import AbortController, {AbortSignal} from 'node-abort-controller'; | ||
import defer = require('defer-promise'); | ||
import {AbortError} from './AbortError'; | ||
import {race} from './race'; | ||
import {nextTick} from './utils/nextTick'; | ||
import defer from 'defer-promise'; | ||
import {AbortError} from './AbortError.js'; | ||
import {race} from './race.js'; | ||
import {nextTick} from './utils/nextTick.js'; | ||
@@ -7,0 +6,0 @@ test('external abort', async () => { |
@@ -1,3 +0,2 @@ | ||
import AbortController, {AbortSignal} from 'node-abort-controller'; | ||
import {AbortError, isAbortError} from './AbortError'; | ||
import {AbortError, isAbortError} from './AbortError.js'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -1,4 +0,3 @@ | ||
import {AbortSignal} from 'node-abort-controller'; | ||
import {delay} from './delay'; | ||
import {rethrowAbortError} from './AbortError'; | ||
import {delay} from './delay.js'; | ||
import {rethrowAbortError} from './AbortError.js'; | ||
@@ -18,3 +17,3 @@ export type RetryOptions = { | ||
* | ||
* Defaults to 15 seconds. | ||
* Defaults to 30 seconds. | ||
* | ||
@@ -53,3 +52,3 @@ * Example: if `baseMs` is 1000 and `maxDelayMs` is 3000, then retries will be | ||
baseMs = 1000, | ||
maxDelayMs = 15000, | ||
maxDelayMs = 30000, | ||
onError, | ||
@@ -56,0 +55,0 @@ maxAttempts = Infinity, |
@@ -1,3 +0,2 @@ | ||
import AbortController, {AbortSignal} from 'node-abort-controller'; | ||
import {catchAbortError} from './AbortError'; | ||
import {catchAbortError} from './AbortError.js'; | ||
@@ -4,0 +3,0 @@ /** |
@@ -1,5 +0,4 @@ | ||
import AbortController, {AbortSignal} from 'node-abort-controller'; | ||
import {spawn} from './spawn'; | ||
import {forever} from './forever'; | ||
import {delay} from './delay'; | ||
import {spawn} from './spawn.js'; | ||
import {forever} from './forever.js'; | ||
import {delay} from './delay.js'; | ||
@@ -19,3 +18,3 @@ test('fork manual abort', async () => { | ||
await forever(signal); | ||
} catch (err) { | ||
} catch (err: any) { | ||
actions.push(`fork abort: ${err.message}`); | ||
@@ -60,3 +59,3 @@ } | ||
await forever(signal); | ||
} catch (err) { | ||
} catch (err: any) { | ||
actions.push(`fork abort: ${err.message}`); | ||
@@ -97,3 +96,3 @@ } | ||
await forever(signal); | ||
} catch (err) { | ||
} catch (err: any) { | ||
actions.push(`fork abort: ${err.message}`); | ||
@@ -145,3 +144,3 @@ } | ||
await forever(signal); | ||
} catch (err) { | ||
} catch (err: any) { | ||
actions.push(`spawn abort: ${err.message}`); | ||
@@ -148,0 +147,0 @@ throw err; |
@@ -1,3 +0,2 @@ | ||
import AbortController, {AbortSignal} from 'node-abort-controller'; | ||
import {AbortError, catchAbortError, isAbortError} from './AbortError'; | ||
import {AbortError, catchAbortError, isAbortError} from './AbortError.js'; | ||
@@ -4,0 +3,0 @@ export type SpawnEffects = { |
@@ -1,4 +0,3 @@ | ||
import AbortController from 'node-abort-controller'; | ||
import {nextTick} from './utils/nextTick'; | ||
import {waitForEvent} from './waitForEvent'; | ||
import {nextTick} from './utils/nextTick.js'; | ||
import {waitForEvent} from './waitForEvent.js'; | ||
@@ -5,0 +4,0 @@ test('external abort', async () => { |
@@ -1,3 +0,2 @@ | ||
import {AbortSignal} from 'node-abort-controller'; | ||
import {execute} from './execute'; | ||
import {execute} from './execute.js'; | ||
@@ -4,0 +3,0 @@ export type EventTargetLike<T> = |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
0
596
Yes
123871
9
63
2959
- Removednode-abort-controller@2.0.0(transitive)