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

state-tree

Package Overview
Dependencies
Maintainers
3
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.2.3 to 0.2.4

README.md

4

lib/computed.d.ts
declare class Computed {
static getByPath: any;
static hasChanged: any;
private _value;
private _computedHasChanged;
private _deps;

@@ -11,4 +8,3 @@ private _cb;

get(passedState: any): any;
hasChanged(changes: any): boolean;
}
export default Computed;

@@ -7,4 +7,2 @@ "use strict";

return new Computed(_deps, _cb);
this._computedHasChanged = true;
this._value = null;
this._deps = _deps;

@@ -18,34 +16,12 @@ this._cb = _cb;

var _this = this;
if (this._computedHasChanged) {
this._computedHasChanged = false;
this._value = this._cb(Object.keys(this._deps).reduce(function (props, key) {
if (typeof _this._deps[key] === 'string') {
var path = _this._deps[key].split('.');
props[key] = Computed.getByPath(path, passedState);
}
else {
props[key] = _this._deps[key].get(passedState);
}
return props;
}, {}));
return this._value;
}
else {
return this._value;
}
};
// Can optimize by remembering the changes in case multiple
// components checks the computed, but very unlikely
Computed.prototype.hasChanged = function (changes) {
if (this._computedHasChanged) {
return true;
}
for (var key in this._deps) {
if ((typeof this._deps[key] === 'string' && Computed.hasChanged(this._deps[key], changes)) ||
(typeof this._deps[key] !== 'string' && this._deps[key].hasChanged(changes))) {
this._computedHasChanged = true;
return true;
return this._cb(Object.keys(this._deps).reduce(function (props, key) {
if (typeof _this._deps[key] === 'string') {
var path = _this._deps[key].split('.');
props[key] = Computed.getByPath(path, passedState);
}
}
return false;
else {
props[key] = _this._deps[key].get(passedState);
}
return props;
}, {}));
};

@@ -55,5 +31,4 @@ return Computed;

Computed.getByPath = utils_1.getByPath;
Computed.hasChanged = utils_1.hasChanged;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Computed;
//# sourceMappingURL=computed.js.map

@@ -5,2 +5,1 @@ export declare function getByPath(path: any, state: any, forcePath?: any): any;

};
export declare function hasChanged(path: any, changes: any): any;

@@ -61,8 +61,2 @@ "use strict";

exports.deepmerge = deepmerge;
function hasChanged(path, changes) {
return path.split('.').reduce(function (changes, key) {
return changes ? changes[key] : false;
}, changes);
}
exports.hasChanged = hasChanged;
//# sourceMappingURL=utils.js.map
{
"name": "state-tree",
"version": "0.2.3",
"version": "0.2.4",
"description": "A state tree that handles reference updates and lets you flush a description of changes",

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

Sorry, the diff of this file is not supported yet

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