forked from transloadit/uppy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@uppy/utils: add
cause
support for AbortError
s
Refs: whatwg/webidl#1179
- Loading branch information
Showing
1 changed file
with
8 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import hasOwnProperty from './hasProperty.js' | ||
/** | ||
* Little AbortController proxy module so we can swap out the implementation easily later. | ||
*/ | ||
export const { AbortController } = globalThis | ||
export const { AbortSignal } = globalThis | ||
export const createAbortError = (message = 'Aborted') => new DOMException(message, 'AbortError') | ||
export const createAbortError = (message = 'Aborted', options) => { | ||
const err = new DOMException(message, 'AbortError') | ||
if (options != null && hasOwnProperty(options, 'cause')) { | ||
Object.defineProperty(err, 'cause', { __proto__: null, configurable: true, writable: true, value: options.cause }) | ||
} | ||
return err | ||
} |