deep-state-observer
Advanced tools
Comparing version 5.5.9 to 5.5.10
@@ -51,2 +51,5 @@ "use strict"; | ||
if (path.length === 0) { | ||
for (var key in obj) { | ||
delete obj[key]; | ||
} | ||
for (var key in value) { | ||
@@ -53,0 +56,0 @@ obj[key] = value[key]; |
@@ -21,2 +21,5 @@ export default class ObjectPath { | ||
if (path.length === 0) { | ||
for (const key in obj) { | ||
delete obj[key]; | ||
} | ||
for (const key in value) { | ||
@@ -23,0 +26,0 @@ obj[key] = value[key]; |
{ | ||
"name": "deep-state-observer", | ||
"version": "5.5.9", | ||
"version": "5.5.10", | ||
"description": "Deep state observer is an state management library that will fire listeners only when specified object node (which also can be a wildcard) was changed.", | ||
@@ -5,0 +5,0 @@ "main": "index.esm.js", |
@@ -1462,3 +1462,3 @@ const State = require("../index.cjs.js"); | ||
it("it should properly clean not recursive path", () => { | ||
it("should properly clean not recursive path", () => { | ||
const state = new State({}); | ||
@@ -1468,2 +1468,32 @@ expect(state.cleanNotRecursivePath("config.list.rows;")).toEqual("config.list.rows"); | ||
}); | ||
it("should replace whole state", () => { | ||
const state = new State({ x: "x" }); | ||
expect(state.get()).toEqual({ x: "x" }); | ||
state.update("", { y: "y" }); | ||
expect(state.get()).toEqual({ y: "y" }); | ||
}); | ||
it("should subscribe to empty path", () => { | ||
const obj = { x: { y: { z: "z" } } }; | ||
const state = new State(obj); | ||
const values = []; | ||
state.subscribe("", (val) => { | ||
values.push(JSON.stringify(val)); | ||
}); | ||
expect(values.length).toEqual(1); | ||
expect(values[0]).toEqual(JSON.stringify(obj)); | ||
state.update("", { a: { b: { c: "c" } } }); | ||
expect(values.length).toEqual(2); | ||
expect(values[1]).toEqual(JSON.stringify({ a: { b: { c: "c" } } })); | ||
values.length = 0; | ||
state.subscribe("a.b", (val) => { | ||
values.push(JSON.stringify(val)); | ||
}); | ||
expect(values.length).toEqual(1); | ||
expect(values[0]).toEqual(JSON.stringify({ c: "c" })); | ||
state.update("a", { b: { c: "cc" } }); | ||
expect(values.length).toEqual(2); | ||
expect(values[1]).toEqual(JSON.stringify({ c: "cc" })); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
562113
42
14390