Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

clues

Package Overview
Dependencies
Maintainers
1
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clues - npm Package Compare versions

Comparing version 2.2.1 to 2.5.0-beta1

test/recursive-test.js

2

bower.json
{
"name": "clues",
"version": "2.2.1",
"version": "2.5.0",
"main": "clues.js",

@@ -5,0 +5,0 @@ "scripts": [

@@ -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 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc