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

deep-storage

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-storage - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

1

index.d.ts

@@ -99,2 +99,3 @@ export declare type StateUpdateCallback = <DeepState>(path: Path, newState: DeepState, oldState: DeepState) => void;

updateIn: (...path: (string | number)[]) => <DeepState>(callback: (s: DeepState) => DeepState) => Promise<DeepState>;
cloneInitialState: (...path: (string | number)[]) => any;
stateIn: <DeepState>(...path: (string | number)[]) => any;

@@ -101,0 +102,0 @@ init: (state: State) => DeepStorage<State, State>;

@@ -117,2 +117,15 @@ "use strict";

};
this.cloneInitialState = function () {
var path = [];
for (var _i = 0; _i < arguments.length; _i++) {
path[_i] = arguments[_i];
}
var initialState = _this.initialStates[path.join('.')];
if (typeof initialState === 'undefined') {
return undefined;
}
else {
return JSON.parse(JSON.stringify(initialState));
}
};
this.stateIn = function () {

@@ -123,3 +136,3 @@ var path = [];

}
var currentState = typeof _this.state === 'undefined' ? _this.initialStates[''] : _this.state;
var currentState = typeof _this.state === 'undefined' ? _this.cloneInitialState() : _this.state;
var pathSoFar = [];

@@ -133,3 +146,3 @@ for (var _a = 0, path_1 = path; _a < path_1.length; _a++) {

// instead of an object
var init = _this.initialStates[pathSoFar.join('.')];
var init = _this.cloneInitialState.apply(_this, pathSoFar);
currentState[p] = typeof init === 'undefined' ? {} : init;

@@ -136,0 +149,0 @@ }

2

package.json
{
"name": "deep-storage",
"version": "1.0.4",
"version": "1.0.5",
"description": "Simple observable state management for reactive applications",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -154,4 +154,12 @@ export type StateUpdateCallback = <DeepState>(path: Path, newState: DeepState, oldState: DeepState) => void;

}
cloneInitialState = (...path: Path) => {
const initialState = this.initialStates[path.join('.')];
if(typeof initialState === 'undefined') {
return undefined;
} else {
return JSON.parse(JSON.stringify(initialState));
}
}
stateIn = <DeepState>(...path: Path) => {
let currentState: any = typeof this.state === 'undefined' ? this.initialStates[''] : this.state;
let currentState: any = typeof this.state === 'undefined' ? this.cloneInitialState() : this.state;
let pathSoFar = [];

@@ -164,3 +172,3 @@ for (let p of path) {

// instead of an object
const init = this.initialStates[pathSoFar.join('.')];
const init = this.cloneInitialState(...pathSoFar);
currentState[p] = typeof init === 'undefined' ? {} : init;

@@ -167,0 +175,0 @@ }

Sorry, the diff of this file is not supported yet

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