proxy-state-tree
Advanced tools
Comparing version 1.0.0-1535047853450 to 1.0.0-1535059157240
import proxify, { IS_PROXY, STATUS } from './proxify'; | ||
const isPlainObject = require('is-plain-object'); | ||
class ProxyStateTree { | ||
constructor(state, options = {}) { | ||
let stateObject = {}; | ||
try { | ||
stateObject = Object.keys(state).reduce((aggr, key) => { | ||
aggr[key] = state[key]; | ||
return aggr; | ||
}, {}); | ||
if (!isPlainObject(state)) { | ||
throw new Error('You did not pass a plain object as state to Proxy State Tree'); | ||
} | ||
catch (e) { | ||
console.warn('You passed a non-object value to Proxy State Tree '); | ||
} | ||
if (typeof options.devmode === 'undefined') { | ||
options.devmode = true; | ||
} | ||
this.state = stateObject; | ||
this.state = state; | ||
this.options = options; | ||
@@ -26,3 +20,3 @@ this.pathDependencies = {}; | ||
this.status = STATUS.IDLE; | ||
this.proxy = proxify(this, stateObject); | ||
this.proxy = proxify(this, state); | ||
this.currentFlushId = 0; | ||
@@ -29,0 +23,0 @@ } |
@@ -5,18 +5,12 @@ "use strict"; | ||
exports.IS_PROXY = proxify_1.IS_PROXY; | ||
const isPlainObject = require('is-plain-object'); | ||
class ProxyStateTree { | ||
constructor(state, options = {}) { | ||
let stateObject = {}; | ||
try { | ||
stateObject = Object.keys(state).reduce((aggr, key) => { | ||
aggr[key] = state[key]; | ||
return aggr; | ||
}, {}); | ||
if (!isPlainObject(state)) { | ||
throw new Error('You did not pass a plain object as state to Proxy State Tree'); | ||
} | ||
catch (e) { | ||
console.warn('You passed a non-object value to Proxy State Tree '); | ||
} | ||
if (typeof options.devmode === 'undefined') { | ||
options.devmode = true; | ||
} | ||
this.state = stateObject; | ||
this.state = state; | ||
this.options = options; | ||
@@ -30,3 +24,3 @@ this.pathDependencies = {}; | ||
this.status = proxify_1.STATUS.IDLE; | ||
this.proxy = proxify_1.default(this, stateObject); | ||
this.proxy = proxify_1.default(this, state); | ||
this.currentFlushId = 0; | ||
@@ -33,0 +27,0 @@ } |
{ | ||
"name": "proxy-state-tree", | ||
"version": "1.0.0-1535047853450", | ||
"version": "1.0.0-1535059157240", | ||
"description": "An implementation of the Mobx/Vue state tracking approach, for library authors", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
213401
2154