Comparing version 0.20.0 to 0.21.0
@@ -378,3 +378,3 @@ /// <reference lib="dom"/> | ||
declare class TimeoutError extends Error { | ||
constructor(); | ||
constructor(request: Request); | ||
} | ||
@@ -381,0 +381,0 @@ |
11
index.js
@@ -159,5 +159,6 @@ /*! MIT License © Sindre Sorhus */ | ||
class TimeoutError extends Error { | ||
constructor() { | ||
constructor(request) { | ||
super('Request timed out'); | ||
this.name = 'TimeoutError'; | ||
this.request = request; | ||
} | ||
@@ -169,3 +170,3 @@ } | ||
// `Promise.race()` workaround (#91) | ||
const timeout = (promise, ms, abortController) => | ||
const timeout = (request, ms, abortController) => | ||
new Promise((resolve, reject) => { | ||
@@ -177,7 +178,7 @@ const timeoutID = setTimeout(() => { | ||
reject(new TimeoutError()); | ||
reject(new TimeoutError(request)); | ||
}, ms); | ||
/* eslint-disable promise/prefer-await-to-then */ | ||
promise | ||
globals.fetch(request) | ||
.then(resolve) | ||
@@ -439,3 +440,3 @@ .catch(reject) | ||
return timeout(globals.fetch(this.request.clone()), this._options.timeout, this.abortController); | ||
return timeout(this.request.clone(), this._options.timeout, this.abortController); | ||
} | ||
@@ -442,0 +443,0 @@ |
{ | ||
"name": "ky", | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"description": "Tiny and elegant HTTP client based on the browser Fetch API", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
11
umd.js
@@ -165,5 +165,6 @@ (function (global, factory) { | ||
class TimeoutError extends Error { | ||
constructor() { | ||
constructor(request) { | ||
super('Request timed out'); | ||
this.name = 'TimeoutError'; | ||
this.request = request; | ||
} | ||
@@ -175,3 +176,3 @@ } | ||
// `Promise.race()` workaround (#91) | ||
const timeout = (promise, ms, abortController) => | ||
const timeout = (request, ms, abortController) => | ||
new Promise((resolve, reject) => { | ||
@@ -183,7 +184,7 @@ const timeoutID = setTimeout(() => { | ||
reject(new TimeoutError()); | ||
reject(new TimeoutError(request)); | ||
}, ms); | ||
/* eslint-disable promise/prefer-await-to-then */ | ||
promise | ||
globals.fetch(request) | ||
.then(resolve) | ||
@@ -445,3 +446,3 @@ .catch(reject) | ||
return timeout(globals.fetch(this.request.clone()), this._options.timeout, this.abortController); | ||
return timeout(this.request.clone(), this._options.timeout, this.abortController); | ||
} | ||
@@ -448,0 +449,0 @@ |
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
62339
1221