summaryrefslogtreecommitdiff
path: root/js-runtime
diff options
context:
space:
mode:
Diffstat (limited to 'js-runtime')
-rw-r--r--js-runtime/reflect.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/js-runtime/reflect.js b/js-runtime/reflect.js
index b7d88f3..5ee2928 100644
--- a/js-runtime/reflect.js
+++ b/js-runtime/reflect.js
@@ -20,7 +20,8 @@ class Complex {
this.imag = imag;
}
toString() {
- return `${flonum_to_string(this.real)}+${flonum_to_string(this.imag)}i`;
+ const sign = this.imag >= 0 && Number.isFinite(this.imag) ? "+": "";
+ return `${flonum_to_string(this.real)}${sign}${flonum_to_string(this.imag)}i`;
}
}
class Fraction {
@@ -440,9 +441,9 @@ class SchemeModule {
string_downcase: Function.call.bind(String.prototype.toLowerCase),
make_weak_map() { return new WeakMap; },
- weak_map_get(map, k) {
+ weak_map_get(map, k, fail) {
const val = map.get(k);
- return val === undefined ? null: val;
+ return val === undefined ? fail: val;
},
weak_map_set(map, k, v) { return map.set(k, v); },
weak_map_delete(map, k) { return map.delete(k); },