Comparing version 2.2.1 to 2.5.0-beta1
{ | ||
"name": "clues", | ||
"version": "2.2.1", | ||
"version": "2.5.0", | ||
"main": "clues.js", | ||
@@ -5,0 +5,0 @@ "scripts": [ |
25
clues.js
@@ -35,5 +35,5 @@ // clues.js (c) 2009-2014 Ziggy.jonsson.nyc@gmail.com @license MIT | ||
clues.version = "2.2.1"; | ||
clues.version = "2.5.0"; | ||
clues.prototype.solve = function(fn,local,caller) { | ||
clues.prototype.solve = function(fn,local,caller,fullref) { | ||
var self = this, ref, args; | ||
@@ -48,2 +48,20 @@ local = local || {}; | ||
// If the reference contains dots we solve recursively | ||
if (ref.indexOf('.') > -1) { | ||
var keys = ref.split('.'), | ||
key = keys.shift(); | ||
fullref = fullref ? fullref+'.'+key : key; | ||
return self.solve(key,local,caller,fullref) | ||
.then(function(d) { | ||
while (key = keys.shift()) { | ||
fullref += '.'+key; | ||
d = d[key]; | ||
if (d && d.solve) | ||
return self.facts[ref] = d.solve(keys.join('.'),local,caller,fullref); | ||
if (!d) return self.Promise.rejected({ref: key, fullref : fullref, caller: caller, message: ref+' not defined', name: 'Undefined'}); | ||
} | ||
return d; | ||
}); | ||
} | ||
// If we can't find any logic, we check self and local before returning an error | ||
@@ -56,3 +74,3 @@ if (self.logic[ref] === undefined) { | ||
if (typeof(self.options.fallback) === 'function') return self.facts[ref] = self.options.fallback.call(this,ref,local,caller); | ||
return self.Promise.rejected({ref: ref, caller: caller, message: ref+' not defined', name: 'Undefined'}); | ||
return self.Promise.rejected({ref: ref, fullref: fullref || ref, caller: caller, message: ref+' not defined', name: 'Undefined'}); | ||
} | ||
@@ -98,2 +116,3 @@ | ||
e.ref = e.ref || ref; | ||
e.fullref = e.fullref || fullref; | ||
e.caller = e.caller || caller || ''; | ||
@@ -100,0 +119,0 @@ throw e; |
{ | ||
"name": "clues", | ||
"version": "2.2.1", | ||
"version": "2.5.0-beta1", | ||
"description": "Lightweight logic tree solver using promises.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -33,2 +33,5 @@ #### Breaking changes in version 2.0: | ||
##### Nesting | ||
Logic trees can contain clues objects that provide a separate fact/logic space for any sub-components. This allows for example person1 and person2 to have identical logic trees without sharing the same facts. Trees can be traversed using dot notation, either when solving by string or using the minification definition above. See `recursive-test.js` in the test directory for examples. (todo: more docs) | ||
## API Reference | ||
@@ -35,0 +38,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
162
0
1
37018
19
646
2