{"name":"is-network-error","version":"1.3.2","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"},"sideEffects":false,"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"},"gitHead":"b039fe8bb8da3607f8fb6a2505c40eb03aac5889","types":"./index.d.ts","_id":"is-network-error@1.3.2","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"homepage":"https://github.com/sindresorhus/is-network-error#readme","_nodeVersion":"25.8.0","_npmVersion":"11.12.0","dist":{"integrity":"sha512-PhBY86zaxNZUuWP6h13Vu5oFe0XY6/UlKzQnYFELzGVHygP3MxmvTfYSG7GN3aIab/iWudSMgjSnG9Dq+nHrgA==","shasum":"9460bc30f8419a4bca77114f4de88a3ee5e0c519","tarball":"http://registry-npm.ywwl.com/is-network-error/download/is-network-error-1.3.2.tgz","fileCount":5,"unpackedSize":5248,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC/QV6HCpzcWgG/pkS7/wwBUUUshhAe6syDzI/uUWv1NwIgXeGuuX7u5mofrYHxyOD0i1CByP3G8o+d5DQ0oQBd0PQ="}],"size":2480,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.3.2.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/is-network-error_1.3.2_1778221069324_0.6273968229033151"},"_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 across Node.js, Bun, Deno, and browsers.\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): value is TypeError`\n\nReturns `true` if the given value is a Fetch network error, otherwise `false`.\n\nThis function acts as a type guard, narrowing the type to `TypeError` when it returns `true`.\n","publish_time":1778221069465,"_cnpm_publish_time":1778221069465,"dist-tags":{"latest":"1.3.2"}}