{"name":"ky-universal","version":"1.0.0","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"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"ky-universal@1.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/ky-universal#readme","bugs":{"url":"https://github.com/sindresorhus/ky-universal/issues"},"dist":{"shasum":"b77889eea65f14b696f134a4f45ef469a0b807b9","tarball":"http://registry-npm.ywwl.com/ky-universal/download/ky-universal-1.0.0.tgz","fileCount":7,"integrity":"sha512-pWikiCD7CRRz3jopuLMRKThrSDDCYjUS5Z68g/qhdUDktL8JolN3rBwEwEwCuDPAK+1nuhXyqHBe2NGR6DMWqg==","signatures":[{"sig":"MEUCIQC8HYFJZW+PiU7P8mvpg8jfhXLKYPSwHwnN1jqb3XiCvQIgBIU3ZhMpGjrw+FkwT18pUxPQ51oNXuw5sR4Vh9/Ou6w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6517,"size":3010,"noattachment":false,"key":"/ky-universal/-/ky-universal-1.0.0.tgz"},"type":"module","types":"./index.d.ts","browser":"browser.js","engines":{"node":">=16"},"exports":{"node":"./index.js","types":"./index.d.ts","default":"./browser.js"},"funding":"https://github.com/sindresorhus/ky-universal?sponsor=1","gitHead":"3184bb8909e5dc349e273f4db507caaa6394a49a","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/ky-universal.git","type":"git"},"_npmVersion":"11.12.0","description":"Use Ky in both Node.js and browsers","directories":{},"sideEffects":false,"_nodeVersion":"25.8.0","dependencies":{"node-fetch":"^3.3.2"},"_hasShrinkwrap":false,"devDependencies":{"ky":"^0.33.3","xo":"^0.55.0","ava":"^5.3.1","tsd":"^0.28.1"},"peerDependencies":{"ky":">=0.33.0","web-streams-polyfill":">=3.2.1"},"peerDependenciesMeta":{"web-streams-polyfill":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/ky-universal_1.0.0_1774678851404_0.06695754582312152","host":"s3://npm-registry-packages-npm-production"},"deprecated":"The package is deprecated. Just use Ky directly.","readme":"# ky-universal\n\n> Use Ky in both Node.js and browsers\n\n**This package is deprecated. Just use Ky directly. It runs natively on Node.js and in 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```sh\nnpm 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":1774678851561,"_cnpm_publish_time":1774678851561,"dist-tags":{"latest":"1.0.0"}}