{"name":"ky-universal","version":"0.7.0","description":"Use Ky in both Node.js and browsers","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/ky-universal.git"},"funding":"https://github.com/sindresorhus/ky-universal?sponsor=1","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=10.16"},"scripts":{"test":"xo && ava"},"keywords":["ky","universal","isomorphic","browser","browsers","node","react","vue","ssr","fetch","request","requests","http","https","fetching","get","url","curl","wget","net","network","ajax","api","rest","xhr","browser","got","axios","node-fetch"],"dependencies":{"abort-controller":"^3.0.0","node-fetch":"^3.0.0-beta.6-exportfix"},"devDependencies":{"ava":"^2.4.0","ky":"^0.17.0","xo":"^0.25.3"},"peerDependencies":{"ky":">=0.17.0","web-streams-polyfill":">=2.0.0"},"peerDependenciesMeta":{"web-streams-polyfill":{"optional":true}},"browser":"browser.js","ava":{"register":["."]},"gitHead":"3eca77b01a3b4139a95bfe3567406ca83d7f5485","bugs":{"url":"https://github.com/sindresorhus/ky-universal/issues"},"homepage":"https://github.com/sindresorhus/ky-universal#readme","_id":"ky-universal@0.7.0","_nodeVersion":"10.20.1","_npmVersion":"6.14.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-lJ39wTuCor/jcNqXd4jvNWw8Rq0eRYJqcof4sjF4aY0sfoj87aFiSKy1Vur7mQ8Jma29rG4qs6SRSeSVatKYlQ==","shasum":"c51406190f724f42e624904d314066a526198db1","tarball":"http://registry-npm.ywwl.com/ky-universal/download/ky-universal-0.7.0.tgz","fileCount":6,"unpackedSize":6617,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeziL/CRA9TVsSAnZWagAA3MoQAJem5YWx5CXPkejxfW6m\nGov6dGqFX6dJ78rw1IQWmVNOx+zsTwbnfR3w4Ry5CH/WTAveelN3zEUPemPp\nrCK1HsNSZXtHTRYOCr3GeCeuWDtYvvoGi4QcHbuVHg3mw8Sb0visWy8VLOYi\noU0rs/lnYaMa4lsX9hs9cqj/mM3t3MLzMolUjDRnNvtommDp3E+CHCRvnTek\nnxBAmGQbcrQSgateqvTPeH7fHNOR1rpLdmyBGWha/PFo1Wsrsy+PMd9AAlP3\n0rNuyccclyMq/5iLa2kB+t6r3v+h/qTmHmaSJEcV5tSfuhVnK0HUwMrAjZWp\ntyVKK9yPkgXSWagR9f2thEudklxqGquNkuw2e/jE583Vc97GuxL/MDy7kA8n\n6HOrNaHxlVq9KC1klu5EJg1/KUj/s8f+rs72BYeRIY+tzxWnTcTDL62DwySx\neaql3RBLdCpaJVNmOSXXqb++0A26ZbFm6ZvF+XK12h03KrByxlP1JnRPJIPQ\nspD4Q+k5aVSJZWb87xe2aWPMBhYQmxKbHLqYscyzXi9/kXk52l7dzkoGdOGi\na2bqysPjKA1LZiYESOr7yTkrzE8cMg2CQ2rB4j7RK5JnpncL0FE12xxFQKa2\nB3Blxcl/yTgrJGEigiBhMtZtb1aOPltbNW2fJbRG0kI0nTLG+LsdfBDAJwmF\nxlw2\r\n=U82i\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA9YeP4adVByGM+eSJu8XhlPlkOLFSvHV6M5DQ+cIWJWAiAC8VE9A9dAgUfTPLdfEaUdIxSlZv4ehv3Pz6IVpJVNrQ=="}],"size":3067,"noattachment":false,"key":"/ky-universal/-/ky-universal-0.7.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ky-universal_0.7.0_1590567678956_0.14584093749242077"},"_hasShrinkwrap":false,"readme":"# ky-universal\n\n> Use Ky in both Node.js and browsers\n\n[Ky](https://github.com/sindresorhus/ky) is made for browsers, but this package makes it possible to use it in Node.js too, by polyfilling most of the required browser APIs using [`node-fetch`](https://github.com/bitinn/node-fetch).\n\nThis package can be useful for:\n- Isomorphic code\n- Web apps (React, Vue.js, etc.) that use server-side rendering (SSR)\n- Testing browser libraries using a Node.js test runner\n\n**Note:** Before opening an issue, make sure it's an issue with Ky and not its polyfills. Generally, if something works in the browser, but not in Node.js, it's an issue with `node-fetch`.\n\nKeep in mind that Ky targets [modern browsers](https://github.com/sindresorhus/ky#browser-support) when used in the browser. For older browsers, you will need to transpile and use a [`fetch` polyfill](https://github.com/github/fetch).\n\n## Install\n\n```sh\nnpm install ky ky-universal\n```\n\n*Note that you also need to install `ky`.*\n\n## Usage\n\n```js\nimport ky from 'ky-universal';\n\nconst parsed = await ky('https://httpbin.org/json').json();\n\n// …\n```\n\n## `ReadableStream` support\n\nFor [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) support, also install [`web-streams-polyfill`](https://github.com/MattiasBuelens/web-streams-polyfill):\n\n```\n$ npm install web-streams-polyfill\n```\n\nYou can then use it normally:\n\n```js\nimport ky from 'ky-universal';\n\nconst {body} = await ky('https://httpbin.org/bytes/16');\nconst {value} = await body.getReader().read();\nconst result = new TextDecoder('utf-8').decode(value);\n\n// …\n```\n\n## API\n\nThe API is exactly the same as the [Ky API](https://github.com/sindresorhus/ky#api), including the [named exports](https://github.com/sindresorhus/ky#httperror).\n\n## FAQ\n\n#### How do I use this with a web app (React, Vue.js, etc.) that uses server-side rendering (SSR)?\n\nUse it like you would use Ky:\n\n```js\nimport ky from 'ky-universal';\n\nconst parsed = await ky('https://httpbin.org/json').json();\n\n// …\n```\n\nWebpack will ensure the polyfills are only included and used when the app is rendered on the server-side.\n\n#### How do I test a browser library that uses Ky in AVA?\n\nPut the following in package.json:\n\n```json\n{\n\t\"ava\": {\n\t\t\"require\": [\n\t\t\t\"ky-universal\"\n\t\t]\n\t}\n}\n```\n\nThe library that uses Ky will now *just work* in AVA tests.\n\n#### `clone()` hangs with a large response in Node - What should I do?\n\nStreams in Node.js have a smaller internal buffer size (16 kB, aka `highWaterMark`) than browsers (>1 MB, not consistent across browsers). When using Ky, the default `highWaterMark` is set to 10 MB, so you shouldn't encounter many issues related to that.\n\nHowever, you can specify a custom `highWaterMark` if needed:\n\n```js\nimport ky from 'ky-universal';\n\nconst response = await ky('https://example.com', {\n\t// 20 MB\n\thighWaterMark: 1000 * 1000 * 20\n});\n\nconst data = await response.clone().buffer();\n```\n\n## Related\n\n- [ky](https://github.com/sindresorhus/ky) - Tiny and elegant HTTP client based on the browser Fetch API\n- [got](https://github.com/sindresorhus/got) - Simplified HTTP requests in Node.js\n","publish_time":1590567679051,"_cnpm_publish_time":1590567679051,"dist-tags":{"latest":"1.0.0"}}