cerebral-model-immutable-js
Advanced tools
Comparing version 0.1.5 to 0.2.0
21
index.js
var Immutable = require('immutable'); | ||
var Baobab = require('baobab'); | ||
@@ -14,4 +15,4 @@ var Model = function (initialState) { | ||
controller.on('seek', function (seek, recording) { | ||
recording.initialState.forEach(function (state) { | ||
tree.set(state.path, state.value); | ||
recording.initialState.forEach(function (stateUpdate) { | ||
state = state.setIn(stateUpdate.path, Immutable.fromJS(stateUpdate.value)); | ||
}); | ||
@@ -29,3 +30,3 @@ }); | ||
toJS: function (path) { | ||
return state.get(path).toJS(); | ||
return state.getIn(path).toJS(); | ||
}, | ||
@@ -51,6 +52,6 @@ export: function () { | ||
import: function (newState) { | ||
return state = state.mergeDeep(newState); | ||
return state = state.mergeDeep(Immutable.fromJS(newState)); | ||
}, | ||
set: function (path, value) { | ||
state = state.setIn(path, value); | ||
state = state.setIn(path, Immutable.fromJS(value)); | ||
}, | ||
@@ -69,3 +70,3 @@ unset: function (path, keys) { | ||
state = state.updateIn(path, function (array) { | ||
return array.push(value); | ||
return array.push(Immutable.fromJS(value)); | ||
}); | ||
@@ -77,7 +78,7 @@ }, | ||
state = state.updateIn(path, function (array) { | ||
return array.splice.apply(array, args); | ||
return array.splice.apply(array, args.map(Immutable.fromJS.bind(Immutable))); | ||
}); | ||
}, | ||
merge: function (path, value) { | ||
state = state.mergeIn(path, value); | ||
state = state.mergeIn(path, Immutable.fromJS(value)); | ||
}, | ||
@@ -88,3 +89,3 @@ concat: function () { | ||
state = state.updateIn(path, function (array) { | ||
return array.concat.apply(array, args); | ||
return array.concat.apply(array, args.map(Immutable.fromJS.bind(Immutable))); | ||
}); | ||
@@ -106,3 +107,3 @@ }, | ||
state = state.updateIn(path, function (array) { | ||
return array.unshift.apply(array, args); | ||
return array.unshift.apply(array, args.map(Immutable.fromJS.bind(Immutable))); | ||
}); | ||
@@ -109,0 +110,0 @@ } |
{ | ||
"name": "cerebral-model-immutable-js", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "A state package for Cerebral", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
11138
303