diff --git a/packages/entity/index.js b/packages/entity/index.js index be688bc..e1a4985 100644 --- a/packages/entity/index.js +++ b/packages/entity/index.js @@ -90,21 +90,6 @@ let numericUid = 1; export class Entity extends decorate(Resource) { - static jsonWithDefaults(json) { - if ('undefined' === typeof json) { - return; - } - const pristine = JSON.parse(JSON.stringify(json)); - for (const type in json.traits) { - if (!hasTrait(type)) { - continue; - } - const Trait = lookupTrait(type); - pristine.traits[type] = merge({}, Trait.defaultJSON(), json.traits[type]); - } - return pristine; - } - constructor(json, jsonext) { super(); this._hooks = {}; @@ -254,6 +239,21 @@ export class Entity extends decorate(Resource) { return type in this._traits; } + static jsonWithDefaults(json) { + if ('undefined' === typeof json) { + return; + } + const pristine = JSON.parse(JSON.stringify(json)); + for (const type in json.traits) { + if (!hasTrait(type)) { + continue; + } + const Trait = lookupTrait(type); + pristine.traits[type] = merge({}, Trait.defaultJSON(), json.traits[type]); + } + return pristine; + } + mergeDiff() { if (!this.uri) { return this.toJSON();