
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
cancelable-awaiter
Advanced tools
A replacement for Typescript's default awaiter helper that supports Bluebird promise cancellations.
A replacement for Typescript's default awaiter helper that supports Bluebird promise cancellations.
npm install --save cancelable-awaiter
Depends on bluebird being installed as a dependency and configured to support cancellations:
import * as tslib from "tslib";
import * as Bluebird from "bluebird";
import * as awaiter from "cancelable-awaiter";
Bluebird.config({
cancellation: true
});
(tslib as any).__awaiter = awaiter;
Note that in order for the above to work you also need to compile your project with the --importHelpers
flag and install the tslib
module.
Then async/await syntax can be used in conjunction with promise cancellations:
async function doSomeThings() {
await doFirstThing()
// will be invoked anyway:
.finally(() => console.log("May have done first thing."));
// may not execute this part if cancelled beforehand:
console.log("Done first thing!");
// may also be cancelled after first thing is done:
await doSecondThing();
console.log("Done second thing!");
}
const promise = doSomeThings()
.finally(() => console.log("May have done some things."));
Promise.delay(1000)
.then(() => promise.cancel());
FAQs
A replacement for Typescript's default awaiter helper that supports Bluebird promise cancellations.
The npm package cancelable-awaiter receives a total of 1,462 weekly downloads. As such, cancelable-awaiter popularity was classified as popular.
We found that cancelable-awaiter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.