fix: immutable
This commit is contained in:
parent
8766e8d6f0
commit
bad8b199dc
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user