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.1 to 1.0.2

8

index.d.ts

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

/**
* Creates a new DeepStorage at this point in the object path and
* gives it an initial value if one hasn't already been set
*/
init: <DeepState>(...path: Path) => (deepState: DeepState) => DeepStorage<DeepState>;
/**
* Gets the root deep storage

@@ -84,2 +89,3 @@ */

private id;
private initialStates;
private subscriptions;

@@ -95,2 +101,3 @@ constructor(state: State);

stateIn: <DeepState>(...path: (string | number)[]) => any;
init: <DeepState>(...path: (string | number)[]) => (deepState: DeepState) => DeepStorage<DeepState, {}>;
deep: <DeepState>(...path: (string | number)[]) => DeepStorage<DeepState, {}>;

@@ -117,2 +124,3 @@ subscription: (callback: StateUpdateCallback) => {

stateIn: <DeepState>(...path: (string | number)[]) => DeepState;
init: <DeepState>(...path: (string | number)[]) => (deepState: DeepState) => DeepStorage<DeepState, {}>;
deep: <DeepState>(...path: (string | number)[]) => DeepStorage<DeepState, {}>;

@@ -119,0 +127,0 @@ subscription: (callback: StateUpdateCallback) => DeepSubscription;

34

lib/index.js

@@ -62,2 +62,3 @@ "use strict";

this.id = 0;
this.initialStates = {};
this.subscriptions = {};

@@ -122,3 +123,3 @@ this.update = function (callback) {

}
var currentState = _this.state;
var currentState = typeof _this.state === 'undefined' ? _this.initialStates[''] : _this.state;
for (var _a = 0, path_1 = path; _a < path_1.length; _a++) {

@@ -130,3 +131,4 @@ var p = path_1[_a];

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

@@ -137,2 +139,12 @@ currentState = currentState[p];

};
this.init = function () {
var path = [];
for (var _i = 0; _i < arguments.length; _i++) {
path[_i] = arguments[_i];
}
return function (deepState) {
_this.initialStates[path.join('.')] = deepState;
return new NestedDeepStorage(path, _this);
};
};
this.deep = function () {

@@ -173,4 +185,4 @@ var path = [];

var result = {};
var state = this.state;
for (var key in state) {
for (var _i = 0, _a = Object.keys(this.state); _i < _a.length; _i++) {
var key = _a[_i];
result[key] = this.deep(key);

@@ -227,2 +239,12 @@ }

};
this.init = function () {
var path = [];
for (var _i = 0; _i < arguments.length; _i++) {
path[_i] = arguments[_i];
}
return function (deepState) {
return (_a = _this.rootStorage).init.apply(_a, _this.path.concat(path))(deepState);
var _a;
};
};
this.deep = function () {

@@ -264,4 +286,4 @@ var path = [];

var result = {};
var state = this.state;
for (var key in state) {
for (var _i = 0, _a = Object.keys(this.state); _i < _a.length; _i++) {
var key = _a[_i];
result[key] = this.deep(key);

@@ -268,0 +290,0 @@ }

4

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

@@ -22,3 +22,3 @@ "main": "./lib/index.js",

"build": "rimraf lib *.d.ts && tsc -p tsconfig.prod.json",
"publish-patch": "yarn build && git commit -am 'build' && git push && npm version patch && git push && npm publish"
"publish-patch": "yarn build && git commit -am 'build' && git push && npm version patch && git push"
},

@@ -25,0 +25,0 @@ "dependencies": {},

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