HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/www/french-american.org/current/node_modules/snyk-paket-parser/dist/line-parser.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Line = /** @class */ (function () {
    function Line(data, indentation) {
        this.data = data;
        this.indentation = indentation;
    }
    return Line;
}());
exports.Line = Line;
function countIndents(line, indent) {
    var spaces = line.match(/^\s*/)[0].length;
    var count = spaces / indent.length;
    if (count % 1 !== 0) {
        throw new Error('Line indentation malformed');
    }
    return count;
}
// On windows machines first symbol of the file sometimes is special
// "ZERO WIDTH NO-BREAK SPACE". Remove it before continue processing because it
// could be counted as a space in `countIndents`.
//
// - https://en.wikipedia.org/wiki/Byte_order_mark
// - https://stackoverflow.com/questions/6784799/what-is-this-char-65279
function removeByteOrderMark(input) {
    if (input.length > 0 && input.charAt(0) === '\uFEFF') {
        return input.substr(1);
    }
    return input;
}
// parse space indented lines into array of Lines
function parseLines(input, indent /* two spaces */, lineSeparator) {
    if (indent === void 0) { indent = '  '; }
    if (lineSeparator === void 0) { lineSeparator = /\r?\n/; }
    var e_1, _a;
    var lines = removeByteOrderMark(input).split(lineSeparator);
    var result = [];
    try {
        for (var lines_1 = tslib_1.__values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
            var line = lines_1_1.value;
            var data = line.trim();
            if (data === '') { // GROUPS often separated by blank lines
                continue;
            }
            var indentation = countIndents(line, indent);
            result.push(new Line(data, indentation));
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
        }
        finally { if (e_1) throw e_1.error; }
    }
    return result;
}
exports.parseLines = parseLines;
//# sourceMappingURL=line-parser.js.map