Skip to content

Commit

Permalink
Move bitstring serialization to private function
Browse files Browse the repository at this point in the history
  • Loading branch information
bartblast committed Oct 18, 2024
1 parent 537835d commit f61c8df
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions assets/js/serializer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ export default class Serializer {
}

if (value?.type === "bitstring") {
if (Type.isBinary(value)) {
return `__binary__:${Bitstring.toText(value)}`;
}

return {...value, bits: Array.from(value.bits)};
return $.#serializeBoxedBitstring(value);
}

if (value?.type === "float") {
Expand Down Expand Up @@ -59,6 +55,14 @@ export default class Serializer {
return `[1,${serialized}]`;
}

static #serializeBoxedBitstring(term) {
if (Type.isBinary(term)) {
return `__binary__:${Bitstring.toText(term)}`;
}

return {...term, bits: Array.from(term.bits)};
}

static #serializeBoxedReference(term, isFullScope) {
if (isFullScope) {
return term;
Expand Down

0 comments on commit f61c8df

Please sign in to comment.