state-tree
Advanced tools
Comparing version 0.1.17 to 0.1.18
{ | ||
"name": "state-tree", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"description": "A state tree that handles reference updates and lets you flush a description of changes", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
var subscribers = []; | ||
function getByPath(path, state, forcePath) { | ||
return path.reduce(function (currentPath, key, index) { | ||
var currentPath = state; | ||
for (var x = 0; x < path.length; x++) { | ||
var key = path[x]; | ||
if (forcePath && currentPath[key] === undefined) { | ||
@@ -10,9 +12,12 @@ var newBranch = {}; | ||
configurable: true, | ||
value: [path.slice().splice(0, index + 1)] | ||
value: [path.slice().splice(0, x + 1)] | ||
}); | ||
currentPath[key] = newBranch; | ||
} | ||
return currentPath[key]; | ||
}, state); | ||
if (currentPath[key] === undefined) { | ||
return currentPath[key]; | ||
} | ||
currentPath = currentPath[key]; | ||
} | ||
return currentPath; | ||
} | ||
@@ -19,0 +24,0 @@ |
@@ -61,1 +61,7 @@ var Lib = require('../src'); | ||
}; | ||
exports['should be able to get undefined from paths that are not in tree'] = function (test) { | ||
var lib = Lib({}); | ||
test.equals(lib.get('some.path'), undefined); | ||
test.done(); | ||
}; |
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
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
38137
946