New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cachetree

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cachetree - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

20

lib/hash.js

@@ -164,5 +164,5 @@ /**

if ((type === 'string' && def) || type === 'number') {
def = { key: def };
def = { __key__: def };
} else if (type === 'function' || def instanceof RegExp) {
def = { validate: def };
def = { __validate__: def };
}

@@ -172,10 +172,10 @@ // Extract child names

children = Object.keys(def).filter(function(value) {
return value !== 'key' && value !== 'validate';
return value !== '__key__' && value !== '__validate__';
});
// Add the child
if (def.key) {
if (def.__key__) {
if (this.root.useProperties === true) {
Object.defineProperty(this, name, {
get: function() {
return create(def.key);
return create(def.__key__);
}

@@ -185,7 +185,7 @@ });

this[name] = function() {
return create(def.key);
return create(def.__key__);
};
}
} else {
if (def.validate && typeof def.validate === 'function') validateFn = true;
if (def.__validate__ && typeof def.__validate__ === 'function') validateFn = true;
this[name] = function(value) {

@@ -196,7 +196,7 @@ var isValid = false,

if (type === 'string' || type === 'number') {
if (def.validate) {
if (def.__validate__) {
if (validateFn) {
isValid = def.validate(value);
isValid = def.__validate__(value);
} else {
isValid = def.validate.test(value);
isValid = def.__validate__.test(value);
}

@@ -203,0 +203,0 @@ } else {

{
"name": "cachetree",
"description": "A scoped, fluent API for easily interacting with hierarchical, key-value data",
"version": "1.0.0",
"version": "1.1.0",
"author": "David Wood <bitprobe@gmail.com>",

@@ -6,0 +6,0 @@ "repository": {

@@ -76,3 +76,3 @@ /*global describe: true, it:true, beforeEach: true, afterEach: true, before: true, after: true */

var cache = cachetree();
cache.add('alpha', { key: 'bravo' });
cache.add('alpha', { __key__: 'bravo' });
isHash(cache.alpha(), ['cache', 'bravo']);

@@ -83,3 +83,3 @@ });

var cache = cachetree();
cache.add({ alpha: { key: 'bravo' }, charlie: 'delta' });
cache.add({ alpha: { __key__: 'bravo' }, charlie: 'delta' });
isHash(cache.alpha(), ['cache', 'bravo']);

@@ -152,3 +152,3 @@ isHash(cache.charlie(), ['cache', 'delta']);

err;
cache.add('alpha', { validate: function(val) { return val === 'bravo'; } });
cache.add('alpha', { __validate__: function(val) { return val === 'bravo'; } });
try {

@@ -169,3 +169,3 @@ cache.alpha('charlie');

err;
cache.add('alpha', { validate: /^br.*$/i });
cache.add('alpha', { __validate__: /^br.*$/i });
try {

@@ -195,3 +195,3 @@ cache.alpha('charlie');

alpha: {
key: 'alpha',
__key__: 'alpha',
bravo: {

@@ -201,3 +201,3 @@ charlie: {}

delta: {
validate: function(val) { return val === 'foxtrot'; },
__validate__: function(val) { return val === 'foxtrot'; },
echo: 'echo'

@@ -207,3 +207,3 @@ }

golf: {
key: 'golf',
__key__: 'golf',
bravo: /^hotel$/i

@@ -210,0 +210,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