27 lines
2.7 KiB
JavaScript
27 lines
2.7 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
//return first eol found from a data chunk.
|
||
|
function default_1(data, param) {
|
||
|
if (!param.eol && data) {
|
||
|
for (var i = 0, len = data.length; i < len; i++) {
|
||
|
if (data[i] === "\r") {
|
||
|
if (data[i + 1] === "\n") {
|
||
|
param.eol = "\r\n";
|
||
|
break;
|
||
|
}
|
||
|
else if (data[i + 1]) {
|
||
|
param.eol = "\r";
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (data[i] === "\n") {
|
||
|
param.eol = "\n";
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return param.eol || "\n";
|
||
|
}
|
||
|
exports.default = default_1;
|
||
|
;
|
||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiL1VzZXJzL2t4aWFuZy93b3JrL3Byb2plY3RzL2NzdjJqc29uL3NyYy9nZXRFb2wudHMiLCJzb3VyY2VzIjpbIi9Vc2Vycy9reGlhbmcvd29yay9wcm9qZWN0cy9jc3YyanNvbi9zcmMvZ2V0RW9sLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ0EsMkNBQTJDO0FBQzNDLG1CQUF5QixJQUFZLEVBQUUsS0FBbUI7SUFDeEQsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLElBQUksSUFBSSxFQUFFO1FBQ3RCLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLEdBQUcsR0FBRyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsR0FBRyxHQUFHLEVBQUUsQ0FBQyxFQUFFLEVBQUU7WUFDL0MsSUFBSSxJQUFJLENBQUMsQ0FBQyxDQUFDLEtBQUssSUFBSSxFQUFFO2dCQUNwQixJQUFJLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLE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