Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
common.js46 linesDownload Raw Back to dist
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.isInSubnet = isInSubnet;
4exports.isCorrect = isCorrect;
5exports.numberToPaddedHex = numberToPaddedHex;
6exports.stringToPaddedHex = stringToPaddedHex;
7exports.testBit = testBit;
8function isInSubnet(address) {
9    if (this.subnetMask < address.subnetMask) {
10        return false;
11    }
12    if (this.mask(address.subnetMask) === address.mask()) {
13        return true;
14    }
15    return false;
16}
17function isCorrect(defaultBits) {
18    return function () {
19        if (this.addressMinusSuffix !== this.correctForm()) {
20            return false;
21        }
22        if (this.subnetMask === defaultBits && !this.parsedSubnet) {
23            return true;
24        }
25        return this.parsedSubnet === String(this.subnetMask);
26    };
27}
28function numberToPaddedHex(number) {
29    return number.toString(16).padStart(2, '0');
30}
31function stringToPaddedHex(numberString) {
32    return numberToPaddedHex(parseInt(numberString, 10));
33}
34/**
35 * @param binaryValue Binary representation of a value (e.g. `10`)
36 * @param position Byte position, where 0 is the least significant bit
37 */
38function testBit(binaryValue, position) {
39    const { length } = binaryValue;
40    if (position > length) {
41        return false;
42    }
43    const positionInString = length - position;
44    return binaryValue.substring(positionInString, positionInString + 1) === '1';
45}
46//# sourceMappingURL=common.js.map
codekingpro/portable-devtools · Team Ai