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.1.4 to 3.1.5

2

package.json
{
"name": "clues",
"version": "3.1.4",
"version": "3.1.5",
"description": "Lightweight logic tree solver using promises.",

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

**clues.js** is a lean-mean-promisified-getter-machine that crunches through any javascript objects, including complex trees, functions, values and promises. Clues consists of a single getter function (just over 100 loc) that dynamically resolves dependency trees and memoizes resolutions (lets call them derived facts) along the way.
*[Prior versions](https://github.com/ZJONSSON/clues/tree/v2) of `clues` were based on internal scaffolding holding separate logic and fact spaces within a `clues` object. Clues 3.x is a major rewrite into a simple superpowered getter function. Clues apis might be backwards compatible - as long as you merge logic and facts into a single facts/logic object and use the new getter function directly for any resolutions*
*[Prior versions](https://github.com/ZJONSSON/clues/tree/v2) of `clues` were based on internal scaffolding holding separate logic and fact spaces within a `clues` object. Clues 3.x is a major rewrite into a simple superpowered getter function. Clues apis might be backwards compatible - as long as you merge logic and facts into a single facts/logic object and use the new getter function directly for any resolutions. Other libraries exploring similar concepts include [curran/reactive-model](https://github.com/curran/reactive-model) and [ZJONSSON/instinct](https://github.com/ZJONSSON/instinct.js)*
The basic function signature is simple and **always** returns a promise:

@@ -315,2 +316,19 @@ #### `clues(obj,fn,[$global])`

Another example of the memoization with `$property` is a simple Fibonacci solver:
```js
var fib = {
0: 0,
1: 1,
$property : function(n) {
return [''+(n-1),''+(n-2),function(a,b) {
return a+b;
}];
}
};
clues(fib,['12','14','25','1000',Array])
.then(console.log)
```
### $external property for undefined paths

@@ -317,0 +335,0 @@ 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.

@@ -62,9 +62,13 @@ var clues = require('../clues'),

var $global = {res:res,req:req,input:req.body},
facts = (typeof(api) === 'function')
var facts = (typeof(api) === 'function')
? clues({},api,$global,'reptiles')
: Object.create(api);
$global.root = facts;
var $global = Object.create(options.global || {},{
res : {value: res},
req : {value: req},
input: {value: req.body},
root : {value: facts}
});
// The api request is either determined by options.select, req.param.fn or by remaining url

@@ -71,0 +75,0 @@ var data = (options.select || decodeURI((req.params && req.params.fn) || req.url.slice(1).replace(/\//g,'.').replace(/\?.*/,'')).split(','))

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