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

@js-bits/xpromise

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@js-bits/xpromise - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

4

index.js

@@ -46,3 +46,5 @@ import enumerate from '@js-bits/enumerate';

if (this[ø.executor]) {
this[ø.executor](this[ø.resolve], this[ø.reject], ...args);
const resolve = this.resolve.bind(this);
const reject = this.reject.bind(this);
this[ø.executor](resolve, reject, ...args);
this[ø.executor] = undefined;

@@ -49,0 +51,0 @@ }

@@ -0,1 +1,3 @@

/* eslint-disable max-classes-per-file */
// eslint-disable-next-line import/no-extraneous-dependencies
import { jest } from '@jest/globals';

@@ -134,2 +136,51 @@ import { cyan } from '@js-bits/log-in-color';

});
describe('resolve/reject binding', () => {
test('resolve', async () => {
expect.assertions(3);
const resolveFunc = jest.fn();
class ResolvedPromise extends ExtendablePromise {
constructor(...args) {
super((resolve, reject) => {
resolve(true);
}, ...args);
this.execute();
}
resolve(...args) {
resolveFunc(...args);
super.resolve(...args);
}
}
const resolvedPromise = new ResolvedPromise();
return resolvedPromise.then(result => {
expect(result).toEqual(true);
expect(resolveFunc).toHaveBeenCalledWith(true);
expect(resolveFunc).toHaveBeenCalledTimes(1);
});
});
test('reject', async () => {
expect.assertions(2);
const rejectFunc = jest.fn();
class RejectedPromise extends ExtendablePromise {
constructor(...args) {
super((resolve, reject) => {
reject(new Error('Rejected Promise'));
}, ...args);
this.execute();
}
reject(...args) {
rejectFunc(...args);
super.reject(...args);
}
}
const rejectedPromise = new RejectedPromise();
return rejectedPromise.catch(reason => {
expect(reason.message).toEqual('Rejected Promise');
expect(rejectFunc).toHaveBeenCalledTimes(1);
});
});
});
});
{
"name": "@js-bits/xpromise",
"version": "0.0.2",
"version": "0.1.0",
"description": "Extendable Promise",

@@ -5,0 +5,0 @@ "keywords": [

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