{"name":"is-network-error","version":"1.3.0","keywords":["network","error","fetch","whatwg","detect","check","typeerror"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"is-network-error@1.3.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/is-network-error#readme","bugs":{"url":"https://github.com/sindresorhus/is-network-error/issues"},"dist":{"shasum":"2ce62cbca444abd506f8a900f39d20b898d37512","tarball":"http://registry-npm.ywwl.com/is-network-error/download/is-network-error-1.3.0.tgz","fileCount":5,"integrity":"sha512-6oIwpsgRfnDiyEDLMay/GqCl3HoAtH5+RUKW29gYkL0QA+ipzpDLA16yQs7/RHCSu+BwgbJaOUqa4A99qNVQVw==","signatures":[{"sig":"MEYCIQD5YlqA9fVgLRt8cCZtSML3BqumqSTcqRr6bAADNLZtcAIhAO3xfp9w9E+Mo1FSVwPO2pMV2a1h5SjdxBumAehAz4TW","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4999,"size":2421,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.3.0.tgz"},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"b119a91971649acc9893efc5aba70be044213b60","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/is-network-error.git","type":"git"},"_npmVersion":"10.9.2","description":"Check if a value is a Fetch network error","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","tsd":"^0.29.0"},"_npmOperationalInternal":{"tmp":"tmp/is-network-error_1.3.0_1758213800006_0.10742027568507417","host":"s3://npm-registry-packages-npm-production"},"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":1758213800189,"_cnpm_publish_time":1758213800189,"dist-tags":{"latest":"1.3.2"}}