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.15 to 0.1.16

2

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

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

var React = require('react');
function hasChanged(path, changes) {
return path.split('.').reduce(function (changes, key) {
return changes[key];
path = Array.isArray(path) ? path : path.split('.');
return path.reduce(function (changes, key) {
return changes ? changes[key] : false;
}, changes);

@@ -12,9 +13,9 @@ }

contextTypes: {
tree: React.PropTypes.object
controller: React.PropTypes.object
},
componentWillMount() {
this.context.tree.subscribe(this.update);
this.context.controller.on('flush', this.update);
},
componentWillUnmount() {
this.context.tree.unsubscribe(this.update);
this.context.controller.removeListener('flush', this.update);
},

@@ -24,4 +25,4 @@ update(changes) {

if (
(typeof paths[key] === 'object' && paths[key].hasChanged(changes)) ||
(typeof paths[key] !== 'object' && hasChanged(paths[key], changes))
(paths[key].hasChanged && paths[key].hasChanged(changes)) ||
(!paths[key].hasChanged && hasChanged(paths[key], changes))
) {

@@ -33,6 +34,6 @@ return this.forceUpdate();

getProps() {
var tree = this.context.tree;
var controller = this.context.controller;
var props = this.props || {};
var propsToPass = Object.keys(paths || {}).reduce(function (props, key) {
props[key] = typeof paths[key] === 'object' ? paths[key].get(tree.get()) : tree.get(paths[key]);
props[key] = paths[key].hasChanged ? paths[key].get(controller.get()) : controller.get(paths[key]);
return props

@@ -46,2 +47,4 @@ }, {})

propsToPass.signals = this.context.controller.getSignals();
return propsToPass

@@ -48,0 +51,0 @@ },

@@ -322,3 +322,6 @@ var subscribers = [];

for (var key in deps) {
if (hasChanged(deps[key], changes)) {
if (
(typeof deps[key] === 'string' && hasChanged(deps[key], changes)) ||
(typeof deps[key] !== 'string' && deps[key].hasChanged(changes))
) {
computedHasChanged = true;

@@ -325,0 +328,0 @@ return true;

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