Comparing version 3.5.16 to 3.6.0-rc1
48
clues.js
@@ -10,2 +10,22 @@ (function(self) { | ||
function checkCircular(d,value) { | ||
var checked = [],circular; | ||
return (function check(c) { | ||
if (circular || !c || checked.indexOf(c) !== -1) return; | ||
checked.push(c); | ||
if (c == value) | ||
return (circular = true); | ||
if (c._cancellationParent) | ||
check(c._cancellationParent); | ||
if (c._onCancelField && c._onCancelField._values) | ||
c._onCancelField._values.forEach(check); | ||
if (c._followee && c._followee()) | ||
check(c._followee()); | ||
})(d) || circular; | ||
} | ||
var reArgs = /function.*?\(([^)]*?)\).*/; | ||
@@ -26,3 +46,3 @@ var reEs6 = /\({0,1}(.*?)\){0,1}\s*=>/; | ||
function clues(logic,fn,$global,caller,fullref) { | ||
function clues(logic,fn,$global,caller,fullref,last) { | ||
var args,ref; | ||
@@ -33,5 +53,5 @@ | ||
if (typeof logic === 'function' || (logic && typeof logic.then === 'function')) | ||
return clues({},logic,$global,caller,fullref) | ||
return clues({},logic,$global,caller,fullref,last) | ||
.then(function(logic) { | ||
return clues(logic,fn,$global,caller,fullref); | ||
return clues(logic,fn,$global,caller,fullref,last); | ||
}); | ||
@@ -45,3 +65,3 @@ | ||
var next = ref.slice(0,dot); | ||
return clues(logic,next,$global,caller,fullref) | ||
return clues(logic,next,$global,caller,fullref,last) | ||
.then(function(d) { | ||
@@ -51,3 +71,3 @@ logic = d; | ||
fullref = (fullref ? fullref+'.' : '')+next; | ||
return clues(logic,ref,$global,caller,fullref); | ||
return clues(logic,ref,$global,caller,fullref,last); | ||
}) | ||
@@ -67,3 +87,3 @@ .catch(function(e) { | ||
else if ($global[ref] && caller && caller !== '__user__') | ||
return clues($global,ref,$global,caller,fullref); | ||
return clues($global,ref,$global,caller,fullref,last); | ||
else if (logic && logic.$property && typeof logic.$property === 'function') | ||
@@ -81,3 +101,3 @@ fn = logic[ref] = function() { return logic.$property.call(logic,ref); }; | ||
if (fn.length === 1) fn = fn[0]; | ||
return clues(obj,fn,$global,caller,fullref); | ||
return clues(obj,fn,$global,caller,fullref,last); | ||
} | ||
@@ -99,2 +119,5 @@ args = fn.slice(0,fn.length-1); | ||
if (typeof fn !== 'function' || (ref && ref[0] === '$')) { | ||
if (fn && !clues.ignoreCircular && fn.isPending && fn.isPending() && checkCircular(fn,last)) | ||
return clues.Promise.rejected({ref: ref, message: 'circular', fullref:fullref, caller: caller}); | ||
// If the value is a promise we wait for it to resolve to inspect the result | ||
@@ -114,4 +137,3 @@ if (fn && typeof fn.then === 'function') | ||
args = (args || matchArgs(fn)) | ||
.map(function(arg) { | ||
var inputs = clues.Promise.map(args || matchArgs(fn),function(arg) { | ||
var optional,showError,res; | ||
@@ -130,3 +152,6 @@ if (optional = (arg[0] === '_')) arg = arg.slice(1); | ||
return res || clues(logic,arg,$global,ref || 'fn',fullref) | ||
return res || clues.Promise.resolve() | ||
.then(function() { | ||
return clues(logic,arg,$global,ref || 'fn',fullref,value); | ||
}) | ||
.then(null,function(e) { | ||
@@ -138,4 +163,3 @@ if (optional) return (showError) ? e : undefined; | ||
var inputs = clues.Promise.all(args), | ||
wait = new Date(), | ||
var wait = new Date(), | ||
duration; | ||
@@ -142,0 +166,0 @@ |
{ | ||
"name": "clues", | ||
"version": "3.5.16", | ||
"version": "3.6.0-rc1", | ||
"description": "Lightweight logic tree solver using promises.", | ||
@@ -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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
93472
32
1867
2