1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.empty = exports.bit = exports.inRange = exports.objectify = exports.dp = exports.multicastGroup = void 0;
|
4 | function multicastGroup(universe) {
|
5 | if ((universe > 0 && universe <= 63999) || universe === 64214) {
|
6 |
|
7 | return `239.255.${universe >> 8}.${universe & 255}`;
|
8 | }
|
9 | throw new RangeError('universe must be between 1-63999');
|
10 | }
|
11 | exports.multicastGroup = multicastGroup;
|
12 | exports.dp = (n, decimals = 2) => Math.round(n * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
13 | function objectify(buf) {
|
14 | const data = {};
|
15 | buf.forEach((val, ch) => {
|
16 | if (val > 0)
|
17 | data[ch + 1] = exports.dp(val / 2.55, 2);
|
18 | });
|
19 | return data;
|
20 | }
|
21 | exports.objectify = objectify;
|
22 | exports.inRange = (n) => Math.min(255, Math.max(Math.round(n), 0));
|
23 | function bit(bitt, num) {
|
24 |
|
25 |
|
26 | const arr = new ArrayBuffer(bitt / 8);
|
27 |
|
28 | const view = new DataView(arr);
|
29 | view[`setUint${bitt}`](0, num, false);
|
30 | return Array.from(new Uint8Array(arr));
|
31 | }
|
32 | exports.bit = bit;
|
33 | exports.empty = (len) => Array.from(new Uint8Array(new ArrayBuffer(len)));
|