New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cerebral

Package Overview
Dependencies
Maintainers
5
Versions
638
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cerebral - npm Package Compare versions

Comparing version 5.0.0-1526222433248 to 5.0.0-1526334609969

6

es/Computed.js

@@ -87,6 +87,6 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

}).map(function (computed) {
return computed.subscribe(_this3.onSubscription);
return computed.subscribe(_this3, _this3.onSubscription);
});
}
this.executedCount++;
return this.computedCallback(Object.keys(this.dependencies).reduce(function (values, key) {

@@ -154,3 +154,3 @@ var dependency = _this3.dependencies[key];

if (!this.watcherSubscription) {
this.watcherSubscription = this.subscribe(this.onSubscription);
this.watcherSubscription = this.subscribe(this, this.onSubscription);
}

@@ -157,0 +157,0 @@

@@ -16,2 +16,4 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

import { DevtoolsBase } from 'function-tree/devtools';
import { Computed } from '../Computed';
var PLACEHOLDER_INITIAL_MODEL = 'PLACEHOLDER_INITIAL_MODEL';

@@ -60,4 +62,5 @@ var PLACEHOLDER_DEBUGGING_DATA = '$$DEBUGGING_DATA$$';

_this.version = "5.0.0-1526222433248";
_this.version = "5.0.0-1526334609969";
_this.debuggerWatchMap = {};
_this.debuggerComputedMap = {};
_this.storeMutations = storeMutations;

@@ -223,3 +226,4 @@ _this.preventExternalMutations = preventExternalMutations;

data: {
map: this.debuggerWatchMap,
watchMap: this.debuggerWatchMap,
computedMap: this.debuggerComputedMap,
updates: {

@@ -303,2 +307,17 @@ ids: []

/*
Updates a map of computed watchers
*/
}, {
key: 'updateComputedMap',
value: function updateComputedMap(computed, subscribers) {
if (computed instanceof Computed) {
this.debuggerComputedMap[computed.name] = subscribers.filter(function (subscriber) {
return subscriber.watcher !== computed;
}).map(function (subscriber) {
return subscriber.watcher;
});
}
}
/*
Sends watch map to debugger. It is debounced (check constructor).

@@ -319,3 +338,4 @@ It needs to wait because React updates async. Instead of tracking

data: {
map: this.debuggerWatchMap,
watchMap: this.debuggerWatchMap,
computedMap: this.debuggerComputedMap,
updates: {

@@ -322,0 +342,0 @@ start: start,

@@ -42,3 +42,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

if (_this2.dependencies[key].type === 'computed') {
return currentSubscriptions.concat(_this2.dependencies[key].getValue(_this2.context).subscribe(_this2.onSubscriptionUpdate));
return currentSubscriptions.concat(_this2.dependencies[key].getValue(_this2.context).subscribe(_this2, _this2.onSubscriptionUpdate));
}

@@ -48,3 +48,3 @@

}, []);
this.subscribe(this.onSubscriptionUpdate);
this.subscribe(this, this.onSubscriptionUpdate);

@@ -58,2 +58,6 @@ return this;

this.executedCount++;
if (this.controller.devtools) {
this.controller.devtools.sendWatchMap([], [], 0, 0);
}
this.cb(Object.keys(this.dependencies).reduce(function (currentDeps, key) {

@@ -60,0 +64,0 @@ currentDeps[key] = _this3.dependencies[key].getValue(_this3.context);

@@ -74,2 +74,8 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

value: function updateWatchMap() {}
}, {
key: 'updateComputedMap',
value: function updateComputedMap() {}
}, {
key: 'sendWatchMap',
value: function sendWatchMap() {}
}]);

@@ -76,0 +82,0 @@

@@ -95,3 +95,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

this.create(this.controller, [], this._displayName);
this.subscribe(function () {
this.subscribe(this, function () {
if (_this3.isUnmounted) {

@@ -198,3 +198,3 @@ return;

computed: attachedComputed,
unsubscribe: attachedComputed.subscribe(_this5.updateComponent)
unsubscribe: attachedComputed.subscribe(_this5, _this5.updateComponent)
};

@@ -223,3 +223,3 @@ }

var computed = tag.getValue(getters).clone();
computed.subscribe(_this6.updateComponent);
computed.subscribe(_this6, _this6.updateComponent);
_this6.dynamicComputed.push(computed);

@@ -305,3 +305,6 @@ return computed.getValue(props);

var viewProps = this.getProps(getters, props, includeProps);
this.executedCount++;
if (this.controller.devtools) {
this.controller.devtools.sendWatchMap([], [], 0, 0);
}
return cb(viewProps);

@@ -308,0 +311,0 @@ }

@@ -31,10 +31,12 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

value: function onUpdate(changes, force) {
this.executedCount++;
this.subscribers.forEach(function (subscription) {
subscription.cb(changes, force);
});
if (this.controller.devtools) {
this.controller.devtools.updateComputedMap(this, this.subscribers);
}
}
}, {
key: 'subscribe',
value: function subscribe(cb) {
value: function subscribe(watcher, cb) {
var _this = this;

@@ -47,16 +49,21 @@

this.controller.devtools.updateWatchMap(this, this.dependencyMap);
this.controller.devtools.sendWatchMap([], [], 0, 0);
}
}
var index = this.subscribers.length;
var unsubscribe = function unsubscribe() {
_this.subscribers.splice(index, 1);
var subscription = {
unsubscribe: function unsubscribe() {
_this.subscribers.splice(_this.subscribers.indexOf(subscription), 1);
},
cb: cb,
watcher: watcher
};
this.subscribers.push({
unsubscribe: unsubscribe,
cb: cb
});
this.subscribers.push(subscription);
return unsubscribe;
if (this.controller.devtools) {
this.controller.devtools.updateComputedMap(this, this.subscribers);
}
return subscription.unsubscribe;
}

@@ -72,5 +79,5 @@ }, {

this.controller.dependencyStore.removeEntity(this, this.dependencyMap);
if (this.controller.devtools) {
this.controller.devtools.updateWatchMap(this, null, this.dependencyMap);
this.controller.devtools.sendWatchMap([], [], 0, 0);
}

@@ -77,0 +84,0 @@ }

@@ -100,6 +100,6 @@ 'use strict';

}).map(function (computed) {
return computed.subscribe(_this3.onSubscription);
return computed.subscribe(_this3, _this3.onSubscription);
});
}
this.executedCount++;
return this.computedCallback(Object.keys(this.dependencies).reduce(function (values, key) {

@@ -167,3 +167,3 @@ var dependency = _this3.dependencies[key];

if (!this.watcherSubscription) {
this.watcherSubscription = this.subscribe(this.onSubscription);
this.watcherSubscription = this.subscribe(this, this.onSubscription);
}

@@ -170,0 +170,0 @@

@@ -24,2 +24,4 @@ 'use strict';

var _Computed = require('../Computed');
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

@@ -78,4 +80,5 @@

_this.version = "5.0.0-1526222433248";
_this.version = "5.0.0-1526334609969";
_this.debuggerWatchMap = {};
_this.debuggerComputedMap = {};
_this.storeMutations = storeMutations;

@@ -241,3 +244,4 @@ _this.preventExternalMutations = preventExternalMutations;

data: {
map: this.debuggerWatchMap,
watchMap: this.debuggerWatchMap,
computedMap: this.debuggerComputedMap,
updates: {

@@ -321,2 +325,17 @@ ids: []

/*
Updates a map of computed watchers
*/
}, {
key: 'updateComputedMap',
value: function updateComputedMap(computed, subscribers) {
if (computed instanceof _Computed.Computed) {
this.debuggerComputedMap[computed.name] = subscribers.filter(function (subscriber) {
return subscriber.watcher !== computed;
}).map(function (subscriber) {
return subscriber.watcher;
});
}
}
/*
Sends watch map to debugger. It is debounced (check constructor).

@@ -337,3 +356,4 @@ It needs to wait because React updates async. Instead of tracking

data: {
map: this.debuggerWatchMap,
watchMap: this.debuggerWatchMap,
computedMap: this.debuggerComputedMap,
updates: {

@@ -340,0 +360,0 @@ start: start,

@@ -54,3 +54,3 @@ 'use strict';

if (_this2.dependencies[key].type === 'computed') {
return currentSubscriptions.concat(_this2.dependencies[key].getValue(_this2.context).subscribe(_this2.onSubscriptionUpdate));
return currentSubscriptions.concat(_this2.dependencies[key].getValue(_this2.context).subscribe(_this2, _this2.onSubscriptionUpdate));
}

@@ -60,3 +60,3 @@

}, []);
this.subscribe(this.onSubscriptionUpdate);
this.subscribe(this, this.onSubscriptionUpdate);

@@ -70,2 +70,6 @@ return this;

this.executedCount++;
if (this.controller.devtools) {
this.controller.devtools.sendWatchMap([], [], 0, 0);
}
this.cb(Object.keys(this.dependencies).reduce(function (currentDeps, key) {

@@ -72,0 +76,0 @@ currentDeps[key] = _this3.dependencies[key].getValue(_this3.context);

@@ -83,2 +83,8 @@ 'use strict';

value: function updateWatchMap() {}
}, {
key: 'updateComputedMap',
value: function updateComputedMap() {}
}, {
key: 'sendWatchMap',
value: function sendWatchMap() {}
}]);

@@ -85,0 +91,0 @@

@@ -110,3 +110,3 @@ 'use strict';

this.create(this.controller, [], this._displayName);
this.subscribe(function () {
this.subscribe(this, function () {
if (_this3.isUnmounted) {

@@ -213,3 +213,3 @@ return;

computed: attachedComputed,
unsubscribe: attachedComputed.subscribe(_this5.updateComponent)
unsubscribe: attachedComputed.subscribe(_this5, _this5.updateComponent)
};

@@ -238,3 +238,3 @@ }

var computed = tag.getValue(getters).clone();
computed.subscribe(_this6.updateComponent);
computed.subscribe(_this6, _this6.updateComponent);
_this6.dynamicComputed.push(computed);

@@ -320,3 +320,6 @@ return computed.getValue(props);

var viewProps = this.getProps(getters, props, includeProps);
this.executedCount++;
if (this.controller.devtools) {
this.controller.devtools.sendWatchMap([], [], 0, 0);
}
return cb(viewProps);

@@ -323,0 +326,0 @@ }

@@ -37,10 +37,12 @@ 'use strict';

value: function onUpdate(changes, force) {
this.executedCount++;
this.subscribers.forEach(function (subscription) {
subscription.cb(changes, force);
});
if (this.controller.devtools) {
this.controller.devtools.updateComputedMap(this, this.subscribers);
}
}
}, {
key: 'subscribe',
value: function subscribe(cb) {
value: function subscribe(watcher, cb) {
var _this = this;

@@ -53,16 +55,21 @@

this.controller.devtools.updateWatchMap(this, this.dependencyMap);
this.controller.devtools.sendWatchMap([], [], 0, 0);
}
}
var index = this.subscribers.length;
var unsubscribe = function unsubscribe() {
_this.subscribers.splice(index, 1);
var subscription = {
unsubscribe: function unsubscribe() {
_this.subscribers.splice(_this.subscribers.indexOf(subscription), 1);
},
cb: cb,
watcher: watcher
};
this.subscribers.push({
unsubscribe: unsubscribe,
cb: cb
});
this.subscribers.push(subscription);
return unsubscribe;
if (this.controller.devtools) {
this.controller.devtools.updateComputedMap(this, this.subscribers);
}
return subscription.unsubscribe;
}

@@ -78,5 +85,5 @@ }, {

this.controller.dependencyStore.removeEntity(this, this.dependencyMap);
if (this.controller.devtools) {
this.controller.devtools.updateWatchMap(this, null, this.dependencyMap);
this.controller.devtools.sendWatchMap([], [], 0, 0);
}

@@ -83,0 +90,0 @@ }

{
"name": "cerebral",
"version": "5.0.0-1526222433248",
"version": "5.0.0-1526334609969",
"description": "A state controller with its own debugger",

@@ -24,3 +24,3 @@ "main": "index.js",

"es6-error": "^4.0.2",
"function-tree": "^3.3.0-1526222433248"
"function-tree": "^3.3.0-1526334609969"
},

@@ -27,0 +27,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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