Skip to content

Commit 0cfa7f9

Browse files
committed
Fix bit array inspect bug
1 parent e42437c commit 0cfa7f9

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/gleam_stdlib.mjs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,6 @@ export function to_string(term) {
4444
return term.toString();
4545
}
4646

47-
export function float_to_string(float) {
48-
const string = float.toString().replace("+", "");
49-
if (string.indexOf(".") >= 0) {
50-
return string;
51-
} else {
52-
const index = string.indexOf("e");
53-
if (index >= 0) {
54-
return string.slice(0, index) + ".0" + string.slice(index);
55-
} else {
56-
return string + ".0";
57-
}
58-
}
59-
}
60-
6147
export function int_to_base_string(int, base) {
6248
return int.toString(base).toUpperCase();
6349
}
@@ -673,6 +659,20 @@ export function inspect(v) {
673659
return new Inspector().inspect(v);
674660
}
675661

662+
export function float_to_string(float) {
663+
const string = float.toString().replace("+", "");
664+
if (string.indexOf(".") >= 0) {
665+
return string;
666+
} else {
667+
const index = string.indexOf("e");
668+
if (index >= 0) {
669+
return string.slice(0, index) + ".0" + string.slice(index);
670+
} else {
671+
return string + ".0";
672+
}
673+
}
674+
}
675+
676676
class Inspector {
677677
#references = new Set();
678678

@@ -822,11 +822,12 @@ class Inspector {
822822
}
823823

824824
#bit_array(bits) {
825-
let acc = "<<";
826825
if (bits.bitSize === 0) {
827-
return acc;
826+
return "<<>>";
828827
}
829828

829+
let acc = "<<";
830+
830831
for (let i = 0; i < bits.byteSize - 1; i++) {
831832
acc += bits.byteAt(i).toString();
832833
acc += ", ";

0 commit comments

Comments
 (0)