UNPKG

diffusion

Version:

Diffusion JavaScript client

52 lines (51 loc) 1.87 kB
"use strict"; /** * @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.StringDataTypeImpl = void 0; var decoder_1 = require("./../../cbor/decoder"); var primitive_datatype_1 = require("./../../data/primitive/primitive-datatype"); /** * Serialise a string value into a CBOR encoder * * @param value the value to serialise * @param encoder the encoder */ function serialise(v, encoder) { if (v === null || v === undefined) { encoder.encode(null); } else { encoder.encode(v.toString()); } } /** * A data type for string values */ // eslint-disable-next-line @typescript-eslint/ban-types var StringDataTypeImpl = /** @class */ (function (_super) { __extends(StringDataTypeImpl, _super); /** * Create a new StringDataTypeImpl instance */ function StringDataTypeImpl() { return _super.call(this, 'string', String, serialise, decoder_1.isString, true) || this; } return StringDataTypeImpl; }(primitive_datatype_1.PrimitiveDataType)); exports.StringDataTypeImpl = StringDataTypeImpl;