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

native-abort-controller

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

native-abort-controller - npm Package Compare versions

Comparing version 0.0.3 to 1.0.0

.github/workflows/main.yml

14

CHANGELOG.md

@@ -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)

4

package.json
{
"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':

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