{"name":"ky-universal","version":"0.11.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":"https://sindresorhus.com"},"type":"module","exports":{"node":"./index.js","default":"./browser.js"},"engines":{"node":">=14.16"},"scripts":{"test":"xo && ava && tsd"},"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.2.10"},"devDependencies":{"ava":"^4.3.3","ky":"^0.31.4","tsd":"^0.24.1","xo":"^0.52.4"},"peerDependencies":{"ky":">=0.31.4","web-streams-polyfill":">=3.2.1"},"peerDependenciesMeta":{"web-streams-polyfill":{"optional":true}},"browser":"browser.js","types":"./index.d.ts","gitHead":"349bbe429dd9a9bed7d1cf18d1a2c4ff4b656fe0","bugs":{"url":"https://github.com/sindresorhus/ky-universal/issues"},"homepage":"https://github.com/sindresorhus/ky-universal#readme","_id":"ky-universal@0.11.0","_nodeVersion":"16.16.0","_npmVersion":"8.3.2","dist":{"integrity":"sha512-65KyweaWvk+uKKkCrfAf+xqN2/epw1IJDtlyCPxYffFCMR8u1sp2U65NtWpnozYfZxQ6IUzIlvUcw+hQ82U2Xw==","shasum":"f5edf857865aaaea416a1968222148ad7d9e4017","tarball":"http://registry-npm.ywwl.com/ky-universal/download/ky-universal-0.11.0.tgz","fileCount":7,"unpackedSize":6750,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDKeU9D5Y1G58NeYZysFjtzN4m0ZSf9in3ca7fSREYIpAiEAwPAHANlV+8TCm/0ecFTO+IxUQgCLb7K55lkGKMzw2JA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjRpmGACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo4nQ/+LTRxkOQXwHNwOYIBqDI06aECWSxr38ySeN+XlcLKY3677iUf\r\nzmfSwGWie0d/zsXwWpKhfdhly+KkmhZHu9VeaONW08qXxHFbs4E1CegmRjQJ\r\nhplno6DiwcoGo0rD1JdeX/wDwulYl+2kkFVu2UmaAraF0FE7JCLhM3wICoOB\r\nOmoAmxAXMfw7cR3iE7QoZ9KZ/oGCuMzFGl0u/0dq5yeojm7pZ5n5jOHSLDlf\r\nRVDSwZvhyB8Sq/9PpylcWBGLBYCKmatdHYNSJBdi0vbOdc+q5i/1ZW+C7teb\r\nfO8T4QZmIAMnA5mWXYA4CaqgyE2sQMEz/jyVsxHxFkEzCOXcRlY6Ykm6LmW/\r\nAdr928gKba6PHZ3fM2rjF+lyjZnTIJpujbV8qF9cho+7GmDXQHF9So634qj/\r\n6+Z4lTcCX607Pv4YDB5z3N9THT918+D5DJTWqg0Dxkjt0lCRcsLkQQUYUvpo\r\nTCj0FYVfIdYl4Rxy+FtA/LNOol1haOYr3OEKcCqoA/jb7fSWWVpVxHdyJB41\r\n7aE5VtP8vqYXP3kMNEC0c0xVhPZrFI3pTDPh7ryMO2UufOw9w08ldR51ZAEx\r\ntfVUiCjmraRS6GkJVu/JDW9VjSblddXRP/7+ROmWgDM60z2/fr/BLfgO9rIz\r\nL3lrSdy1mjuZU/mCAOkdCR+6sOi6pUaGI8Q=\r\n=bsji\r\n-----END PGP SIGNATURE-----\r\n","size":3063,"noattachment":false,"key":"/ky-universal/-/ky-universal-0.11.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ky-universal_0.11.0_1665571206780_0.751019981799179"},"_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":1665571206958,"_cnpm_publish_time":1665571206958,"dist-tags":{"latest":"1.0.0"}}