fast-csv
Version:
CSV parser and writer
34 lines • 1.29 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
class ParserOptions {
constructor(opts) {
this.objectMode = true;
this.delimiter = ',';
this.ignoreEmpty = false;
this.quote = '"';
this.escape = null;
this.escapeChar = this.quote;
this.comment = null;
this.supportsComments = false;
this.ltrim = false;
this.rtrim = false;
this.trim = false;
this.headers = null;
this.renameHeaders = false;
this.strictColumnHandling = false;
this.discardUnmappedColumns = false;
this.carriageReturn = '\r';
this.encoding = 'utf8';
Object.assign(this, opts || {});
if (this.delimiter.length > 1) {
throw new Error('delimiter option must be one character long');
}
this.escapedDelimiter = lodash_1.escapeRegExp(this.delimiter);
this.escapeChar = lodash_1.isString(this.escape) ? this.escape : this.quote;
this.supportsComments = !lodash_1.isNil(this.comment);
this.NEXT_TOKEN_REGEXP = new RegExp(`([^\\s]|\\r\\n|\\n|\\r|${this.escapedDelimiter})`);
}
}
exports.ParserOptions = ParserOptions;
//# sourceMappingURL=ParserOptions.js.map