Comparing version 5.0.0-1528833169015 to 5.0.0-1528907706035
@@ -1,6 +0,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; }; }(); | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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; }; }(); | ||
@@ -11,5 +9,46 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { Tag } from 'function-tree'; | ||
import Watch from './Watch'; | ||
import { isComputedValue } from './utils'; | ||
export var NestedComputedValue = function () { | ||
function NestedComputedValue(computed, nestedPath) { | ||
_classCallCheck(this, NestedComputedValue); | ||
this.computed = computed; | ||
this.propsTags = computed.propsTags; | ||
this.nestedPath = nestedPath; | ||
} | ||
_createClass(NestedComputedValue, [{ | ||
key: 'getValue', | ||
value: function getValue(props) { | ||
return this.nestedPath.reduce(function (currentValue, key) { | ||
return currentValue && currentValue[key]; | ||
}, this.computed.getValue()); | ||
} | ||
}, { | ||
key: 'clone', | ||
value: function clone() { | ||
return this.computed.clone(); | ||
} | ||
}, { | ||
key: 'subscribe', | ||
value: function subscribe() { | ||
var _computed; | ||
return (_computed = this.computed).subscribe.apply(_computed, arguments); | ||
} | ||
}, { | ||
key: 'destroy', | ||
value: function destroy() { | ||
return this.computed.destroy(); | ||
} | ||
}]); | ||
return NestedComputedValue; | ||
}(); | ||
export var Compute = function (_Watch) { | ||
@@ -106,3 +145,3 @@ _inherits(Compute, _Watch); | ||
_this3.propsTags.push(tag); | ||
} else if (tag.type === 'state' && tag.getValue(_this3.getters) instanceof Compute) { | ||
} else if (tag.type === 'state' && isComputedValue(tag.getValue(_this3.getters))) { | ||
_this3.computedTags.push(tag); | ||
@@ -116,3 +155,3 @@ } else { | ||
if (value instanceof Compute) { | ||
if (isComputedValue(value)) { | ||
return value.getValue(this.props); | ||
@@ -119,0 +158,0 @@ } |
@@ -13,5 +13,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 { Reaction } from './Reaction'; | ||
import { Compute } from './Compute'; | ||
import { Tag } from 'function-tree'; | ||
import { ensureStrictPath, extractModuleProp } from './utils'; | ||
import { ensureStrictPath, extractModuleProp, isComputedValue } from './utils'; | ||
@@ -124,3 +123,3 @@ /* | ||
if (value instanceof Compute) { | ||
if (isComputedValue(value)) { | ||
return value.getValue(overrideProps); | ||
@@ -167,3 +166,3 @@ } | ||
if (value instanceof Compute) { | ||
if (isComputedValue(value)) { | ||
return updatedCurrentDepsMap; | ||
@@ -170,0 +169,0 @@ } |
@@ -63,3 +63,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.version = "5.0.0-1528833169015"; | ||
_this.version = "5.0.0-1528907706035"; | ||
_this.debuggerWatchMap = {}; | ||
@@ -66,0 +66,0 @@ _this.debuggerComputedMap = {}; |
@@ -13,2 +13,3 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
import BaseModel from './BaseModel'; | ||
import { Compute, NestedComputedValue } from './Compute'; | ||
@@ -110,3 +111,10 @@ var Model = function (_BaseModel) { | ||
return path.reduce(function (currentState, key) { | ||
return path.reduce(function (currentState, key, index) { | ||
if (currentState instanceof NestedComputedValue) { | ||
return currentState; | ||
} | ||
if (currentState instanceof Compute) { | ||
return new NestedComputedValue(currentState, path.slice(index)); | ||
} | ||
return currentState ? currentState[key] : undefined; | ||
@@ -113,0 +121,0 @@ }, this.state); |
import Provider from '../Provider'; | ||
import { Compute } from '../Compute'; | ||
import { isComputedValue } from '../utils'; | ||
@@ -7,3 +7,3 @@ export default Provider(function (context) { | ||
var value = context.resolve.value(tag); | ||
if (value instanceof Compute) { | ||
if (isComputedValue(value)) { | ||
return value.getValue(overrides || context.props); | ||
@@ -10,0 +10,0 @@ } |
@@ -12,3 +12,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; }; }(); | ||
import Watch from './Watch'; | ||
import { Compute } from './Compute'; | ||
import { isComputedValue } from './utils'; | ||
@@ -64,3 +64,3 @@ export var Reaction = function (_Watch) { | ||
if (currentDeps[key] instanceof Compute) { | ||
if (isComputedValue(currentDeps[key])) { | ||
currentDeps[key] = currentDeps[key].getValue(); | ||
@@ -67,0 +67,0 @@ } |
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
import { Tag } from './tags'; | ||
import { Compute } from './Compute'; | ||
import { Compute, NestedComputedValue } from './Compute'; | ||
import { Provider } from 'function-tree'; | ||
@@ -222,6 +222,6 @@ | ||
isCompute: function isCompute(arg) { | ||
return arg instanceof Compute; | ||
return isComputedValue(arg); | ||
}, | ||
value: function value(arg, overrideProps) { | ||
if (arg instanceof Tag || arg instanceof Compute) { | ||
if (arg instanceof Tag || isComputedValue(arg)) { | ||
return arg.getValue(overrideProps ? Object.assign({}, getters, { props: overrideProps }) : getters); | ||
@@ -353,2 +353,6 @@ } | ||
} | ||
export function isComputedValue(value) { | ||
return value instanceof Compute || value instanceof NestedComputedValue; | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -10,5 +10,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 { Tag } from 'function-tree'; | ||
import { getChangedProps, throwError, getStateTreeProp, noop } from './utils'; | ||
import { getChangedProps, throwError, getStateTreeProp, noop, isComputedValue } from './utils'; | ||
import Watch from './Watch'; | ||
import { Compute } from './Compute'; | ||
import Reaction from './Reaction'; | ||
@@ -194,3 +193,3 @@ | ||
return Object.keys(this.dependencies).reduce(function (computed, key) { | ||
if (_this5.dependencies[key] instanceof Tag && _this5.dependencies[key].getValue(getters) instanceof Compute) { | ||
if (_this5.dependencies[key] instanceof Tag && isComputedValue(_this5.dependencies[key].getValue(getters))) { | ||
var computedInstance = _this5.dependencies[key].getValue(getters); | ||
@@ -225,3 +224,3 @@ var attachedComputed = computedInstance.propsTags.length ? computedInstance.clone() : computedInstance; | ||
if (value instanceof Compute) { | ||
if (isComputedValue(value)) { | ||
var computedInstance = tag.getValue(getters); | ||
@@ -268,3 +267,3 @@ var attachedComputed = computedInstance.propsTags.length ? computedInstance.clone() : computedInstance; | ||
currentProps[key] = value instanceof Compute ? value.getValue(props) : value; | ||
currentProps[key] = isComputedValue(value) ? value.getValue(props) : value; | ||
@@ -287,3 +286,3 @@ return currentProps; | ||
if (value instanceof Compute) { | ||
if (isComputedValue(value)) { | ||
return value.getValue(props); | ||
@@ -290,0 +289,0 @@ } |
@@ -6,8 +6,8 @@ 'use strict'; | ||
}); | ||
exports.Compute = undefined; | ||
exports.Compute = exports.NestedComputedValue = undefined; | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
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; }; }(); | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
var _functionTree = require('function-tree'); | ||
@@ -19,6 +19,6 @@ | ||
var _utils = require('./utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
@@ -28,2 +28,42 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var NestedComputedValue = exports.NestedComputedValue = function () { | ||
function NestedComputedValue(computed, nestedPath) { | ||
_classCallCheck(this, NestedComputedValue); | ||
this.computed = computed; | ||
this.propsTags = computed.propsTags; | ||
this.nestedPath = nestedPath; | ||
} | ||
_createClass(NestedComputedValue, [{ | ||
key: 'getValue', | ||
value: function getValue(props) { | ||
return this.nestedPath.reduce(function (currentValue, key) { | ||
return currentValue && currentValue[key]; | ||
}, this.computed.getValue()); | ||
} | ||
}, { | ||
key: 'clone', | ||
value: function clone() { | ||
return this.computed.clone(); | ||
} | ||
}, { | ||
key: 'subscribe', | ||
value: function subscribe() { | ||
var _computed; | ||
return (_computed = this.computed).subscribe.apply(_computed, arguments); | ||
} | ||
}, { | ||
key: 'destroy', | ||
value: function destroy() { | ||
return this.computed.destroy(); | ||
} | ||
}]); | ||
return NestedComputedValue; | ||
}(); | ||
var Compute = exports.Compute = function (_Watch) { | ||
@@ -120,3 +160,3 @@ _inherits(Compute, _Watch); | ||
_this3.propsTags.push(tag); | ||
} else if (tag.type === 'state' && tag.getValue(_this3.getters) instanceof Compute) { | ||
} else if (tag.type === 'state' && (0, _utils.isComputedValue)(tag.getValue(_this3.getters))) { | ||
_this3.computedTags.push(tag); | ||
@@ -130,3 +170,3 @@ } else { | ||
if (value instanceof Compute) { | ||
if ((0, _utils.isComputedValue)(value)) { | ||
return value.getValue(this.props); | ||
@@ -133,0 +173,0 @@ } |
@@ -23,4 +23,2 @@ 'use strict'; | ||
var _Compute = require('./Compute'); | ||
var _functionTree = require('function-tree'); | ||
@@ -143,3 +141,3 @@ | ||
if (value instanceof _Compute.Compute) { | ||
if ((0, _utils.isComputedValue)(value)) { | ||
return value.getValue(overrideProps); | ||
@@ -186,3 +184,3 @@ } | ||
if (value instanceof _Compute.Compute) { | ||
if ((0, _utils.isComputedValue)(value)) { | ||
return updatedCurrentDepsMap; | ||
@@ -189,0 +187,0 @@ } |
@@ -81,3 +81,3 @@ 'use strict'; | ||
_this.version = "5.0.0-1528833169015"; | ||
_this.version = "5.0.0-1528907706035"; | ||
_this.debuggerWatchMap = {}; | ||
@@ -84,0 +84,0 @@ _this.debuggerComputedMap = {}; |
@@ -17,2 +17,4 @@ 'use strict'; | ||
var _Compute = require('./Compute'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -121,3 +123,10 @@ | ||
return path.reduce(function (currentState, key) { | ||
return path.reduce(function (currentState, key, index) { | ||
if (currentState instanceof _Compute.NestedComputedValue) { | ||
return currentState; | ||
} | ||
if (currentState instanceof _Compute.Compute) { | ||
return new _Compute.NestedComputedValue(currentState, path.slice(index)); | ||
} | ||
return currentState ? currentState[key] : undefined; | ||
@@ -124,0 +133,0 @@ }, this.state); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
var _Compute = require('../Compute'); | ||
var _utils = require('../utils'); | ||
@@ -19,3 +19,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var value = context.resolve.value(tag); | ||
if (value instanceof _Compute.Compute) { | ||
if ((0, _utils.isComputedValue)(value)) { | ||
return value.getValue(overrides || context.props); | ||
@@ -22,0 +22,0 @@ } |
@@ -16,3 +16,3 @@ 'use strict'; | ||
var _Compute = require('./Compute'); | ||
var _utils = require('./utils'); | ||
@@ -76,3 +76,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
if (currentDeps[key] instanceof _Compute.Compute) { | ||
if ((0, _utils.isComputedValue)(currentDeps[key])) { | ||
currentDeps[key] = currentDeps[key].getValue(); | ||
@@ -79,0 +79,0 @@ } |
@@ -32,2 +32,3 @@ 'use strict'; | ||
exports.getRootPath = getRootPath; | ||
exports.isComputedValue = isComputedValue; | ||
@@ -255,6 +256,6 @@ var _tags = require('./tags'); | ||
isCompute: function isCompute(arg) { | ||
return arg instanceof _Compute.Compute; | ||
return isComputedValue(arg); | ||
}, | ||
value: function value(arg, overrideProps) { | ||
if (arg instanceof _tags.Tag || arg instanceof _Compute.Compute) { | ||
if (arg instanceof _tags.Tag || isComputedValue(arg)) { | ||
return arg.getValue(overrideProps ? Object.assign({}, getters, { props: overrideProps }) : getters); | ||
@@ -386,2 +387,6 @@ } | ||
} | ||
function isComputedValue(value) { | ||
return value instanceof _Compute.Compute || value instanceof _Compute.NestedComputedValue; | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -17,4 +17,2 @@ 'use strict'; | ||
var _Compute = require('./Compute'); | ||
var _Reaction = require('./Reaction'); | ||
@@ -210,3 +208,3 @@ | ||
return Object.keys(this.dependencies).reduce(function (computed, key) { | ||
if (_this5.dependencies[key] instanceof _functionTree.Tag && _this5.dependencies[key].getValue(getters) instanceof _Compute.Compute) { | ||
if (_this5.dependencies[key] instanceof _functionTree.Tag && (0, _utils.isComputedValue)(_this5.dependencies[key].getValue(getters))) { | ||
var computedInstance = _this5.dependencies[key].getValue(getters); | ||
@@ -241,3 +239,3 @@ var attachedComputed = computedInstance.propsTags.length ? computedInstance.clone() : computedInstance; | ||
if (value instanceof _Compute.Compute) { | ||
if ((0, _utils.isComputedValue)(value)) { | ||
var computedInstance = tag.getValue(getters); | ||
@@ -284,3 +282,3 @@ var attachedComputed = computedInstance.propsTags.length ? computedInstance.clone() : computedInstance; | ||
currentProps[key] = value instanceof _Compute.Compute ? value.getValue(props) : value; | ||
currentProps[key] = (0, _utils.isComputedValue)(value) ? value.getValue(props) : value; | ||
@@ -303,3 +301,3 @@ return currentProps; | ||
if (value instanceof _Compute.Compute) { | ||
if ((0, _utils.isComputedValue)(value)) { | ||
return value.getValue(props); | ||
@@ -306,0 +304,0 @@ } |
{ | ||
"name": "cerebral", | ||
"version": "5.0.0-1528833169015", | ||
"version": "5.0.0-1528907706035", | ||
"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-1528833169015" | ||
"function-tree": "^3.3.0-1528907706035" | ||
}, | ||
@@ -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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
772913
7692