Float.unwrap

This commit is contained in:
Tony Garnock-Jones 2018-11-16 00:10:27 +00:00
parent 80c55e4f30
commit c9484ac9ac
2 changed files with 11 additions and 1 deletions

View File

@ -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",

View File

@ -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);