Skip to content

Commit

Permalink
feat: use native AbortController when possible (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala authored Aug 18, 2020
1 parent a611f30 commit a294834
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions abort-controller.browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict'
/* eslint-env browser */

module.exports = AbortController
9 changes: 9 additions & 0 deletions abort-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

// Electron has `AbortController` and should use that instead of custom.
// Works around: https://github.com/mysticatea/abort-controller/issues/24
module.exports = typeof AbortController === 'function'
/* eslint-env browser */
/* istanbul ignore next */
? require('./abort-controller.browser')
: require('abort-controller')
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const AbortController = require('abort-controller')
const AbortController = require('./abort-controller')

/**
* Takes an array of AbortSignals and returns a single signal.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "Combines an array of AbortSignals into a single signal that is aborted when any signal is",
"main": "index.js",
"files": [
"index.js"
"index.js",
"abort-controller.js",
"abort-controller.browser.js"
],
"scripts": {
"test": "npm run lint && nyc --reporter=lcov --reporter=text ava --verbose",
Expand All @@ -13,6 +15,9 @@
"keywords": [],
"author": "Jacob Heun",
"license": "MIT",
"browser": {
"./abort-controller.js": "./abort-controller.browser.js"
},
"dependencies": {
"abort-controller": "^3.0.0"
},
Expand All @@ -35,4 +40,4 @@
"url": "https://github.com/jacobheun/any-signal/issues"
},
"homepage": "https://github.com/jacobheun/any-signal#readme"
}
}

0 comments on commit a294834

Please sign in to comment.