UNPKG

apisearch

Version:
70 lines (69 loc) 1.45 kB
"use strict"; exports.__esModule = true; exports.IndexUUID = void 0; var InvalidFormatError_1 = require("../Error/InvalidFormatError"); /** * IndexUUID class */ var IndexUUID = /** @class */ (function () { /** * Constructor * * @param id */ function IndexUUID(id) { if (id.indexOf('_') >= 0) { throw InvalidFormatError_1.InvalidFormatError.indexUUIDFormatNotValid(); } this.id = id; } /** * Create by id * * @param id * * @returns {ItemUUID} */ IndexUUID.createById = function (id) { return new IndexUUID(id); }; /** * Return id * * @returns {string} */ IndexUUID.prototype.getId = function () { return this.id; }; /** * To array * * @returns {{id: *, type: *}} */ IndexUUID.prototype.toArray = function () { return { id: this.id }; }; /** * Create from array * * @param array {{id:string, type:string}} * * @return {ItemUUID} */ IndexUUID.createFromArray = function (array) { array = JSON.parse(JSON.stringify(array)); return new IndexUUID(array.id); }; /** * Compose unique id * * @returns {string} */ IndexUUID.prototype.composedUUID = function () { return this.id; }; return IndexUUID; }()); exports.IndexUUID = IndexUUID;