Skip to content

Commit

Permalink
fix(src/serialism.ts): Don't handle encoded meta array as an object.
Browse files Browse the repository at this point in the history
  • Loading branch information
voodooattack committed Nov 24, 2018
1 parent cba5b2d commit 787c236
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/serialism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,26 @@ export class Serialism {
return result;
}

let encoded: any = Object.assign({}, value);
let encoded: any;
const type = this.classes.find(t => value.constructor === t);
if (type) {
encoded = ['@serialism:type', type.name, Object.entries(value)];
}
known.set(value, encoded);
for (const [key, val] of Object.entries(encoded)) {
encoded[key] = this.entomb(val, known);
}
encoded = ['@serialism:type', type.name, null];
known.set(value, encoded);
encoded[2] = Object.entries(value).map(
([key, val]) => [key, this.entomb(val, known)]
);
} else {
encoded = Object.assign({}, value);
known.set(value, encoded);
for (const [key, val] of Object.entries(encoded)) {
encoded[key] = this.entomb(val, known);
}

for (const sym of Object.getOwnPropertySymbols(value)) {
const key = Symbol.keyFor(sym);
if (key) {
encoded[`@serialism:sym:${key}`] = this.entomb(value[sym], known);
for (const sym of Object.getOwnPropertySymbols(value)) {
const key = Symbol.keyFor(sym);
if (key) {
encoded[`@serialism:sym:${key}`] = this.entomb(value[sym], known);
}
}
}

Expand Down

0 comments on commit 787c236

Please sign in to comment.