{"_id":"@blakgeek/cancellable-promise","_rev":"2-2a597c25e6300b45a188ce82e61836d1","name":"@blakgeek/cancellable-promise","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@blakgeek/cancellable-promise","version":"1.0.0","author":{"name":"blakgeek"},"license":"MIT","_id":"@blakgeek/cancellable-promise@1.0.0","maintainers":[{"name":"carloslawton","email":"blakgeek@gmail.com"}],"homepage":"https://github.com/blakgeek/cancellable-promise#readme","bugs":{"url":"https://github.com/blakgeek/cancellable-promise/issues"},"dist":{"shasum":"2cc36ad93995a9bf7dfe9910348d35dbfe459698","tarball":"https://registry.npmjs.org/@blakgeek/cancellable-promise/-/cancellable-promise-1.0.0.tgz","fileCount":12,"integrity":"sha512-W3VvAgCyUPlXv/YDIKTEJV4ww7kx7mEJtm+mOvtPOy+j2qgSlZY3s4Fc8JnZ/PgNKnANILqzWhb/zt/7xyI+UQ==","signatures":[{"sig":"MEQCIAeh/qXn5nV/PZNJFPCsjVOrmX43U7k9g1b5VIaL2GEaAiA/F8QkxGl3CJu6SLP9BCY+zatCVIG57p3OG8I1aCPyKA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22952,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjljGTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoByQ//XUTQzEWCG1kdheLpVDXT/TOWaFsQ8zFns+17Y4ckGTAyRVW/\r\nYgfeAD7xRxgVnOY61njRfNoPAUJy5dnOM4tbtfouxJrbtMU5wXzwaFjss/9C\r\nZj/WFPeSfqv/FgaQNAsTq3ZDB4gd6DzbKDbuH40oaGHFP6C+ChwaJeBi1De4\r\nz0H7P1yXdMkwWkY33dMTkiC9flonIY4eu8V36UwWeGWeKdYC2KEyJyNMuD0g\r\n2zPWkUjOdGorBcL5hdrraH5agpDCYGbct//uvQARNm4MpVhl/nvLmojMX3Yc\r\n2QIItqiW7rdHicMWrmSaC836kS3gG//B7XtFCgC26EfgjSqt1x7Q9lAW5dxJ\r\nysELbfhODOGEshbMmLAwCymYmI+RjKWO/2EkSfPdw81sLhGYmMczmb1DiZay\r\nRAwWoO3AMuX+J2paEHusU+f2cYDMxtIKG56WtVXywtjEoiHDn4aKKkF1e94j\r\nFey3VyJkhTl0ukbsqIttXwZbz8AwjbU/qya62WbIgsCjpo70wLvI0CrHF2TO\r\nfL+at2kNBkxldk0v5Ehb411mKspavBZLKWFX4hm7rdyKR/vriLE+M+LR/EOv\r\nadvtTWeJrEp81jx6RAjMW7OXphqPW2tYUVNFeUO+Im79/tBm7xNKfJpzyOP/\r\nai58cfbrfWGco6dnnz/Dhb7DfebDw22VGiM=\r\n=wNlh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","husky":{"hooks":{"pre-commit":"tsdx lint"}},"module":"dist/cancelable-promise.esm.js","engines":{"node":">=10"},"gitHead":"7e535ad068068b12d550f2548378c5be84f4f93e","scripts":{"lint":"tsdx lint","size":"size-limit","test":"tsdx test","build":"tsdx build","start":"tsdx watch","analyze":"size-limit --why","prepare":"tsdx build"},"typings":"dist/index.d.ts","_npmUser":{"name":"carloslawton","email":"blakgeek@gmail.com"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/blakgeek/cancellable-promise.git","type":"git"},"size-limit":[{"path":"dist/cancelable-promise.cjs.production.min.js","limit":"10 KB"},{"path":"dist/cancelable-promise.esm.js","limit":"10 KB"}],"_npmVersion":"8.5.0","description":"A functional cancellable promise implementation.","directories":{},"_nodeVersion":"16.14.2","_hasShrinkwrap":false,"devDependencies":{"tsdx":"^0.14.1","husky":"^8.0.2","tslib":"^2.4.1","size-limit":"^8.1.0","typescript":"^4.9.4","@size-limit/preset-small-lib":"^8.1.0"},"peerDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/cancellable-promise_1.0.0_1670787475034_0.5470612477063084","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@blakgeek/cancellable-promise","version":"1.0.1","license":"MIT","main":"dist/index.js","typings":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/blakgeek/cancellable-promise.git"},"description":"A functional cancellable promise implementation.","engines":{"node":">=10"},"scripts":{"start":"tsdx watch","build":"tsdx build","test":"tsdx test","lint":"tsdx lint","prepare":"tsdx build","size":"size-limit","analyze":"size-limit --why"},"peerDependencies":{},"husky":{"hooks":{"pre-commit":"tsdx lint"}},"prettier":{"printWidth":80,"semi":true,"singleQuote":true,"trailingComma":"es5"},"author":{"name":"blakgeek"},"module":"dist/cancellable-promise.esm.js","size-limit":[{"path":"dist/cancellable-promise.cjs.production.min.js","limit":"10 KB"},{"path":"dist/cancellable-promise.esm.js","limit":"10 KB"}],"devDependencies":{"@size-limit/preset-small-lib":"^8.1.0","husky":"^8.0.2","size-limit":"^8.1.0","tsdx":"^0.14.1","tslib":"^2.4.1","typescript":"^4.9.4"},"_id":"@blakgeek/cancellable-promise@1.0.1","gitHead":"c914f843587337ba4924e6ef1caffe2a45183db1","bugs":{"url":"https://github.com/blakgeek/cancellable-promise/issues"},"homepage":"https://github.com/blakgeek/cancellable-promise#readme","_nodeVersion":"23.10.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-NTuo94FOnOHXlGzJRdG/L4BpWCPjbIczR6inCsPZ+zi5vEc9uJPLE0eAd4Hojvq2lzxfAFUQ3PnA/1LklHpMRQ==","shasum":"a0030db8364f22242fa5ba8e3999c12ac470dd77","tarball":"https://registry.npmjs.org/@blakgeek/cancellable-promise/-/cancellable-promise-1.0.1.tgz","fileCount":12,"unpackedSize":22954,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCfLQIoYn59tBz81BlWLNwcH0wuZS2I8QN34MnaPm2spwIhAPyfDU0GdkUuyQomjVF+Z9l3RdiY0bSWFPQej5sf4+fO"}]},"_npmUser":{"name":"carloslawton","email":"blakgeek@gmail.com"},"directories":{},"maintainers":[{"name":"carloslawton","email":"blakgeek@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cancellable-promise_1.0.1_1744997096313_0.24759470529112182"},"_hasShrinkwrap":false}},"time":{"created":"2022-12-11T19:37:54.973Z","modified":"2025-04-18T17:24:56.747Z","1.0.0":"2022-12-11T19:37:55.193Z","1.0.1":"2025-04-18T17:24:56.548Z"},"bugs":{"url":"https://github.com/blakgeek/cancellable-promise/issues"},"author":{"name":"blakgeek"},"license":"MIT","homepage":"https://github.com/blakgeek/cancellable-promise#readme","repository":{"type":"git","url":"git+https://github.com/blakgeek/cancellable-promise.git"},"description":"A functional cancellable promise implementation.","maintainers":[{"name":"carloslawton","email":"blakgeek@gmail.com"}],"readme":"# Cancellable Promise\n\n## Basic Usage\n```ts\nconst cancellablePromise = new CancellablePromise<LongRunningResult>((resolve, reject) => {\n    \n    resolve(runLongRunningProcess())\n}, (reason: string) => {\n    console.warn('request cancelled')\n});\n\n// cancel the promise if it runs longer than 10s\nsetTimeout(() => {\n    cancellablePromise.cancel();\n}, 10000)\nconsole.log(await cancellablePromise);\n```\n\n\n## Make a native Promise cancellable\n```ts\nconst cancellablePromise = CancellablePromise.fromPromise(runLongRunningProcess());\n\n// cancel the promise if it runs longer than 10s\nsetTimeout(() => {\n    cancellablePromise.cancel();\n}, 10000)\nconsole.log(await cancellablePromise);\n```\n","readmeFilename":"README.md"}