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

state-tree

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

state-tree - npm Package Compare versions

Comparing version 0.1.16 to 0.1.17

2

package.json
{
"name": "state-tree",
"version": "0.1.16",
"version": "0.1.17",
"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) {
return path.reduce(function (currentPath, key) {
function getByPath(path, state, forcePath) {
return path.reduce(function (currentPath, key, index) {
if (forcePath && currentPath[key] === undefined) {
var newBranch = {};
Object.defineProperty(newBranch, '.referencePaths', {
writable: true,
configurable: true,
value: [path.slice().splice(0, index + 1)]
});
currentPath[key] = newBranch;
}
return currentPath[key];

@@ -131,3 +141,3 @@ }, state);

var key = pathArray.pop();
var host = getByPath(pathArray, state);
var host = getByPath(pathArray, state, true);
cleanReferences(host[key], state, originalPath);

@@ -210,3 +220,3 @@ host[key] = setReferences(value, pathArray.concat(key));

var key = pathArray.pop();
var host = getByPath(pathArray, state);
var host = getByPath(pathArray, state, true);
var child = host[key] || host;

@@ -213,0 +223,0 @@ Object.keys(value).forEach(function (mergeKey) {

@@ -58,1 +58,10 @@ var Lib = require('../src');

};
exports['should be able to set paths that does not exist'] = function (test) {
var lib = Lib({});
lib.set('foo.bar.test', 'bar2');
test.deepEqual(lib.get(), {foo: { bar: { test: 'bar2' } } });
test.deepEqual(lib.get('foo')['.referencePaths'], [['foo']]);
test.deepEqual(lib.get('foo.bar')['.referencePaths'], [['foo', 'bar']]);
test.done();
};
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