Comparing version 3.0.4 to 3.0.5
45
dot.js
@@ -37,6 +37,7 @@ /*global Map Promise Set*/ | ||
// | ||
function callOnAny(a, k, m) { | ||
function callOnAny(a, k, m, s) { | ||
// a - arg | ||
// k - keys | ||
// m - map | ||
// s - signal | ||
// | ||
@@ -47,7 +48,7 @@ var props = "" | ||
props = props + (i > 0 ? period : empty) + prop | ||
return callOn(a, m, props) | ||
return callOn(a, m, props, s) | ||
}) | ||
return Promise.all([ | ||
callOn(a, m, ""), | ||
callOn(a, m, "", s), | ||
Promise.all(promise), | ||
@@ -59,6 +60,7 @@ ]) | ||
// | ||
function callOn(a, m, p) { | ||
function callOn(a, m, p, s) { | ||
// a - arg | ||
// m - map | ||
// p - props | ||
// s - signal | ||
// | ||
@@ -71,4 +73,4 @@ var set = m.get(p) | ||
set.forEach(function(fn) { | ||
if (!a.sig.cancel) { | ||
promises.push(fn(a)) | ||
if (!s.cancel) { | ||
promises.push(fn(a, s)) | ||
} | ||
@@ -94,11 +96,11 @@ }) | ||
// | ||
var a1 = { sig: {} }, | ||
a2 = { sig: {} }, | ||
keys = p.match(propRegex) || [], | ||
var keys = p.match(propRegex) || [], | ||
pa = after[0] + period + p, | ||
pb = before[0] + period + p | ||
pb = before[0] + period + p, | ||
sig1 = {}, | ||
sig2 = {} | ||
var props = keys.slice(1) | ||
var arg = { | ||
var arg = Object.freeze({ | ||
dot: r.dot, | ||
@@ -110,15 +112,12 @@ fn: fn, | ||
props: props, | ||
} | ||
}) | ||
Object.assign(a1, arg) | ||
Object.assign(a2, arg) | ||
var promise = Promise.all([ | ||
callOnAny(a1, before.concat(keys), s.anyMap), | ||
callOn(a2, s.onMap, pb), | ||
callOnAny(arg, before.concat(keys), s.anyMap, sig1), | ||
callOn(arg, s.onMap, pb, sig2), | ||
]) | ||
.then(function() { | ||
return Promise.all([ | ||
callOnAny(a1, keys, s.anyMap), | ||
callOn(a2, s.onMap, p), | ||
callOnAny(arg, keys, s.anyMap, sig1), | ||
callOn(arg, s.onMap, p, sig2), | ||
]) | ||
@@ -128,4 +127,4 @@ }) | ||
return Promise.all([ | ||
callOnAny(a1, after.concat(keys), s.anyMap), | ||
callOn(a2, s.onMap, pa), | ||
callOnAny(arg, after.concat(keys), s.anyMap, sig1), | ||
callOn(arg, s.onMap, pa, sig2), | ||
]) | ||
@@ -135,6 +134,6 @@ }) | ||
var value = a1.sig.value || a2.sig.value | ||
var value = sig1.value || sig2.value | ||
var noValue = | ||
a1.sig.value === undefined && a2.sig.value === undefined | ||
sig1.value === undefined && sig2.value === undefined | ||
@@ -141,0 +140,0 @@ return noValue ? promise : value |
@@ -47,3 +47,2 @@ /* eslint-env jest */ | ||
props: ["b", "c"], | ||
sig: {}, | ||
}) | ||
@@ -76,4 +75,4 @@ }) | ||
dot.on("before.a.b", "c", function(opt) { | ||
opt.sig.cancel = true | ||
dot.on("before.a.b", "c", function(opt, sig) { | ||
sig.cancel = true | ||
}) | ||
@@ -91,4 +90,4 @@ | ||
test("on value", function() { | ||
dot.on("before.a.b", "c", function(opt) { | ||
opt.sig.value = true | ||
dot.on("before.a.b", "c", function(opt, sig) { | ||
sig.value = true | ||
}) | ||
@@ -171,5 +170,4 @@ | ||
props: ["b", "c"], | ||
sig: {}, | ||
}) | ||
}) | ||
}) |
{ | ||
"name": "dot-event", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Powerful event emitter", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8947
310