key-tree-store
Advanced tools
Comparing version 1.2.1 to 1.3.0
var slice = Array.prototype.slice; | ||
// our constructor | ||
function KeyTreeStore() { | ||
function KeyTreeStore(options) { | ||
options = options || {}; | ||
if (typeof options !== 'object') { | ||
throw new TypeError('Options must be an object'); | ||
} | ||
var DEFAULT_SEPARATOR = '.'; | ||
this.storage = {}; | ||
this.separator = options.separator || DEFAULT_SEPARATOR; | ||
} | ||
var DEFAULT_SEPARATOR = '.'; | ||
// add an object to the store | ||
@@ -36,3 +41,3 @@ KeyTreeStore.prototype.add = function (keypath, obj) { | ||
for (key in this.storage) { | ||
if (!keypath || keypath === key || key.indexOf(keypath + DEFAULT_SEPARATOR) === 0) { | ||
if (!keypath || keypath === key || key.indexOf(keypath + this.separator) === 0) { | ||
res = res.concat(this.storage[key]); | ||
@@ -51,3 +56,3 @@ } | ||
for (key in this.storage) { | ||
if (!keypath || keypath === key || key.indexOf(keypath + DEFAULT_SEPARATOR) === 0) { | ||
if (!keypath || keypath === key || key.indexOf(keypath + this.separator) === 0) { | ||
res[key] = slice.call(this.storage[key]); | ||
@@ -66,3 +71,3 @@ } | ||
for (key in this.storage) { | ||
if (keypath === key || key.indexOf(keypath + DEFAULT_SEPARATOR) === 0) { | ||
if (keypath === key || key.indexOf(keypath + this.separator) === 0) { | ||
res[key] = slice.call(this.storage[key]); | ||
@@ -69,0 +74,0 @@ } |
{ | ||
"name": "key-tree-store", | ||
"description": "Simple tool for storing/retrieving objects events based hierarchical keypaths.", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
"files": [ | ||
"key-tree-store.js" | ||
], | ||
"bugs": { | ||
@@ -13,3 +10,3 @@ "url": "https://github.com/HenrikJoreteg/key-tree-store/issues" | ||
"devDependencies": { | ||
"tape": "^3.5.0" | ||
"tape": "^4.0.3" | ||
}, | ||
@@ -19,7 +16,10 @@ "directories": { | ||
}, | ||
"files": [ | ||
"key-tree-store.js" | ||
], | ||
"homepage": "https://github.com/HenrikJoreteg/key-tree-store", | ||
"keywords": [ | ||
"events", | ||
"trigger", | ||
"keypath" | ||
"keypath", | ||
"trigger" | ||
], | ||
@@ -26,0 +26,0 @@ "license": "MIT", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
5140
70
1