Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@avocode/cancel-token
Advanced tools
Readme
A method for making async operations cancellable
Component:
$ component install ForbesLindesay/cancellation
NPM:
$ npm install cancellation
Returns a new CancellationTokenSource:
var tokenSource = require('cancellation');
var source = tokenSource();
callAsyncOperation(arg1, arg2, arg3, source.token);
setTimeout(function () {
source.cancel('Operation timed out');
}, 1000);
Returns an 'empty' CancellationToken (one that will never be cancelled).
var tokenSource = require('cancellation');
function asyncOperation(arg1, arg2, arg3, cancellationToken) {
cancellationToken = cancellationToken || tokenSource.empty;
//Continue with function knowing there is a cancellation token
}
Returns true if the token has been cancelled:
//In ES6
function asyncOperation(cancellationToken) {
return spawn(function* () {
while(!cancellationToken.isCancelled()) {
yield NextAsyncOp();
}
})
}
Throws the rejection reason if the token has been cancelled:
//In ES6
function asyncOperation(cancellationToken) {
return spawn(function* () {
while(true) {
cancellationToken.throwIfCancelled()
yield NextAsyncOp();
}
})
}
Calls cb when the cancellation token is cancelled (this is probably currently the most useful of these methods).
function get(url, cancellationToken) {
var def = defer();
var req = request(url, function (err, res) {
if (err) def.reject(err);
else def.resolve(res);
});
cancellationToken
.onCancelled(function (reason) {
def.reject(reason);
req.abort();
});
return def.promise;
}
MIT
FAQs
A method for making async operations cancellable
The npm package @avocode/cancel-token receives a total of 21 weekly downloads. As such, @avocode/cancel-token popularity was classified as not popular.
We found that @avocode/cancel-token demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 18 open source maintainers 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.