Float.unwrap
This commit is contained in:
parent
80c55e4f30
commit
c9484ac9ac
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "preserves",
|
"name": "preserves",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"description": "Experimental data serialization format",
|
"description": "Experimental data serialization format",
|
||||||
"homepage": "https://gitlab.com/tonyg/preserves",
|
"homepage": "https://gitlab.com/tonyg/preserves",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -73,6 +73,16 @@ Float.prototype.hashCode = function () {
|
||||||
return this.value | 0; // TODO: something better?
|
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) {
|
function Single(value) {
|
||||||
if (!(this instanceof Single)) return new Single(value);
|
if (!(this instanceof Single)) return new Single(value);
|
||||||
_Float.call(this, value);
|
_Float.call(this, value);
|
||||||
|
|
Loading…
Reference in New Issue