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

clues

Package Overview
Dependencies
Maintainers
2
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 3.5.33 to 3.5.34

2

bower.json
{
"name": "clues",
"version": "3.5.24",
"version": "3.5.33",
"main": "clues.js",

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

@@ -108,8 +108,10 @@ (function(self) {

args = (args || matchArgs(fn));
// Shortcuts to define empty objects with $property or $external
if (fn.name == '$property') return logic[ref] = clues.Promise.resolve({$property: fn.bind(logic)});
if (fn.name == '$external') return logic[ref] = clues.Promise.resolve({$external: fn.bind(logic)});
if (fn.name === '$property' || (args[0] === '$property' && args.length === 1)) return logic[ref] = clues.Promise.resolve({$property: fn.bind(logic)});
if (fn.name === '$external' || (args[0] === '$external' && args.length === 1)) return logic[ref] = clues.Promise.resolve({$external: fn.bind(logic)});
args = (args || matchArgs(fn))
.map(function(arg) {
args = args.map(function(arg) {
var optional,showError,res;

@@ -116,0 +118,0 @@ if (optional = (arg[0] === '_')) arg = arg.slice(1);

{
"name": "clues",
"version": "3.5.33",
"version": "3.5.34",
"description": "Lightweight logic tree solver using promises.",

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

@@ -70,3 +70,3 @@ [![NPM Version][npm-image]][npm-url]

* [`$property`](#property---lazily-create-children-by-missing-reference) and [`$external`](#external-property-for-undefined-paths) are special handlers for missing properties (if they are functions)
* Any function named in-line as `$property` or `$external` will act as shorthands
* Any function named in-line as `$property` or `$external` (or as only argument name of a function) will act as shorthands
* `$global` will always return the full global object provided, in any context.

@@ -382,2 +382,9 @@ * `$caller` and `$fullref` are reserved to provide access to the current state of the clues solver when it hits a function for the first time.

Another way to create this shortcut is to have a function where only argument name is `$property`
```js
var fib = $property => ($property <= 1) ? +$property : [''+($property-1),''+($property-2), (a,b) => a+b];
```
### $external property for undefined paths

@@ -421,8 +428,20 @@ If an undefined property can not locate a `$property` function it will look for an `$external` function. The purpose of the `$external` function is similar except that the argument passed to the function will be the full remaining reference (in dot notation), not just the next reference in the chain.

return function $external(ref) {
ref = ref.replace(/\./g,'/');
....
}
}
return request.getAsync({
url : 'http://api.vendor.com/api/'+ref.replace(/\./g,'/'),
json : {user_id : userid}
});
....
```
A function with a sole argument of `$external` will behave the same:
```js
...
externalApi : userid => $external => request.getAsync({
url: 'http://api.vendor.com/api/'+$external.replace(/\./g,'/').
json: {user_id: userid}
});
```
### function that returns a function that returns a...

@@ -434,9 +453,3 @@ If the resolved value of any function is itself a function, that returned function will also be resolved (within the same scope). This allows for very powerful 'gateways' that constrains the tree traversal only to segments that are relevant for a particular solutions.

tree_b : {....},
next_step: function(step) {
if (step === 'a')
return ['tree_a',Object]
else
return ['tree_b',Object];
}
}
next_step: step => (step === 'a') ? ['tree_a',Object] : ['tree_b',Object]
}

@@ -443,0 +456,0 @@

@@ -21,2 +21,6 @@ var clues = require('../clues'),

},
as_argument: function($external) {
return 'answer:'+$external;
},
as_argument_es6: $external => 'answer:'+$external,
concurrent : function $external() {

@@ -108,2 +112,34 @@ return clues.Promise.delay(Math.random()*1000)

describe('when argument name is $external',function() {
it('acts as a shorthand for empty object with $external',function() {
return clues(facts,'as_argument.first')
.then(function(d) {
assert.equal(d,'answer:first');
assert.equal(facts.shorthand.value().first.value(),'answer:first');
return clues(facts,'as_argument.second');
})
.then(function(d) {
assert.equal(d,'answer:second');
assert.equal(facts.shorthand.value().first.value(),'answer:first');
assert.equal(facts.shorthand.value().second.value(),'answer:second');
});
});
it('as ES6 acts as a shorthand for empty object with $external',function() {
return clues(facts,'as_argument_es6.first')
.then(function(d) {
assert.equal(d,'answer:first');
assert.equal(facts.shorthand.value().first.value(),'answer:first');
return clues(facts,'as_argument_es6.second');
})
.then(function(d) {
assert.equal(d,'answer:second');
assert.equal(facts.shorthand.value().first.value(),'answer:first');
assert.equal(facts.shorthand.value().second.value(),'answer:second');
});
});
});
});

@@ -32,2 +32,6 @@ var clues = require('../clues'),

},
as_argument: function ($property) {
return $property * this.a;
},
as_argument_es6 : a => $property => $property * a,
concurrent : {

@@ -157,2 +161,32 @@ $property : function() {

describe('when argument name is $property',function() {
it('acts as a shorthand for empty object with $property',function() {
return clues(facts,'as_argument.2')
.then(function(d) {
assert.equal(d,10);
assert.equal(facts.shorthand.value()['2'].value(),10);
return clues(facts,'as_argument.4');
})
.then(function(d) {
assert.equal(d,20);
assert.equal(facts.shorthand.value()['4'].value(),20);
assert.equal(facts.shorthand.value()['2'].value(),10);
});
});
it('as ES6 acts as a shorthand for empty object with $property',function() {
return clues(facts,'as_argument_es6.2')
.then(function(d) {
assert.equal(d,10);
assert.equal(facts.shorthand.value()['2'].value(),10);
return clues(facts,'as_argument_es6.4');
})
.then(function(d) {
assert.equal(d,20);
assert.equal(facts.shorthand.value()['4'].value(),20);
assert.equal(facts.shorthand.value()['2'].value(),10);
});
});
});
});
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