brianmhunt-mutex-promise
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -444,8 +444,11 @@ "use strict"; | ||
Array.from(iter).forEach(function (valueOrPromise) { | ||
var p = MutexPromise.resolve(valueOrPromise); | ||
var idx = arr.length; | ||
arr.push(undefined); | ||
var p; | ||
if (valueOrPromise instanceof MutexPromise) { | ||
p = valueOrPromise; | ||
promises.push(p); | ||
} else { | ||
p = MutexPromise.resolve(valueOrPromise); | ||
} | ||
var idx = arr.length; | ||
arr.push(undefined); // Placeholder. | ||
MutexPromise.resolve(p).then(function (value) { | ||
@@ -452,0 +455,0 @@ arr[idx] = value; |
{ | ||
"name": "brianmhunt-mutex-promise", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Promises with uncaught handling and events", | ||
@@ -14,2 +14,3 @@ "main": "index.js", | ||
"chai": "^3.5.0", | ||
"chokidar-cli": "^1.2.0", | ||
"eslint": "^2.3.0", | ||
@@ -16,0 +17,0 @@ "mocha": "^2.4.5", |
@@ -157,3 +157,2 @@ "use strict" | ||
} | ||
} | ||
@@ -379,8 +378,11 @@ | ||
Array.from(iter).forEach(function (valueOrPromise) { | ||
var p = MutexPromise.resolve(valueOrPromise) | ||
var idx = arr.length | ||
arr.push(undefined) | ||
var p | ||
if (valueOrPromise instanceof MutexPromise) { | ||
p = valueOrPromise | ||
promises.push(p) | ||
} else { | ||
p = MutexPromise.resolve(valueOrPromise) | ||
} | ||
var idx = arr.length | ||
arr.push(undefined) // Placeholder. | ||
MutexPromise.resolve(p) | ||
@@ -387,0 +389,0 @@ .then(function (value) { |
@@ -9,2 +9,5 @@ // | ||
// Enable/Disable the Promise A+ spec. | ||
const PERFORM_APLUS_TESTS = true | ||
// We do not ever want to refer to the global promise. | ||
@@ -40,3 +43,5 @@ global.Promise = null | ||
describe("Promises A+", function () { | ||
require('promises-aplus-tests').mocha(APLUS_ADAPTER) | ||
if (PERFORM_APLUS_TESTS) { | ||
require('promises-aplus-tests').mocha(APLUS_ADAPTER) | ||
} | ||
}) | ||
@@ -46,3 +51,3 @@ | ||
// Out MutexPromise-specific tests | ||
describe.only("MutexPromise", function () { | ||
describe("MutexPromise", function () { | ||
beforeEach(function () { MP.setMutex(this.currentTest.title) }) | ||
@@ -214,5 +219,4 @@ afterEach(() => MP.eventHandlers = {}) | ||
// FIXME This is higher than it should be. | ||
return MP.all([0, p0, 1, 2]) | ||
.then(() => assert.equal(spy.callCount, 6)) | ||
.then(() => assert.equal(spy.callCount, 4)) | ||
}) | ||
@@ -283,2 +287,16 @@ }) | ||
it("trespass raised when mutexes differ", function () { | ||
var a, b | ||
a = MP.resolve(1) | ||
b = MP.resolve(2) | ||
a.mutexTo = 'A' | ||
b.mutexTo = 'B' | ||
return new MP((resolve) => { | ||
MP.on('trespass', resolve) | ||
MP.all([a, b]) | ||
}) | ||
.then((tp) => assert.equal(tp.during, 'chain')) | ||
}) | ||
it("finishes when given an empty array", function () { | ||
@@ -285,0 +303,0 @@ return MP.all([]) |
44104
1097
8