{"_id":"make-cancellable-promise","_rev":"4542609","name":"make-cancellable-promise","description":"Make any Promise cancellable.","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"time":{"modified":"2026-04-09T15:47:34.000Z","created":"2019-07-17T11:40:36.240Z","2.0.0":"2025-03-20T23:07:20.366Z","1.3.2":"2023-10-18T13:22:48.088Z","1.3.1":"2023-05-29T17:26:25.293Z","1.3.0":"2023-05-29T14:09:49.662Z","1.2.1":"2023-02-02T08:25:34.093Z","1.2.0":"2023-01-10T07:12:58.943Z","1.1.0":"2021-09-13T21:40:31.283Z","1.0.0":"2019-07-17T11:40:36.240Z"},"users":{},"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"repository":{"type":"git","url":"git+https://github.com/wojtekmaj/make-cancellable-promise.git"},"versions":{"2.0.0":{"name":"make-cancellable-promise","version":"2.0.0","description":"Make any Promise cancellable.","type":"module","sideEffects":false,"main":"./dist/index.js","source":"./src/index.ts","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./*":"./*"},"scripts":{"build":"tsc --project tsconfig.build.json","clean":"rimraf dist","format":"biome format","lint":"biome lint","prepack":"yarn clean && yarn build","test":"yarn lint && yarn tsc && yarn format && yarn unit","tsc":"tsc","unit":"vitest"},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"@biomejs/biome":"1.9.0","husky":"^9.0.0","rimraf":"^6.0.0","typescript":"^5.5.2","vitest":"^3.0.5"},"publishConfig":{"access":"public","provenance":true},"repository":{"type":"git","url":"git+https://github.com/wojtekmaj/make-cancellable-promise.git"},"funding":"https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1","packageManager":"yarn@4.3.1","_id":"make-cancellable-promise@2.0.0","bugs":{"url":"https://github.com/wojtekmaj/make-cancellable-promise/issues"},"homepage":"https://github.com/wojtekmaj/make-cancellable-promise#readme","_integrity":"sha512-3SEQqTpV9oqVsIWqAcmDuaNeo7yBO3tqPtqGRcKkEo0lrzD3wqbKG9mkxO65KoOgXqj+zH2phJ2LiAsdzlogSw==","_resolved":"/home/runner/work/make-cancellable-promise/make-cancellable-promise/package.tgz","_from":"file:package.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"shasum":"d582b3ea435205e31653dead33a10bea0696c2fa","size":2942,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-2.0.0.tgz"},"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/make-cancellable-promise_2.0.0_1742512040197_0.47018152869786123"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-20T23:07:20.366Z","publish_time":1742512040366,"_source_registry_name":"default","_cnpm_publish_time":1742512040366},"1.3.2":{"name":"make-cancellable-promise","version":"1.3.2","description":"Make any Promise cancellable.","type":"module","sideEffects":false,"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","source":"./src/index.ts","types":"./dist/cjs/index.d.ts","exports":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"scripts":{"build":"yarn build-esm && yarn build-cjs && yarn build-cjs-package","build-esm":"tsc --project tsconfig.build.json --outDir dist/esm","build-cjs":"tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs --verbatimModuleSyntax false","build-cjs-package":"echo '{\n  \"type\": \"commonjs\"\n}' > dist/cjs/package.json","clean":"rimraf dist","lint":"eslint .","prepack":"yarn clean && yarn build","prettier":"prettier --check . --cache","test":"yarn lint && yarn tsc && yarn prettier && yarn unit","tsc":"tsc --noEmit","unit":"vitest"},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"eslint":"^8.26.0","eslint-config-wojtekmaj":"^0.9.0","husky":"^8.0.0","lint-staged":"^14.0.0","prettier":"^3.0.0","rimraf":"^3.0.0","typescript":"^5.0.0","vitest":"^0.34.0"},"publishConfig":{"access":"public","provenance":true},"repository":{"type":"git","url":"git+https://github.com/wojtekmaj/make-cancellable-promise.git"},"funding":"https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1","packageManager":"yarn@3.1.0","bugs":{"url":"https://github.com/wojtekmaj/make-cancellable-promise/issues"},"homepage":"https://github.com/wojtekmaj/make-cancellable-promise#readme","_id":"make-cancellable-promise@1.3.2","_integrity":"sha512-GCXh3bq/WuMbS+Ky4JBPW1hYTOU+znU+Q5m9Pu+pI8EoUqIHk9+tviOKC6/qhHh8C4/As3tzJ69IF32kdz85ww==","_resolved":"/home/runner/work/make-cancellable-promise/make-cancellable-promise/package.tgz","_from":"file:package.tgz","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"shasum":"993c8c8b79cff13c74fa93de0bd8a17fe66685c1","size":3333,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-1.3.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-1.3.2.tgz"},"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-cancellable-promise_1.3.2_1697635367813_0.5928588901411476"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-18T13:22:48.088Z","publish_time":1697635368088,"_source_registry_name":"default","_cnpm_publish_time":1697635368088},"1.3.1":{"name":"make-cancellable-promise","version":"1.3.1","description":"Make any Promise cancellable.","type":"module","sideEffects":false,"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","source":"./src/index.ts","types":"./dist/cjs/index.d.ts","exports":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"scripts":{"build":"yarn build-esm && yarn build-cjs","build-esm":"tsc --project tsconfig.build.json --outDir dist/esm --module esnext","build-cjs":"tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs && echo '{\n  \"type\": \"commonjs\"\n}' > dist/cjs/package.json","clean":"rimraf dist","lint":"eslint .","prepack":"yarn clean && yarn build","prettier":"prettier --check . --cache","test":"yarn lint && yarn tsc && yarn prettier && yarn unit","tsc":"tsc --noEmit","unit":"vitest run"},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"eslint":"^8.26.0","eslint-config-wojtekmaj":"^0.8.4","husky":"^8.0.0","prettier":"^2.7.0","pretty-quick":"^3.1.0","rimraf":"^3.0.0","typescript":"^5.0.0","vitest":"^0.30.1"},"repository":{"type":"git","url":"https://github.com/wojtekmaj/make-cancellable-promise.git"},"funding":"https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1","packageManager":"yarn@3.1.0","_id":"make-cancellable-promise@1.3.1","gitHead":"a68efc0e74fa837b18c30699e958d9d87a24a280","dist":{"shasum":"3bd89704c75afe6251cdd6a82baca1fcfbd2c792","size":3147,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-1.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-1.3.1.tgz"},"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-cancellable-promise_1.3.1_1685381185114_0.493868532045211"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-05-29T17:26:25.293Z","publish_time":1685381185293,"_source_registry_name":"default","_cnpm_publish_time":1685381185293},"1.3.0":{"name":"make-cancellable-promise","version":"1.3.0","description":"Make any Promise cancellable.","type":"module","sideEffects":false,"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","source":"./src/index.ts","types":"./dist/cjs/index.d.ts","exports":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"scripts":{"build":"yarn build-esm && yarn build-cjs","build-esm":"tsc --project tsconfig.build.json --outDir dist/esm --module esnext","build-cjs":"tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs","clean":"rimraf dist","lint":"eslint .","prepack":"yarn clean && yarn build","prettier":"prettier --check . --cache","test":"yarn lint && yarn tsc && yarn prettier && yarn unit","tsc":"tsc --noEmit","unit":"vitest run"},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"eslint":"^8.26.0","eslint-config-wojtekmaj":"^0.8.4","husky":"^8.0.0","prettier":"^2.7.0","pretty-quick":"^3.1.0","rimraf":"^3.0.0","typescript":"^5.0.0","vitest":"^0.30.1"},"repository":{"type":"git","url":"https://github.com/wojtekmaj/make-cancellable-promise.git"},"funding":"https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1","packageManager":"yarn@3.1.0","_id":"make-cancellable-promise@1.3.0","gitHead":"297947477b5247593b1beb76cccb8b956d4628b8","dist":{"shasum":"109dd373eb6a2b0e1e04af9c8ced3b3f58c97a05","size":3069,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-1.3.0.tgz"},"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-cancellable-promise_1.3.0_1685369389467_0.0007281799760125995"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-05-29T14:09:49.662Z","publish_time":1685369389662,"_source_registry_name":"default","_cnpm_publish_time":1685369389662},"1.2.1":{"name":"make-cancellable-promise","version":"1.2.1","description":"Make any Promise cancellable.","main":"dist/cjs/index.js","module":"dist/esm/index.js","source":"src/index.ts","types":"dist/cjs/index.d.ts","sideEffects":false,"scripts":{"build":"yarn build-esm && yarn build-cjs","build-esm":"tsc --project tsconfig.build.json --outDir dist/esm --module esnext","build-cjs":"tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs","clean":"rimraf dist","jest":"jest","lint":"eslint src","prepack":"yarn clean && yarn build","prettier":"prettier --check . --cache","test":"yarn lint && yarn tsc && yarn prettier && yarn jest","tsc":"tsc --noEmit"},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"@babel/core":"^7.15.0","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.18.6","@types/jest":"^29.0.0","@typescript-eslint/eslint-plugin":"^5.41.0","@typescript-eslint/parser":"^5.44.0","eslint":"^8.26.0","eslint-config-wojtekmaj":"^0.7.1","husky":"^8.0.0","jest":"^29.0.0","prettier":"^2.7.0","pretty-quick":"^3.1.0","rimraf":"^3.0.0","typescript":"^4.9.4"},"resolutions":{"semver@7.0.0":"^7.0.0"},"repository":{"type":"git","url":"https://github.com/wojtekmaj/make-cancellable-promise.git"},"funding":"https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1","packageManager":"yarn@3.1.0","_id":"make-cancellable-promise@1.2.1","gitHead":"de03f6afab63e099a415b111def7e950a8f24ad4","dist":{"shasum":"b644fbc1ead91ef4968ac63da762476a462732ac","size":3152,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-1.2.1.tgz"},"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-cancellable-promise_1.2.1_1675326333827_0.29707729804066396"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-02-02T08:25:34.093Z","publish_time":1675326334093,"_cnpm_publish_time":1675326334093},"1.2.0":{"name":"make-cancellable-promise","version":"1.2.0","description":"Make any Promise cancellable.","main":"dist/cjs/index.js","module":"dist/esm/index.js","source":"src/index.ts","types":"src/index.ts","sideEffects":false,"scripts":{"build":"yarn build-esm && yarn build-cjs","build-esm":"tsc --project tsconfig.build.json --outDir dist/esm --module esnext","build-cjs":"tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs","clean":"rimraf dist","jest":"jest","lint":"eslint src","prepack":"yarn clean && yarn build","prettier":"prettier --check . --cache","test":"yarn lint && yarn tsc && yarn prettier && yarn jest","tsc":"tsc --noEmit"},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"@babel/core":"^7.15.0","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.18.6","@types/jest":"^29.0.0","@typescript-eslint/eslint-plugin":"^5.41.0","@typescript-eslint/parser":"^5.44.0","eslint":"^8.26.0","eslint-config-wojtekmaj":"^0.7.1","husky":"^8.0.0","jest":"^29.0.0","prettier":"^2.7.0","pretty-quick":"^3.1.0","rimraf":"^3.0.0","typescript":"^4.9.4"},"resolutions":{"semver@7.0.0":"^7.0.0"},"repository":{"type":"git","url":"https://github.com/wojtekmaj/make-cancellable-promise.git"},"funding":"https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1","packageManager":"yarn@3.1.0","_id":"make-cancellable-promise@1.2.0","gitHead":"13fc5ef2750ed3d3a31a633c9dd523e68be69d2b","dist":{"shasum":"a71ce4d000e9f3b26dab95dcc39947506440e792","size":3126,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-1.2.0.tgz"},"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-cancellable-promise_1.2.0_1673334778788_0.7783870042345262"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-01-10T07:12:58.943Z","publish_time":1673334778943,"_cnpm_publish_time":1673334778943},"1.1.0":{"name":"make-cancellable-promise","version":"1.1.0","description":"Make any Promise cancellable.","main":"dist/umd/index.js","module":"dist/esm/index.js","source":"src/index.js","sideEffects":false,"scripts":{"build":"yarn build-esm && yarn build-umd","build-esm":"BABEL_ENV=production-esm babel src -d dist/esm --ignore \"**/*.spec.js\"","build-umd":"BABEL_ENV=production-umd babel src -d dist/umd --ignore \"**/*.spec.js\"","clean":"rimraf dist","jest":"jest","jest-coverage":"jest --coverage","lint":"eslint src/ --ext .jsx,.js","prepack":"yarn clean && yarn build","test":"yarn lint && yarn jest"},"jest":{},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"@babel/cli":"^7.8.0","@babel/core":"^7.9.0","@babel/preset-env":"^7.9.0","eslint":"~7.19.0","eslint-config-wojtekmaj":"^0.5.0","jest":"^26.6.0","rimraf":"^3.0.0"},"resolutions":{"semver@7.0.0":"^7.0.0"},"repository":{"type":"git","url":"https://github.com/wojtekmaj/make-cancellable-promise.git"},"funding":"https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1","_id":"make-cancellable-promise@1.1.0","dist":{"shasum":"b4e9fcb31db3a27417e44f80cffa598ec9ac9f4e","size":3012,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-1.1.0.tgz"},"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-cancellable-promise_1.1.0_1631569231070_0.503243073019142"},"_hasShrinkwrap":false,"publish_time":1631569231283,"_cnpm_publish_time":1631569231283,"_cnpmcore_publish_time":"2021-12-16T18:01:41.896Z"},"1.0.0":{"name":"make-cancellable-promise","version":"1.0.0","description":"Make any Promise cancellable.","main":"dist/index.js","source":"src/index.js","scripts":{"build":"babel src -d dist --ignore **/__tests__,**/*.spec.js","clean":"rimraf dist","jest":"jest","jest-coverage":"jest --coverage","lint":"eslint src/ --ext .jsx,.js","prepublishOnly":"yarn clean && yarn build","test":"yarn lint && yarn jest"},"jest":{},"keywords":["promise","promise-cancelling"],"author":{"name":"Wojciech Maj","email":"kontakt@wojtekmaj.pl"},"license":"MIT","devDependencies":{"@babel/cli":"^7.5.0","@babel/core":"^7.5.0","@babel/preset-env":"^7.5.0","eslint":"^5.16.0","eslint-config-airbnb-base":"^13.1.0","eslint-plugin-import":"^2.18.0","jest":"^24.8.0","rimraf":"^2.6.3"},"repository":{"type":"git","url":"https://github.com/wojtekmaj/make-cancellable-promise.git"},"licenseText":"MIT License\n\nCopyright (c) 2019 Wojciech Maj\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"make-cancellable-promise@1.0.0","dist":{"shasum":"826214115b0827ca7a45ba204df7c31546243870","size":3120,"noattachment":false,"key":"/make-cancellable-promise/-/make-cancellable-promise-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/make-cancellable-promise/download/make-cancellable-promise-1.0.0.tgz"},"maintainers":[{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"}],"_npmUser":{"name":"wojtekmaj","email":"kontakt@wojtekmaj.pl"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-cancellable-promise_1.0.0_1563363636094_0.3400210026005539"},"_hasShrinkwrap":false,"publish_time":1563363636240,"_cnpm_publish_time":1563363636240,"_cnpmcore_publish_time":"2021-12-16T18:01:42.176Z"}},"readme":"[![npm](https://img.shields.io/npm/v/make-cancellable-promise.svg)](https://www.npmjs.com/package/make-cancellable-promise) ![downloads](https://img.shields.io/npm/dt/make-cancellable-promise.svg) [![CI](https://github.com/wojtekmaj/make-cancellable-promise/actions/workflows/ci.yml/badge.svg)](https://github.com/wojtekmaj/make-cancellable-promise/actions)\n\n# Make-Cancellable-Promise\n\nMake any Promise cancellable.\n\n## tl;dr\n\n- Install by executing `npm install make-cancellable-promise` or `yarn add make-cancellable-promise`.\n- Import by adding `import makeCancellablePromise from 'make-cancellable-promise`.\n- Do stuff with it!\n  ```ts\n  const { promise, cancel } = makeCancellablePromise(myPromise);\n  ```\n\n## User guide\n\n### makeCancellablePromise(myPromise)\n\nA function that returns an object with two properties:\n\n`promise` and `cancel`. `promise` is a wrapped around your promise. `cancel` is a function which stops `.then()` and `.catch()` from working on `promise`, even if promise passed to `makeCancellablePromise` resolves or rejects.\n\n#### Usage\n\n```ts\nconst { promise, cancel } = makeCancellablePromise(myPromise);\n```\n\nTypically, you'd want to use `makeCancellablePromise` in React components. If you call `setState` on an unmounted component, React will throw an error.\n\nHere's how you can use `makeCancellablePromise` with React:\n\n```tsx\nfunction MyComponent() {\n  const [status, setStatus] = useState('initial');\n\n  useEffect(() => {\n    const { promise, cancel } = makeCancellable(fetchData());\n\n    promise.then(() => setStatus('success')).catch(() => setStatus('error'));\n\n    return () => {\n      cancel();\n    };\n  }, []);\n\n  const text = (() => {\n    switch (status) {\n      case 'pending':\n        return 'Fetching…';\n      case 'success':\n        return 'Success';\n      case 'error':\n        return 'Error!';\n      default:\n        return 'Click to fetch';\n    }\n  })();\n\n  return <p>{text}</p>;\n}\n```\n\n## License\n\nThe MIT License.\n\n## Author\n\n<table>\n  <tr>\n    <td >\n      <img src=\"https://avatars.githubusercontent.com/u/5426427?v=4&s=128\" width=\"64\" height=\"64\" alt=\"Wojciech Maj\">\n    </td>\n    <td>\n      <a href=\"https://github.com/wojtekmaj\">Wojciech Maj</a>\n    </td>\n  </tr>\n</table>\n","_attachments":{},"homepage":"https://github.com/wojtekmaj/make-cancellable-promise#readme","bugs":{"url":"https://github.com/wojtekmaj/make-cancellable-promise/issues"},"license":"MIT"}