Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ky

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ky - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

8

index.d.ts

@@ -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;

@@ -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 @@

@@ -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 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc