Skip to content

Commit

Permalink
Merge pull request #10 from JaapRood/fix/remove-deprecated-features
Browse files Browse the repository at this point in the history
Remove features deprecated in v2
  • Loading branch information
JaapRood authored May 9, 2018
2 parents 7c8c5aa + fa64637 commit 9db95a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
11 changes: 1 addition & 10 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,9 @@ internals.parse = (attrs) => {
return attrs
}

internals.serialize = (state, optionsOrOmit) => {
internals.serialize = (state, options) => {
var options;

// TODO: remove in v3.0
Warning(!_isPlainObject(optionsOrOmit), 'The `omitMeta` flag as a second argument to `state.serialize` has been deprecated. Instead, pass an object of `options` with an `omitMeta` flag as the second argument')

if (_isPlainObject(optionsOrOmit)) {
options = optionsOrOmit
} else {
options = { omitMeta: optionsOrOmit }
}

Invariant(exports.isState(state) || Immutable.Iterable.isIterable(state), 'State instance or Immutable Iterable is required to serialize state');
Invariant(!options || _isPlainObject(options), 'Options, when passed, must be a plain object when serializing a state instance')

Expand Down
8 changes: 1 addition & 7 deletions test/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Test('state.collectionOf', function(t) {
});

Test('state.serialize', function(t) {
t.plan(7 + 5 + 2 + 2);
t.plan(7 + 5 + 2);

var state = State.create('test-model', {});

Expand Down Expand Up @@ -284,12 +284,6 @@ Test('state.serialize', function(t) {
t.equal(instance.get('__typeName'), serializedIncluded.__typeName, 'serialized object contains the state type name of the instance when passing true for the `omitMeta` option')
}, 'accepts a State instance and options with a flag to omit meta data');

t.doesNotThrow(function() {
var serializedIncluded = state.serialize(instance, false);

t.equal(instance.get('__cid'), serializedIncluded.__cid, 'serialized object contains the client identifier of the instance when passing true as the second argument');
}, 'accepts a State instance and a flag to omit meta data (backwards compat for 1.x)');

t.doesNotThrow(function() {
const serialized = state.serialize(instance)
const noContext = state.serialize.call(null, instance)
Expand Down

0 comments on commit 9db95a2

Please sign in to comment.