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.2.1 to 1.3.0

38

package.json
{
"name": "make-cancellable-promise",
"version": "1.2.1",
"version": "1.3.0",
"description": "Make any Promise cancellable.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.ts",
"types": "dist/cjs/index.d.ts",
"type": "module",
"sideEffects": false,
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"source": "./src/index.ts",
"types": "./dist/cjs/index.d.ts",
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"scripts": {

@@ -15,8 +20,8 @@ "build": "yarn build-esm && yarn build-cjs",

"clean": "rimraf dist",
"jest": "jest",
"lint": "eslint src",
"lint": "eslint .",
"prepack": "yarn clean && yarn build",
"prettier": "prettier --check . --cache",
"test": "yarn lint && yarn tsc && yarn prettier && yarn jest",
"tsc": "tsc --noEmit"
"test": "yarn lint && yarn tsc && yarn prettier && yarn unit",
"tsc": "tsc --noEmit",
"unit": "vitest run"
},

@@ -33,20 +38,11 @@ "keywords": [

"devDependencies": {
"@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",
"eslint-config-wojtekmaj": "^0.8.4",
"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"
"typescript": "^5.0.0",
"vitest": "^0.30.1"
},
"resolutions": {
"semver@7.0.0": "^7.0.0"
},
"files": [

@@ -53,0 +49,0 @@ "dist",

@@ -1,2 +0,2 @@

[![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)
[![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)

@@ -3,0 +3,0 @@ # Make-Cancellable-Promise

@@ -0,4 +1,5 @@

import { describe, expect, it, vi } from 'vitest';
import makeCancellablePromise from './index';
jest.useFakeTimers();
vi.useFakeTimers();

@@ -23,8 +24,8 @@ describe('makeCancellablePromise()', () => {

it('resolves promise if not cancelled', async () => {
const resolve = jest.fn();
const reject = jest.fn();
const resolve = vi.fn();
const reject = vi.fn();
const { promise } = makeCancellablePromise(resolveInFiveSeconds());
jest.advanceTimersByTime(5000);
vi.advanceTimersByTime(5000);
await promise.then(resolve).catch(reject);

@@ -37,8 +38,8 @@

it('rejects promise if not cancelled', async () => {
const resolve = jest.fn();
const reject = jest.fn();
const resolve = vi.fn();
const reject = vi.fn();
const { promise } = makeCancellablePromise(rejectInFiveSeconds());
jest.runAllTimers();
vi.runAllTimers();
await promise.then(resolve).catch(reject);

@@ -53,7 +54,7 @@

const resolve = jest.fn(() => {
const resolve = vi.fn(() => {
// Will fail because of expect.assertions(0);
expect(true).toBe(true);
});
const reject = jest.fn(() => {
const reject = vi.fn(() => {
// Will fail because of expect.assertions(0);

@@ -66,5 +67,5 @@ expect(true).toBe(true);

jest.advanceTimersByTime(2500);
vi.advanceTimersByTime(2500);
cancel();
jest.advanceTimersByTime(2500);
vi.advanceTimersByTime(2500);
});

@@ -75,7 +76,7 @@

const resolve = jest.fn(() => {
const resolve = vi.fn(() => {
// Will fail because of expect.assertions(0);
expect(true).toBe(true);
});
const reject = jest.fn(() => {
const reject = vi.fn(() => {
// Will fail because of expect.assertions(0);

@@ -88,6 +89,6 @@ expect(true).toBe(true);

jest.advanceTimersByTime(2500);
vi.advanceTimersByTime(2500);
cancel();
jest.advanceTimersByTime(2500);
vi.advanceTimersByTime(2500);
});
});
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