Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@nextgis/cancelable-promise
Advanced tools
A promise you can stop.
Simply download and include with a script tag, CancelablePromise
will be registered as a global variable.
<script src="../lib/cancelable-promise.global.js"></script>
<script>
var promise = new CancelablePromise((resolve, reject, onCancel) => {
setTimeout(resolve, 1000);
onCancel(() => console.log('canceled'));
});
promise.cancel();
</script>
unpkg
<script src="https://unpkg.com/@nextgis/cancelable-promise"></script>
jsdelivr
<script src="https://cdn.jsdelivr.net/npm/@nextgis/cancelable-promise"></script>
We recommend linking to a specific version number /cancelable-promise@[version]
$ npm install --save-dev @nextgis/cancelable-promise
# or
$ yarn add @nextgis/cancelable-promise
Catch CancelError
import CancelablePromise from "@nextgis/cancelable-promise";
const promise = new CancelablePromise((resolve, reject) => {
setTimeout(() => resolve(), 100);
}).catch((er) => {
if (er.name === "CancelError") {
// handle cancel error
}
throw er;
});
promise.cancel();
Handle onCancel
callback
import CancelablePromise from "@nextgis/cancelable-promise";
const promise = new CancelablePromise((resolve, reject, onCancel) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onload = () => {
resolve(xhr.responseText);
};
xhr.onerror = (er) => {
reject(er);
};
onCancel(() => {
xhr.abort();
});
xhr.send();
});
promise.cancel();
Check out the API Documentation
Need to fix a bug or add a feature to @nextgis/cancelable-promise
? We provide custom development and support for this software. Contact us to discuss options!
FAQs
A promise you can stop
The npm package @nextgis/cancelable-promise receives a total of 110 weekly downloads. As such, @nextgis/cancelable-promise popularity was classified as not popular.
We found that @nextgis/cancelable-promise demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.