Socket
Socket
Sign inDemoInstall

brianmhunt-mutex-promise

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

12

dist/MutexPromise.js

@@ -127,3 +127,4 @@ "use strict";

promiseMutexTo: this.mutexTo,
mutexId: MutexPromise.mutexId
mutexId: MutexPromise.mutexId,
during: "then"
});

@@ -319,2 +320,11 @@ }

value: function _resolutionProcedureFn(valueOrReasonOrThenable, immediateState) {
// Resolution should occur only in the same mutex.
if (this.mutexTo !== MutexPromise.mutexId) {
this.emit("trespass", {
promiseMutexTo: this.mutexTo,
mutexId: MutexPromise.mutexId,
during: "Resolution"
});
}
// 1.2 “thenable” is an object or function that defines a then method.

@@ -321,0 +331,0 @@ try {

2

package.json
{
"name": "brianmhunt-mutex-promise",
"version": "1.0.4",
"version": "1.0.5",
"description": "Promises with uncaught handling and events",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -107,3 +107,4 @@ "use strict"

promiseMutexTo: this.mutexTo,
mutexId: MutexPromise.mutexId
mutexId: MutexPromise.mutexId,
during: "then"
})

@@ -261,2 +262,11 @@ }

_resolutionProcedureFn(valueOrReasonOrThenable, immediateState) {
// Resolution should occur only in the same mutex.
if (this.mutexTo !== MutexPromise.mutexId) {
this.emit("trespass", {
promiseMutexTo: this.mutexTo,
mutexId: MutexPromise.mutexId,
during: "Resolution"
})
}
// 1.2 “thenable” is an object or function that defines a then method.

@@ -263,0 +273,0 @@ try {

@@ -165,7 +165,10 @@ //

// Triggers twice
// 1. during .then
// 2. during .resolve
return p0
.then(() => assert.equal(spy.callCount, 1))
.then(() => assert.equal(spy.callCount, 2))
})
it("triggers 'trespass' on resolutions across mutexes", function () {
it("triggers 'trespass' on resolutions across sync mutexes", function () {
var spy = handlerSpy('trespass')

@@ -176,4 +179,20 @@ return new MP(function (res) {

})
.then(() => assert.equal(spy.callCount, 1))
.then(() => assert.equal(spy.callCount, 2))
})
it("triggers 'trespass' on resolutions across async mutexes", function () {
var spy = handlerSpy('trespass')
return new MP(function (res) {
MP.setMutex('b')
setTimeout(() => res('123'), 1)
})
.then(() => assert.equal(spy.callCount, 2))
})
it("triggers 'trespass' for async then's", function () {
var spy = handlerSpy('trespass')
var p = new MP((res) => res('x'))
.then(() => MP.setMutex('b'))
return p.then(() => assert.equal(spy.callCount, 1))
})
})

@@ -180,0 +199,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc