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

deep-state-observer

Package Overview
Dependencies
Maintainers
1
Versions
225
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-state-observer - npm Package Compare versions

Comparing version 4.1.8 to 4.1.9

21

index.ts

@@ -342,14 +342,14 @@ import WildcardObject from "./wildcard-object-scan";

this.options = { ...getDefaultOptions(), ...options };
//if (this.options.useProxy) this.options.useObjectMaps = true;
if (this.options.useProxy) {
if (this.options.useObjectMaps) {
this.data = this.updateMapDown("", data, this.rootProxyNode, false);
} else {
this.data = this.makeObservable(data, "", this.rootProxyNode);
}
this.proxy = this.data;
this.$$$ = this.proxy;
} else {
if (this.options.useObjectMaps) {
this.data = this.updateMapDown("", data, this.rootProxyNode, false);
}
if (this.options.useProxy && !this.options.useObjectMaps) {
this.data = this.makeObservable(data, "", this.rootProxyNode);
}
if (!this.options.useObjectMaps && !this.options.useProxy) {
this.data = data;
}
this.proxy = this.data;
this.$$$ = this.proxy;

@@ -419,2 +419,3 @@ this.id = 0;

if (!this.options.useObjectMaps) return Path.get(this.split(path), this.data);
if (!path) return this.data;
return this.map.get(path);

@@ -421,0 +422,0 @@ }

{
"name": "deep-state-observer",
"version": "4.1.8",
"version": "4.1.9",
"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.cjs.js",

@@ -308,2 +308,26 @@ const State = require("../index.cjs.js");

it("should update root node (only maps)", () => {
const state = new State({ x: { y: { z: 1 } } }, { useObjectMaps: true, useProxy: false });
const values = [];
state.subscribe("x.y.z", (val) => {
values.push(val);
});
expect(values[0]).toEqual(1);
state.update("", (oldValue) => {
return { x: oldValue.x, xx: { yy: { zz: 1 } } };
});
expect(state.data.xx.yy.zz).toEqual(1);
expect(state.data[undefined]).toBeFalsy();
expect(state.get("x.y.z")).toEqual(1);
expect(state.get("xx.yy.zz")).toEqual(1);
state.update("yy.zz", 22);
expect(state.get("yy.zz")).toEqual(22);
expect(state.data.yy.zz).toEqual(22);
state.collect();
state.multi(true).update("e.as", "as").update("e.tu", "tu").done();
state.executeCollected();
expect(state.data.e.as).toEqual("as");
expect(state.data.e.tu).toEqual("tu");
});
it("should save function", () => {

@@ -310,0 +334,0 @@ const values = [];

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

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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