New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pendings

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pendings - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

6

lib/pending.js

@@ -119,2 +119,4 @@ /**

* Resets to initial state.
*
* @param {String} [msg='Pending reset'] custom rejection error message if promise is in pending state.
*/

@@ -124,5 +126,5 @@

key: 'reset',
value: function reset() {
value: function reset(msg) {
if (this._isPending) {
this.reject(new Error('Pending reset'));
this.reject(new Error(msg || 'Promise rejected by reset'));
}

@@ -129,0 +131,0 @@ this._promise = null;

@@ -23,3 +23,3 @@ /**

var message = 'Promise timeout: ' + timeout + ' ms';
var message = 'Promise rejected by timeout (' + timeout + ' ms)';

@@ -26,0 +26,0 @@ var _this = _possibleConstructorReturn(this, (TimeoutError.__proto__ || Object.getPrototypeOf(TimeoutError)).call(this, message));

{
"name": "pendings",
"version": "0.2.1",
"version": "0.2.2",
"description": "Better control of pending promises",

@@ -5,0 +5,0 @@ "author": {

@@ -142,6 +142,8 @@ /**

* Resets to initial state.
*
* @param {String} [msg='Pending reset'] custom rejection error message if promise is in pending state.
*/
reset() {
reset(msg) {
if (this._isPending) {
this.reject(new Error('Pending reset'));
this.reject(new Error(msg || 'Promise rejected by reset'));
}

@@ -148,0 +150,0 @@ this._promise = null;

@@ -13,3 +13,3 @@ /**

constructor(timeout) {
const message = `Promise timeout: ${timeout} ms`;
const message = `Promise rejected by timeout (${timeout} ms)`;
super(message);

@@ -16,0 +16,0 @@ this.timeout = timeout;

@@ -196,4 +196,10 @@ 'use strict';

this.pending.reset();
return assert.isRejected(res, 'Pending reset');
return assert.isRejected(res, 'Promise rejected by reset');
});
it('should reject pending promise with custom message', function () {
const res = this.pending.call(noop);
this.pending.reset('err');
return assert.isRejected(res, 'err');
});
});

@@ -211,5 +217,5 @@

setTimeout(() => this.pending.resolve('foo'), 20);
return assert.isRejected(res, 'Promise timeout: 10 ms');
return assert.isRejected(res, 'Promise rejected by timeout (10 ms)');
});
});
});

@@ -198,3 +198,3 @@ 'use strict';

const res = this.pendings.set(1, noop, {timeout: 5});
return assert.isRejected(res, 'Promise timeout: 5 ms');
return assert.isRejected(res, 'Promise rejected by timeout (5 ms)');
});

@@ -205,3 +205,3 @@

const res = pendings.set(1, noop);
return assert.isRejected(res, 'Promise timeout: 5 ms');
return assert.isRejected(res, 'Promise rejected by timeout (5 ms)');
});

@@ -212,3 +212,3 @@

const res = pendings.set(1, noop, {timeout: 5});
return assert.isRejected(res, 'Promise timeout: 5 ms');
return assert.isRejected(res, 'Promise rejected by timeout (5 ms)');
});

@@ -215,0 +215,0 @@ });

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