Comparing version 0.9.1 to 0.10.0
@@ -36,3 +36,3 @@ /// <reference lib="dom"/> | ||
/** | ||
Options are the same as fetch, with some exceptions. | ||
Options are the same as `window.fetch`, with some exceptions. | ||
*/ | ||
@@ -145,3 +145,3 @@ export interface Options extends RequestInit { | ||
export interface Ky { | ||
declare const ky: { | ||
/** | ||
@@ -220,7 +220,5 @@ Fetch the given `url`. | ||
*/ | ||
extend(defaultOptions: Options): Ky; | ||
extend(defaultOptions: Options): typeof ky; | ||
} | ||
declare const ky: Ky; | ||
export default ky; |
23
index.js
@@ -66,9 +66,9 @@ /*! MIT License © Sindre Sorhus */ | ||
const responseTypes = [ | ||
'json', | ||
'text', | ||
'formData', | ||
'arrayBuffer', | ||
'blob' | ||
]; | ||
const responseTypes = { | ||
json: 'application/json', | ||
text: 'text/*', | ||
formData: 'multipart/form-data', | ||
arrayBuffer: '*/*', | ||
blob: '*/*' | ||
}; | ||
@@ -122,4 +122,7 @@ const retryMethods = new Set([ | ||
delay(ms).then(() => { | ||
if (supportsAbortController) { | ||
abortController.abort(); | ||
} | ||
reject(new TimeoutError()); | ||
abortController.abort(); | ||
}); | ||
@@ -208,2 +211,3 @@ /* eslint-enable promise/prefer-await-to-then */ | ||
const fn = async () => { | ||
await delay(1); | ||
let response = await this._fetch(); | ||
@@ -230,4 +234,5 @@ | ||
for (const type of responseTypes) { | ||
for (const [type, mimeType] of Object.entries(responseTypes)) { | ||
result[type] = async () => { | ||
headers.set('accept', mimeType); | ||
return (await result).clone()[type](); | ||
@@ -234,0 +239,0 @@ }; |
{ | ||
"name": "ky", | ||
"version": "0.9.1", | ||
"version": "0.10.0", | ||
"description": "Tiny and elegant HTTP client based on the browser Fetch API", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=8" | ||
}, | ||
@@ -16,0 +16,0 @@ "scripts": { |
@@ -120,3 +120,3 @@ <div align="center"> | ||
Returns a [`Response` object](https://developer.mozilla.org/en-US/docs/Web/API/Response) with [`Body` methods](https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods) added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range `200...299`. | ||
Returns a [`Response` object](https://developer.mozilla.org/en-US/docs/Web/API/Response) with [`Body` methods](https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods) added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, proper `Accept` header will be set depending on body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range `200...299`. | ||
@@ -380,2 +380,7 @@ ### ky.get(input, [options]) | ||
## Node.js support | ||
Ky requires Node.js 10 or later, but it indicates Node.js 8 in package.json so you can use it with Node.js 8 by polyfilling the globals without having Yarn fail on install. However, you should just use [`ky-universal`](https://github.com/sindresorhus/ky-universal). | ||
## Related | ||
@@ -382,0 +387,0 @@ |
23
umd.js
@@ -72,9 +72,9 @@ (function (global, factory) { | ||
const responseTypes = [ | ||
'json', | ||
'text', | ||
'formData', | ||
'arrayBuffer', | ||
'blob' | ||
]; | ||
const responseTypes = { | ||
json: 'application/json', | ||
text: 'text/*', | ||
formData: 'multipart/form-data', | ||
arrayBuffer: '*/*', | ||
blob: '*/*' | ||
}; | ||
@@ -128,4 +128,7 @@ const retryMethods = new Set([ | ||
delay(ms).then(() => { | ||
if (supportsAbortController) { | ||
abortController.abort(); | ||
} | ||
reject(new TimeoutError()); | ||
abortController.abort(); | ||
}); | ||
@@ -214,2 +217,3 @@ /* eslint-enable promise/prefer-await-to-then */ | ||
const fn = async () => { | ||
await delay(1); | ||
let response = await this._fetch(); | ||
@@ -236,4 +240,5 @@ | ||
for (const type of responseTypes) { | ||
for (const [type, mimeType] of Object.entries(responseTypes)) { | ||
result[type] = async () => { | ||
headers.set('accept', mimeType); | ||
return (await result).clone()[type](); | ||
@@ -240,0 +245,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
36492
690
400