1 | {
|
2 | "name": "@fatcherjs/middleware-aborter",
|
3 | "version": "1.0.0",
|
4 | "main": "dist/index.js",
|
5 | "module": "dist/index.esm.js",
|
6 | "browser": "dist/index.min.js",
|
7 | "typings": "dist/index.d.ts",
|
8 | "repository": "https://github.com/fatcherjs/middlewares/tree/master/packages/aborter",
|
9 | "license": "MIT",
|
10 | "files": [
|
11 | "dist"
|
12 | ],
|
13 | "peerDependencies": {
|
14 | "fatcher": "^1.0.0"
|
15 | },
|
16 | "scripts": {
|
17 | "dev": "rimraf dist && rollup -c rollup.config.ts -w",
|
18 | "build": "rimraf dist && rollup -c rollup.config.ts"
|
19 | },
|
20 | "readme": "# @fatcherjs/middleware-aborter\n\nA middleware for aborting fatcher request.\n\n## Install\n\n### NPM\n\n```bash\n>$ npm install @fatcherjs/middleware-aborter\n```\n\n### CDN\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/@fatcherjs/middleware-aborter/dist/index.min.js\"></script>\n```\n\n## Usage\n\n```ts\nimport { aborter } from '@fatcherjs/middleware-aborter';\nimport { fatcher, isAbortError } from 'fatcher';\n\nfatcher({\n url: '/bar/foo',\n middlewares: [\n aborter({\n timeout: 10 * 1000, // 10s\n onAbort: () => {\n console.log('Request is Aborted.');\n },\n }),\n ],\n})\n .then(res => {\n // Request success in 10s\n console.log(res);\n })\n .catch(err => {\n if (isAbortError(err)) {\n //Run error when request aborted.\n console.error(err);\n }\n\n // Other errors.\n });\n```\n\n## Options\n\n### timeout\n\n- Type: `number`\n- DefaultValue: `0`\n- Description:\n\nIf `timeout > 0`, will abort this request later.\n\nAborted request will throw a DOMException which can use `isAbortError` to confirm.\n\n### onAbort\n\n- Type: `(() => void) | null`\n- DefaultValue: `null`\n- Description:\n\nA callback when aborting this request.\n\n## License\n\n[MIT](../../LICENSE)\n"
|
21 | } |
\ | No newline at end of file |