UNPKG

1.03 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const __1 = require("./..");
4/**
5 * Maps a root description to a device.
6 */
7function mapFromRootDescription(rootDescription) {
8 if (rootDescription.macAddress === undefined) {
9 return null;
10 }
11 return new __1.Device(rootDescription.remoteAddress, parsePortFromPresentationUrl(rootDescription.presentationUrl), rootDescription.macAddress, rootDescription.friendlyName, rootDescription.modelName, rootDescription.modelDescription, rootDescription.modelNumber, rootDescription.presentationUrl);
12}
13exports.mapFromRootDescription = mapFromRootDescription;
14const portFromPresentationUrlRegExp = /:(\d+)\/?$/i;
15function parsePortFromPresentationUrl(presentationUrl) {
16 if (presentationUrl === undefined) {
17 return undefined;
18 }
19 const portMatch = portFromPresentationUrlRegExp.exec(presentationUrl);
20 if (portMatch == null) {
21 return undefined;
22 }
23 return Number(portMatch[1]);
24}
25//# sourceMappingURL=Mappings.js.map
\No newline at end of file