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

state-tree

Package Overview
Dependencies
Maintainers
1
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.1.9 to 0.1.10

2

package.json
{
"name": "state-tree",
"version": "0.1.9",
"version": "0.1.10",
"description": "A state tree that handles reference updates and lets you flush a description of changes",

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

@@ -228,2 +228,3 @@ # state-tree (EXPERIMENTAL)

import HOC from 'state-tree/react/HOC';
import {computed} from 'state-tree';
import addItem from './addItem';

@@ -230,0 +231,0 @@

@@ -231,43 +231,39 @@ var subscribers = [];

},
computed: function (deps, cb) {
var computedHasChanged = true;
var value = null;
return {
get: function (passedState) {
if (computedHasChanged) {
computedHasChanged = false;
value = cb(Object.keys(deps).reduce(function (props, key) {
var path = deps[key].split('.');
props[key] = getByPath(path, passedState);
return props;
}, {}));
return value;
} else {
return value;
}
},
// Can optimize by remembering the changes in case multiple
// components checks the computed, but very unlikely
hasChanged: function (changes) {
if (computedHasChanged) {
return true;
}
for (var key in deps) {
if (hasChanged(deps[key], changes)) {
computedHasChanged = true;
return true;
}
}
return false;
};
};
StateTree.computed = function (deps, cb) {
var computedHasChanged = true;
var value = null;
return {
get: function (passedState) {
if (computedHasChanged) {
computedHasChanged = false;
value = cb(Object.keys(deps).reduce(function (props, key) {
var path = deps[key].split('.');
props[key] = getByPath(path, passedState);
return props;
}, {}));
return value;
} else {
return value;
}
},
// Can optimize by remembering the changes in case multiple
// components checks the computed, but very unlikely
hasChanged: function (changes) {
if (computedHasChanged) {
return true;
}
for (var key in deps) {
if (hasChanged(deps[key], changes)) {
computedHasChanged = true;
return true;
}
}
return false;
}
};
};
}
}
/*
- Create computed
- ComponentWillMount, subscribe to computed
*/
module.exports = StateTree;
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