{"id":21363688,"url":"https://github.com/kevinokerlund/cancellable-promise","last_synced_at":"2025-03-16T07:13:18.235Z","repository":{"id":82290399,"uuid":"87649893","full_name":"kevinokerlund/cancellable-promise","owner":"kevinokerlund","description":"An extension of native ES6 Promises that provides the ability to cancel and/or clear promise chains.","archived":false,"fork":false,"pushed_at":"2017-04-09T04:57:42.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-22T19:36:50.060Z","etag":null,"topics":["clear-promise-chains","es6-promise","javascript-promise","native-es6-promises","promise","promise-cancelling","promise-chain","promises"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinokerlund.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-08T17:01:19.000Z","updated_at":"2021-03-19T12:21:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"55a93760-4e69-4332-9e5a-ccc36cc55f2c","html_url":"https://github.com/kevinokerlund/cancellable-promise","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Fcancellable-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Fcancellable-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Fcancellable-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Fcancellable-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinokerlund","download_url":"https://codeload.github.com/kevinokerlund/cancellable-promise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243836028,"owners_count":20355616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clear-promise-chains","es6-promise","javascript-promise","native-es6-promises","promise","promise-cancelling","promise-chain","promises"],"created_at":"2024-11-22T06:20:44.401Z","updated_at":"2025-03-16T07:13:18.215Z","avatar_url":"https://github.com/kevinokerlund.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cancellable-promise\nAn extension of native ES6 Promises that provides the ability to cancel and clear promise chains.\n\n\n## Usage\n\n### Creating a new cancellable promise\n\nCancellable promises are created just like regular promises, the only difference is the constructor you use.\n\n```javascript\nlet promise = new CancellablePromise((resolve, reject) =\u003e {\n\tsetTimeout(() =\u003e {\n\t\tresolve('Resolved!');\n\t}, 500)\n});\n\npromise\n    .then(val =\u003e console.log(val))\n    .catch(val =\u003e console.log(val));\n```\n\n### Cancelling a promise\n\nCancelling a promise, internally calls the \"reject\" on the promise. \n\n```javascript\npromise.cancel();\n```\n\n### Clearing a promise chain\n\nSometimes it is helpful to just clear all the `.then`, and `.catch` promise chains. This method clears whatever has been set in the past.\n \n```javascript\npromise.clear();\n```\n\n## Common questions\n \n### Will a cancellable promise still work with `Promise.race`, and `Promise.all`?\n\nYes. This extension literally `extends Promise`.\n\n### When I call cancel on a promise, will it cause an error in the browser?\n\n`.cancel` internally calls the rejection callback and so it will default to however the browser treats a rejected promise for ES6. Chrome for example will throw an error if a rejection is called on a promise, and there is no `.catch`. Firefox and Safari on the other hand, will not.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinokerlund%2Fcancellable-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinokerlund%2Fcancellable-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinokerlund%2Fcancellable-promise/lists"}