-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make test runner work even if there is no
AbortSignal
support
Fixes a breaking change for Node.js v14.x that was introduced in 3.2.0. Fixes: #35
- Loading branch information
Showing
5 changed files
with
42 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,28 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
AbortController, | ||
AbortSignal | ||
if (typeof AbortController === 'undefined') { | ||
module.exports = { | ||
AbortController: class AbortController { | ||
#eventListeners = new Set() | ||
signal = { | ||
aborted: false, | ||
addEventListener: (_, listener) => { | ||
this.#eventListeners.add(listener) | ||
}, | ||
removeEventListener: (_, listener) => { | ||
this.#eventListeners.delete(listener) | ||
} | ||
} | ||
|
||
abort () { | ||
this.signal.aborted = true | ||
this.#eventListeners.forEach(listener => listener()) | ||
} | ||
} | ||
} | ||
} else { | ||
module.exports = { | ||
AbortController, | ||
AbortSignal | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters