Comparing version 0.11.1 to 0.11.2
39
index.js
@@ -118,24 +118,33 @@ /*! MIT License © Sindre Sorhus */ | ||
const delay = ms => new Promise((resolve, reject) => { | ||
const safeTimeout = (resolve, reject, ms) => { | ||
if (ms > 2147483647) { // The maximum value of a 32bit int (see #117) | ||
reject(new RangeError('The `timeout` option cannot be greater than 2147483647')); | ||
} else { | ||
setTimeout(resolve, ms); | ||
} | ||
}); | ||
return setTimeout(resolve, ms); | ||
}; | ||
const delay = ms => new Promise((resolve, reject) => safeTimeout(resolve, reject, ms)); | ||
// `Promise.race()` workaround (#91) | ||
const timeout = (promise, ms, abortController) => new Promise((resolve, reject) => { | ||
/* eslint-disable promise/prefer-await-to-then */ | ||
promise.then(resolve).catch(reject); | ||
delay(ms).then(() => { | ||
if (supportsAbortController) { | ||
abortController.abort(); | ||
} | ||
const timeout = (promise, ms, abortController) => | ||
new Promise((resolve, reject) => { | ||
const timeoutID = safeTimeout(() => { | ||
if (supportsAbortController) { | ||
abortController.abort(); | ||
} | ||
reject(new TimeoutError()); | ||
}).catch(reject); | ||
/* eslint-enable promise/prefer-await-to-then */ | ||
}); | ||
reject(new TimeoutError()); | ||
}, reject, ms); | ||
/* eslint-disable promise/prefer-await-to-then */ | ||
promise | ||
.then(resolve) | ||
.catch(reject) | ||
.then(() => { | ||
clearTimeout(timeoutID); | ||
}); | ||
/* eslint-enable promise/prefer-await-to-then */ | ||
}); | ||
const normalizeRequestMethod = input => requestMethods.includes(input) ? input.toUpperCase() : input; | ||
@@ -142,0 +151,0 @@ |
{ | ||
"name": "ky", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "Tiny and elegant HTTP client based on the browser Fetch API", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -15,7 +15,7 @@ <div align="center"> | ||
[![Build Status](https://travis-ci.com/sindresorhus/ky.svg?branch=master)](https://travis-ci.com/sindresorhus/ky) [![codecov](https://codecov.io/gh/sindresorhus/ky/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/ky) | ||
[![Build Status](https://travis-ci.com/sindresorhus/ky.svg?branch=master)](https://travis-ci.com/sindresorhus/ky) [![codecov](https://codecov.io/gh/sindresorhus/ky/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/ky) [![](https://badgen.net/bundlephobia/minzip/ky)](https://bundlephobia.com/result?p=ky) | ||
Ky targets [modern browsers](#browser-support) and [Deno](https://github.com/denoland/deno). For older browsers, you will need to transpile and use a [`fetch` polyfill](https://github.com/github/fetch). For Node.js, check out [Got](https://github.com/sindresorhus/got). For isomorphic needs (like SSR), check out [`ky-universal`](https://github.com/sindresorhus/ky-universal). | ||
1 KB *(minified & gzipped)*, one file, and no dependencies. | ||
It's just a tiny file with no dependencies. | ||
@@ -259,3 +259,3 @@ | ||
await ky('https://example.com', { | ||
onProgress: (progress, chunk) => { | ||
onDownloadProgress: (progress, chunk) => { | ||
// Example output: | ||
@@ -262,0 +262,0 @@ // `0% - 0 of 1271 bytes` |
39
umd.js
@@ -124,24 +124,33 @@ (function (global, factory) { | ||
const delay = ms => new Promise((resolve, reject) => { | ||
const safeTimeout = (resolve, reject, ms) => { | ||
if (ms > 2147483647) { // The maximum value of a 32bit int (see #117) | ||
reject(new RangeError('The `timeout` option cannot be greater than 2147483647')); | ||
} else { | ||
setTimeout(resolve, ms); | ||
} | ||
}); | ||
return setTimeout(resolve, ms); | ||
}; | ||
const delay = ms => new Promise((resolve, reject) => safeTimeout(resolve, reject, ms)); | ||
// `Promise.race()` workaround (#91) | ||
const timeout = (promise, ms, abortController) => new Promise((resolve, reject) => { | ||
/* eslint-disable promise/prefer-await-to-then */ | ||
promise.then(resolve).catch(reject); | ||
delay(ms).then(() => { | ||
if (supportsAbortController) { | ||
abortController.abort(); | ||
} | ||
const timeout = (promise, ms, abortController) => | ||
new Promise((resolve, reject) => { | ||
const timeoutID = safeTimeout(() => { | ||
if (supportsAbortController) { | ||
abortController.abort(); | ||
} | ||
reject(new TimeoutError()); | ||
}).catch(reject); | ||
/* eslint-enable promise/prefer-await-to-then */ | ||
}); | ||
reject(new TimeoutError()); | ||
}, reject, ms); | ||
/* eslint-disable promise/prefer-await-to-then */ | ||
promise | ||
.then(resolve) | ||
.catch(reject) | ||
.then(() => { | ||
clearTimeout(timeoutID); | ||
}); | ||
/* eslint-enable promise/prefer-await-to-then */ | ||
}); | ||
const normalizeRequestMethod = input => requestMethods.includes(input) ? input.toUpperCase() : input; | ||
@@ -148,0 +157,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
44175
844