{"name":"is-network-error","version":"1.0.0","description":"Check if a value is a Fetch network error","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/is-network-error.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"88b46c29fcb69700ab8919be1fd322a234ccbf40","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_id":"is-network-error@1.0.0","_nodeVersion":"16.20.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-P3fxi10Aji2FZmHTrMPSNFbNC6nnp4U5juPAIjXPHkUNubi4+qK7vvdsaNpAUwXslhYm9oyjEYTxs1xd/+Ph0w==","shasum":"757d7af42263f18f616626e63af12abb19002bbc","tarball":"http://registry-npm.ywwl.com/is-network-error/download/is-network-error-1.0.0.tgz","fileCount":5,"unpackedSize":4460,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFhVjNkxVQGsWk3mbp3D0lwdTU8iEbx2CuqpRdB0VmY9AiEAmRketzkY1t6lHRBY4VM4BQknciW12a5GCg8k8/aeWJQ="}],"size":2190,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.0.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/is-network-error_1.0.0_1695737709369_0.7316419387319419"},"_hasShrinkwrap":false,"readme":"# is-network-error\n\n> Check if a value is a [Fetch network error](https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions)\n\nThis can be useful when you want to do something specific when a network error happens without catching other Fetch-related errors.\n\nUnfortunately, Fetch network errors are [not standardized](https://github.com/whatwg/fetch/issues/526) and differ among implementations. This package handles the differences.\n\nFor instance, [`p-retry`](https://github.com/sindresorhus/p-retry) uses this package to retry on network errors.\n\n## Install\n\n```sh\nnpm install is-network-error\n```\n\n## Usage\n\n```js\nimport isNetworkError from 'is-network-error';\n\nasync function getUnicorns() {\n\ttry {\n\t\tconst response = await fetch('unicorns.json');\n\t\treturn await response.json();\n\t} catch (error) {\n\t\tif (isNetworkError(error)) {\n\t\t\treturn localStorage.getItem('…');\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nconsole.log(await getUnicorns());\n```\n\n## API\n\n### `isNetworkError(value: unknown): boolean`\n\nReturns `true` if the given value is a Fetch network error, otherwise `false`.\n","publish_time":1695737709619,"_cnpm_publish_time":1695737709619,"dist-tags":{"latest":"1.3.2"}}