diffusion
Version:
Diffusion JavaScript client
54 lines (53 loc) • 1.95 kB
JavaScript
;
/**
* @module diffusion.datatypes
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DoubleDataTypeImpl = void 0;
var decoder_1 = require("./../../cbor/decoder");
var primitive_datatype_1 = require("./../../data/primitive/primitive-datatype");
/**
* Serialise an double value into a CBOR encoder
*
* @param value the value to serialise
* @param encoder the encoder
*/ // eslint-disable-next-line @typescript-eslint/ban-types
function serialise(value, encoder) {
if (value === null || value === undefined) {
encoder.encode(null);
}
else {
encoder.writeDouble(value);
}
}
/**
* A data type for double values
*/
var DoubleDataTypeImpl = /** @class */ (function (_super) {
__extends(DoubleDataTypeImpl
// eslint-disable-next-line @typescript-eslint/ban-types
, _super);
/**
* Create a new DoubleDataType instance
*/
function DoubleDataTypeImpl() {
return _super.call(this, 'double', Number, serialise, decoder_1.isDouble, false) || this;
}
return DoubleDataTypeImpl;
}(primitive_datatype_1.PrimitiveDataType));
exports.DoubleDataTypeImpl = DoubleDataTypeImpl;