diff --git a/implementations/javascript/package.json b/implementations/javascript/package.json index 692d070..89e1e40 100644 --- a/implementations/javascript/package.json +++ b/implementations/javascript/package.json @@ -1,6 +1,6 @@ { "name": "preserves", - "version": "0.0.3", + "version": "0.0.4", "description": "Experimental data serialization format", "homepage": "https://gitlab.com/tonyg/preserves", "license": "MIT", diff --git a/implementations/javascript/src/values.js b/implementations/javascript/src/values.js index ff2ca05..b786cf0 100644 --- a/implementations/javascript/src/values.js +++ b/implementations/javascript/src/values.js @@ -73,6 +73,16 @@ Float.prototype.hashCode = function () { return this.value | 0; // TODO: something better? }; +Float.unwrap = function (v) { + if (typeof v === 'number') return v; + if (v instanceof Float) return v.value; + { + const e = new TypeError("Float.unwrap failed"); + e.irritant = v; + throw e; + } +}; + function Single(value) { if (!(this instanceof Single)) return new Single(value); _Float.call(this, value);