fix: immutable

This commit is contained in:
cha0s 2021-01-28 23:57:03 -06:00
parent 8766e8d6f0
commit bad8b199dc

View File

@ -10,20 +10,26 @@ export default class JsonResource extends Resource {
}
static async extendJson(json) {
if ('string' === typeof json.extends) {
// eslint-disable-next-line no-param-reassign
json.extends = await this.read(json.extends);
}
return this.mergeJson(json);
return this.mergeJson(
'string' === typeof json.extends
? {
...json,
extends: await this.read(json.extends),
}
: json,
);
}
static async load(json = {}) {
const resource = new this();
if ('string' === typeof json.extends) {
// eslint-disable-next-line no-param-reassign
json.uri = json.extends;
}
await resource.load(await this.extendJson(json));
await resource.load(await this.extendJson(
'string' === typeof json.extends
? {
...json,
uri: json.extends,
}
: json,
));
return resource;
}