Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

make-cancellable-promise

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-cancellable-promise - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

dist/cjs/index.d.ts

25

dist/esm/index.js
export default function makeCancellablePromise(promise) {
var isCancelled = false;
var wrappedPromise = new Promise(function (resolve, reject) {
promise.then(function () {
return !isCancelled && resolve.apply(void 0, arguments);
})["catch"](function (error) {
return !isCancelled && reject(error);
var isCancelled = false;
var wrappedPromise = new Promise(function (resolve, reject) {
promise
.then(function (value) { return !isCancelled && resolve(value); })["catch"](function (error) { return !isCancelled && reject(error); });
});
});
return {
promise: wrappedPromise,
cancel: function cancel() {
isCancelled = true;
}
};
}
return {
promise: wrappedPromise,
cancel: function () {
isCancelled = true;
}
};
}
{
"name": "make-cancellable-promise",
"version": "1.1.0",
"version": "1.2.0",
"description": "Make any Promise cancellable.",
"main": "dist/umd/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.js",
"source": "src/index.ts",
"types": "src/index.ts",
"sideEffects": false,
"scripts": {
"build": "yarn build-esm && yarn build-umd",
"build-esm": "BABEL_ENV=production-esm babel src -d dist/esm --ignore \"**/*.spec.js\"",
"build-umd": "BABEL_ENV=production-umd babel src -d dist/umd --ignore \"**/*.spec.js\"",
"build": "yarn build-esm && yarn build-cjs",
"build-esm": "tsc --project tsconfig.build.json --outDir dist/esm --module esnext",
"build-cjs": "tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs",
"clean": "rimraf dist",
"jest": "jest",
"jest-coverage": "jest --coverage",
"lint": "eslint src/ --ext .jsx,.js",
"lint": "eslint src",
"prepack": "yarn clean && yarn build",
"test": "yarn lint && yarn jest"
"prettier": "prettier --check . --cache",
"test": "yarn lint && yarn tsc && yarn prettier && yarn jest",
"tsc": "tsc --noEmit"
},
"jest": {},
"keywords": [

@@ -31,9 +32,16 @@ "promise",

"devDependencies": {
"@babel/cli": "^7.8.0",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"eslint": "~7.19.0",
"eslint-config-wojtekmaj": "^0.5.0",
"jest": "^26.6.0",
"rimraf": "^3.0.0"
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.18.6",
"@types/jest": "^29.0.0",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.44.0",
"eslint": "^8.26.0",
"eslint-config-wojtekmaj": "^0.7.1",
"husky": "^8.0.0",
"jest": "^29.0.0",
"prettier": "^2.7.0",
"pretty-quick": "^3.1.0",
"rimraf": "^3.0.0",
"typescript": "^4.9.4"
},

@@ -44,6 +52,4 @@ "resolutions": {

"files": [
"LICENSE",
"README.md",
"dist/",
"src/"
"dist",
"src"
],

@@ -54,3 +60,4 @@ "repository": {

},
"funding": "https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1"
"funding": "https://github.com/wojtekmaj/make-cancellable-promise?sponsor=1",
"packageManager": "yarn@3.1.0"
}

@@ -1,14 +0,16 @@

[![npm](https://img.shields.io/npm/v/make-cancellable-promise.svg)](https://www.npmjs.com/package/make-cancellable-promise) ![downloads](https://img.shields.io/npm/dt/make-cancellable-promise.svg) [![CI](https://github.com/wojtekmaj/make-cancellable-promise/workflows/CI/badge.svg)](https://github.com/wojtekmaj/make-cancellable-promise/actions) ![dependencies](https://img.shields.io/david/wojtekmaj/make-cancellable-promise.svg) ![dev dependencies](https://img.shields.io/david/dev/wojtekmaj/make-cancellable-promise.svg) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
[![npm](https://img.shields.io/npm/v/make-cancellable-promise.svg)](https://www.npmjs.com/package/make-cancellable-promise) ![downloads](https://img.shields.io/npm/dt/make-cancellable-promise.svg) [![CI](https://github.com/wojtekmaj/make-cancellable-promise/workflows/CI/badge.svg)](https://github.com/wojtekmaj/make-cancellable-promise/actions) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
# Make-Cancellable-Promise
Make any Promise cancellable.
## tl;dr
* Install by executing `npm install make-cancellable-promise` or `yarn add make-cancellable-promise`.
* Import by adding `import makeCancellablePromise from 'make-cancellable-promise`.
* Do stuff with it!
```js
const { promise, cancel } = makeCancellablePromise(myPromise);
```
- Install by executing `npm install make-cancellable-promise` or `yarn add make-cancellable-promise`.
- Import by adding `import makeCancellablePromise from 'make-cancellable-promise`.
- Do stuff with it!
```js
const { promise, cancel } = makeCancellablePromise(myPromise);
```
## User guide

@@ -39,5 +41,3 @@

promise
.then(() => setStatus('success'))
.catch(() => setStatus('error'));
promise.then(() => setStatus('success')).catch(() => setStatus('error'));

@@ -51,13 +51,15 @@ return () => {

switch (status) {
case 'pending': return 'Fetching…';
case 'success': return 'Success';
case 'error': return 'Error!';
default: return 'Click to fetch';
case 'pending':
return 'Fetching…';
case 'success':
return 'Success';
case 'error':
return 'Error!';
default:
return 'Click to fetch';
}
})();
return (
<p>{text}</p>
);
return <p>{text}</p>;
}
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc