
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
typescript-async-timeouts
Advanced tools
$ npm install typescript-async-timeouts --save
or
$ yarn add typescript-async-timeouts
Too many times we have to manage the timeouts. Keeping the timeout result somewhere and managing to clean it up. Aswell providing asynchronous method and keeping the promises increases the boulerplate. To solve this there are two methods:
cancel()
to cancel the timeoutSo, instead of:
try {
let timeout = null;
const result = await new Promise((resolve, reject) => {
timeout = setTimeout(() => async () => {
try {
const result = await myAsyncCall();
resolve(result);
} catch (error) {
reject(error);
}
}, 1)
});
// when we would like to cancel
if (timeout != null) {
clearTimeout(timeout)
}
} catch (error) {
concole.error(error);
}
We could run
try {
const result = runAsyncLater(myAsyncCall, 1)
result.cancel(); // to cancel the result
await result; // to get the result
} catch (error) {
console.error(error);
}
Short, right? Also, there is a ashortcut to synchronous call
try {
const result = runLater(() => { return "OK"; }, 1);
result.cancel(); // to cancel the result
await result; // to get the result
} catch (error) {
console.error(error);
}
I have really long array to iterate or heavy logic which needs to be run on ech row and I would not like to block the browser, So, there is a way to iterate asynchronous way. With two methods:
To solve the problem there are two methods:
(value: ValueType, index: number, cancel: () => void) => Promise<any>
(value: ValueType, index: number, cancel: () => void) => any
Basic syntax:
const runnable = iterateAsyncLater([...long_array], async (value, index, cancel) => {
// do some magic stuff or call cancel();
});
runnable.cancel() // If I decied not to go this way
await runnable; // to wait until it runs
Or when the run is not async
const runnable = iterateLater([...long_array], (value, index, cancel) => {
// do some magic stuff or call cancel();
});
runnable.cancel() // If I decied not to go this way
await runnable; // to wait until it runs
FAQs
Typescript future timeout utils
The npm package typescript-async-timeouts receives a total of 0 weekly downloads. As such, typescript-async-timeouts popularity was classified as not popular.
We found that typescript-async-timeouts 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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.