UNPKG

@iotile/iotile-cloud

Version:

A typescript library for interfacing with the IOTile Cloud API

28 lines 934 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var DeviceGlobalId = /** @class */ (function () { function DeviceGlobalId(id) { this.id = id; } /** * * This class represents a Device ID * It helps converts a device id like 0x20 to a string slug of * the form: * d--XXXX-XXXX-XXXX-XXXX * * The slug always has the hex string in lowercase. * */ DeviceGlobalId.prototype.toString = function () { var hexString = Number(this.id).toString(16); while (hexString.length < 16) { hexString = '0' + hexString; } hexString = hexString.toLowerCase(); return 'd--' + hexString.substr(0, 4) + '-' + hexString.substr(4, 4) + '-' + hexString.substr(8, 4) + '-' + hexString.substr(12, 4); }; return DeviceGlobalId; }()); exports.DeviceGlobalId = DeviceGlobalId; //# sourceMappingURL=gid.js.map