native-abort-controller
Advanced tools
Comparing version 0.0.3 to 1.0.0
@@ -0,1 +1,15 @@ | ||
# [1.0.0](https://github.com/achingbrain/native-abort-controller/compare/v0.0.3...v1.0.0) (2021-02-03) | ||
### Bug Fixes | ||
* do not extend abort controller ([#1](https://github.com/achingbrain/native-abort-controller/issues/1)) ([8f6c4ec](https://github.com/achingbrain/native-abort-controller/commit/8f6c4ec088c516d6844a87e1cd19ef094ae9be3b)) | ||
### BREAKING CHANGES | ||
* you must now used named imports instead of the default | ||
<a name="0.0.3"></a> | ||
@@ -2,0 +16,0 @@ ## [0.0.3](https://github.com/achingbrain/native-abort-controller/compare/v0.0.2...v0.0.3) (2020-08-28) |
{ | ||
"name": "native-abort-controller", | ||
"version": "0.0.3", | ||
"version": "1.0.0", | ||
"description": "Returns native AbortController/AbortSignal if available or the abort-controller module if not", | ||
@@ -27,3 +27,3 @@ "main": "src/index.js", | ||
"abort-controller": "^3.0.0", | ||
"aegir": "^26.0.0" | ||
"aegir": "^30.3.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "contributors": [ |
@@ -5,3 +5,3 @@ # native-abort-controller | ||
A drop-in replacement for the `abort-controller` module that returns the native AbortController if available or the polyfill if not. | ||
An (almost) drop-in replacement for the `abort-controller` module that returns the native AbortController if available or the polyfill if not. | ||
@@ -27,3 +27,3 @@ ### Why? | ||
```javascript | ||
import AbortController from 'native-abort-controller' | ||
import { AbortController } from 'native-abort-controller' | ||
@@ -30,0 +30,0 @@ const controller = new AbortController() |
'use strict' | ||
const globalThis = require('globalthis')() | ||
let impl | ||
if (globalThis.AbortController && globalThis.AbortSignal) { | ||
module.exports = class AbortController extends globalThis.AbortController {} | ||
module.exports.AbortSignal = globalThis.AbortSignal | ||
module.exports.default = module.exports | ||
impl = globalThis | ||
} else { | ||
module.exports = require('abort-controller') | ||
impl = require('abort-controller') | ||
} | ||
module.exports = { | ||
AbortController: impl.AbortController, | ||
AbortSignal: impl.AbortSignal | ||
} |
@@ -5,6 +5,12 @@ 'use strict' | ||
const { expect } = require('aegir/utils/chai') | ||
const NativeAbortController = require('../src') | ||
const AbortControllerPollyfill = require('abort-controller') | ||
const { AbortController: NativeAbortController } = require('../src') | ||
const { AbortController: AbortControllerPollyfill } = require('abort-controller') | ||
const globalthis = require('globalthis')() | ||
let nodeVersion | ||
if (globalthis.process && globalthis.process.version) { | ||
nodeVersion = parseInt(globalthis.process.version.match(/v(\d+)\./)[1], 10) | ||
} | ||
describe('env', function () { | ||
@@ -24,5 +30,12 @@ it('AbortController should be correct in each env', function () { | ||
case 'node': | ||
expect(NativeAbortController).to.equal(AbortControllerPollyfill) | ||
expect(new NativeAbortController()).to.be.instanceOf(AbortControllerPollyfill) | ||
expect(globalthis.AbortController).to.be.undefined() | ||
if (nodeVersion < 15) { | ||
expect(NativeAbortController).to.equal(AbortControllerPollyfill) | ||
expect(new NativeAbortController()).to.be.instanceOf(AbortControllerPollyfill) | ||
expect(globalthis.AbortController).to.be.undefined() | ||
} else { | ||
// node 15+ gets native AbortController | ||
expect(NativeAbortController).to.not.equal(AbortControllerPollyfill) | ||
expect(new NativeAbortController()).to.be.instanceOf(globalthis.AbortController) | ||
expect(globalthis.AbortController).to.be.ok() | ||
} | ||
break | ||
@@ -29,0 +42,0 @@ case 'browser': |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6992
6
63
1