refactor: sort trait keys
This commit is contained in:
parent
bdd5152e77
commit
5f189009b9
|
@ -71,12 +71,26 @@ export default class EntityController extends JsonResourceController {
|
|||
|
||||
static decode(encoded, latus) {
|
||||
const {Entity} = latus.get('%resources');
|
||||
return super.decode(Entity.withoutDefaults(encoded));
|
||||
const json = Entity.withoutDefaults(encoded);
|
||||
return super.decode({
|
||||
...json,
|
||||
traits: Object.fromEntries(
|
||||
Object.entries(json.traits)
|
||||
.sort(([l], [r]) => (l < r ? -1 : 1)),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
static encode(buffer, latus) {
|
||||
const {Entity} = latus.get('%resources');
|
||||
return Entity.withDefaults(super.encode(buffer));
|
||||
const json = Entity.withDefaults(super.encode(buffer));
|
||||
return {
|
||||
...json,
|
||||
traits: Object.fromEntries(
|
||||
Object.entries(json.traits)
|
||||
.sort(([l], [r]) => (l < r ? -1 : 1)),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
static get matcher() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user