{"name":"is-network-error","version":"1.3.1","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.1","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":"a2a86b80ffd6b05b774755c73c8aaab16597e58d","tarball":"http://registry-npm.ywwl.com/is-network-error/download/is-network-error-1.3.1.tgz","fileCount":5,"integrity":"sha512-6QCxa49rQbmUWLfk0nuGqzql9U8uaV2H6279bRErPBHe/109hCzsLUBUHfbEtvLIHBd6hyXbgedBSHevm43Edw==","signatures":[{"sig":"MEYCIQC4DKTSADUokMxccEqY+dF50uL4XA3NRj/gTkMxavl2xAIhAOuqHyXpewsqPxTz2zeCCcL6CD1pXeNusSFp6pBTpi2D","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5182,"size":2469,"noattachment":false,"key":"/is-network-error/-/is-network-error-1.3.1.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":"ca6cca4f05caf415515d7646e42b1edc82927082","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":"11.8.0","description":"Check if a value is a Fetch network error","directories":{},"sideEffects":false,"_nodeVersion":"25.6.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","tsd":"^0.29.0"},"_npmOperationalInternal":{"tmp":"tmp/is-network-error_1.3.1_1772113906719_0.12846963177350545","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":1772113906844,"_cnpm_publish_time":1772113906844,"dist-tags":{"latest":"1.3.2"}}