Comparing version 0.33.1 to 0.33.2
@@ -1,31 +0,1 @@ | ||
declare const DOMException: { | ||
new (message?: string | undefined, name?: string | undefined): DOMException; | ||
prototype: DOMException; | ||
readonly ABORT_ERR: number; | ||
readonly DATA_CLONE_ERR: number; | ||
readonly DOMSTRING_SIZE_ERR: number; | ||
readonly HIERARCHY_REQUEST_ERR: number; | ||
readonly INDEX_SIZE_ERR: number; | ||
readonly INUSE_ATTRIBUTE_ERR: number; | ||
readonly INVALID_ACCESS_ERR: number; | ||
readonly INVALID_CHARACTER_ERR: number; | ||
readonly INVALID_MODIFICATION_ERR: number; | ||
readonly INVALID_NODE_TYPE_ERR: number; | ||
readonly INVALID_STATE_ERR: number; | ||
readonly NAMESPACE_ERR: number; | ||
readonly NETWORK_ERR: number; | ||
readonly NOT_FOUND_ERR: number; | ||
readonly NOT_SUPPORTED_ERR: number; | ||
readonly NO_DATA_ALLOWED_ERR: number; | ||
readonly NO_MODIFICATION_ALLOWED_ERR: number; | ||
readonly QUOTA_EXCEEDED_ERR: number; | ||
readonly SECURITY_ERR: number; | ||
readonly SYNTAX_ERR: number; | ||
readonly TIMEOUT_ERR: number; | ||
readonly TYPE_MISMATCH_ERR: number; | ||
readonly URL_MISMATCH_ERR: number; | ||
readonly VALIDATION_ERR: number; | ||
readonly WRONG_DOCUMENT_ERR: number; | ||
}; | ||
export default DOMException; | ||
export declare function composeAbortError(signal?: AbortSignal): DOMException; | ||
export declare function composeAbortError(signal?: AbortSignal): Error | DOMException; |
@@ -1,7 +0,18 @@ | ||
const DOMException = globalThis.DOMException ?? Error; | ||
export default DOMException; | ||
// When targeting Node.js 18, use `signal.throwIfAborted()` (https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted) | ||
// DOMException is supported on most modern browsers and Node.js 18+. | ||
// @see https://developer.mozilla.org/en-US/docs/Web/API/DOMException#browser_compatibility | ||
const isDomExceptionSupported = Boolean(globalThis.DOMException); | ||
// TODO: When targeting Node.js 18, use `signal.throwIfAborted()` (https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted) | ||
export function composeAbortError(signal) { | ||
return new DOMException(signal?.reason ?? 'The operation was aborted.'); | ||
/* | ||
NOTE: Use DomException with AbortError name as specified in MDN docs (https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) | ||
> When abort() is called, the fetch() promise rejects with an Error of type DOMException, with name AbortError. | ||
*/ | ||
if (isDomExceptionSupported) { | ||
return new DOMException(signal?.reason ?? 'The operation was aborted.', 'AbortError'); | ||
} | ||
// DOMException not supported. Fall back to use of error and override name. | ||
const error = new Error(signal?.reason ?? 'The operation was aborted.'); | ||
error.name = 'AbortError'; | ||
return error; | ||
} | ||
//# sourceMappingURL=DOMException.js.map |
{ | ||
"name": "ky", | ||
"version": "0.33.1", | ||
"version": "0.33.2", | ||
"description": "Tiny and elegant HTTP client based on the browser Fetch API", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
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
139343
1069