Commit f9b658b6 by 蒋勇

d

parent e276ad43

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -9,10 +9,10 @@ from DBUtils.PooledDB import PooledDB
import pymysql
MYSQL_HOST = 'rm-2zexiblg7bi3hs165.mysql.rds.aliyuncs.com' # 外网地址
MYSQL_HOST = 'rm-2zey194899z131ouf.mysql.rds.aliyuncs.com' # 外网地址
PORT = 3306 # 外网端口
USER = 'bp'
PASSWORD = 'M0TaGe4f3kNnXanO%r'
USER = 'root'
PASSWORD = 'Gongsibao2018'
DB = 'ent_data'
pool = PooledDB(pymysql, 8, host=MYSQL_HOST, user=USER, passwd=PASSWORD, db=DB, port=PORT)
......
[database]
dbhost=rm-2zexiblg7bi3hs165.mysql.rds.aliyuncs.com
dbhost=rm-2zey194899z131ouf.mysql.rds.aliyuncs.com
dbport=3306
dbname=ent_data
dbuser=bp
dbpassword=M0TaGe4f3kNnXanO%r
dbuser=root
dbpassword=Gongsibao2018
dbcharset=utf8
......
......@@ -4,10 +4,10 @@ from DBUtils.PooledDB import PooledDB
from common.crm_change_standard import getStandardName
MYSQL_HOST = 'rm-2zexiblg7bi3hs165.mysql.rds.aliyuncs.com' # 外网地址
MYSQL_HOST = 'rm-2zey194899z131ouf.mysql.rds.aliyuncs.com' # 外网地址
PORT = 3306 # 外网端口
USER = 'bp'
PASSWORD = 'M0TaGe4f3kNnXanO%r'
USER = 'root'
PASSWORD = 'Gongsibao2018'
DB = 'ent_data'
pool = PooledDB(pymysql,8, host=MYSQL_HOST, user=USER, passwd=PASSWORD, db=DB, port=PORT)
......
......@@ -2,10 +2,10 @@ from DBUtils.PooledDB import PooledDB
import pymysql,json
from flask import request
MYSQL_HOST = 'rm-2zexiblg7bi3hs165.mysql.rds.aliyuncs.com' # 外网地址
MYSQL_HOST = 'rm-2zey194899z131ouf.mysql.rds.aliyuncs.com' # 外网地址
PORT = 3306 # 外网端口
USER = 'bp'
PASSWORD = 'M0TaGe4f3kNnXanO%r'
USER = 'root'
PASSWORD = 'Gongsibao2018'
DB = 'ent_data'
pool = PooledDB(pymysql, 8, host=MYSQL_HOST, user=USER, passwd=PASSWORD, db=DB, port=PORT)
......
......@@ -11,10 +11,10 @@ import json
"""读取tj_hx_type_connect表,获取大类"""
"""返回格式:["基本标签", "产品标签", "风险标签", "经营标签", "偏好标签"]"""
MYSQL_HOST = 'rm-2zexiblg7bi3hs165.mysql.rds.aliyuncs.com' # 外网地址
MYSQL_HOST = 'rm-2zey194899z131ouf.mysql.rds.aliyuncs.com' # 外网地址
PORT = 3306 # 外网端口
USER = 'bp'
PASSWORD = 'M0TaGe4f3kNnXanO%r'
USER = 'root'
PASSWORD = 'Gongsibao2018'
DB = 'ent_data'
pool = PooledDB(pymysql, 8, host=MYSQL_HOST, user=USER, passwd=PASSWORD, db=DB, port=PORT)
......
../_marked@0.7.0@marked/bin/marked
\ No newline at end of file
../_@alicloud_pop-core@1.7.10@@alicloud/pop-core
\ No newline at end of file
../_@fast-csv_format@4.3.5@@fast-csv/format
\ No newline at end of file
../_@fast-csv_parse@4.3.6@@fast-csv/parse
\ No newline at end of file
../_@mapbox_node-pre-gyp@1.0.5@@mapbox/node-pre-gyp
\ No newline at end of file
../_@tootallnate_once@1.1.2@@tootallnate/once
\ No newline at end of file
../_@types_bson@4.0.3@@types/bson
\ No newline at end of file
../_@types_mongodb@3.6.12@@types/mongodb
\ No newline at end of file
## 1.0.2 (2017-01-16)
Feature:
- 返回出错的结果,挂载到返回error的data对象上,err.data = resData
\ No newline at end of file
# @alicloud/pop-core
The core SDK of POP API.
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![codecov][cov-image]][cov-url]
[npm-image]: https://img.shields.io/npm/v/@alicloud/pop-core.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@alicloud/pop-core
[travis-image]: https://img.shields.io/travis/aliyun/openapi-core-nodejs-sdk/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/aliyun/openapi-core-nodejs-sdk
[cov-image]: https://codecov.io/gh/aliyun/openapi-core-nodejs-sdk/branch/master/graph/badge.svg
[cov-url]: https://codecov.io/gh/aliyun/openapi-core-nodejs-sdk
## Installation
Install it and write into package.json dependences.
```sh
$ npm install @alicloud/pop-core -S
```
## Prerequisite
Node.js >= 8.x
### Notes
You must know your `AK`(`accessKeyId/accessKeySecret`), and the cloud product's `endpoint` and `apiVersion`.
For example, The ECS OpenAPI(https://help.aliyun.com/document_detail/25490.html), the API version is `2014-05-26`.
And the endpoint list can be found at [here](https://help.aliyun.com/document_detail/25489.html), the center endpoint is ecs.aliyuncs.com. Add http protocol `http` or `https`, should be `http://ecs.aliyuncs.com/`.
## Online Demo
**[API Explorer](https://api.aliyun.com)** provides the ability to call the cloud product OpenAPI online, and dynamically generate SDK Example code and quick retrieval interface, which can significantly reduce the difficulty of using the cloud API. **It is highly recommended**.
<a href="https://api.aliyun.com" target="api_explorer">
<img src="https://img.alicdn.com/tfs/TB12GX6zW6qK1RjSZFmXXX0PFXa-744-122.png" width="180" />
</a>
## Usage
The RPC style client:
```js
var RPCClient = require('@alicloud/pop-core').RPCClient;
var client = new RPCClient({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
endpoint: '<endpoint>',
apiVersion: '<apiVersion>'
});
// => returns Promise
client.request(action, params);
// co/yield, async/await
// options
client.request(action, params, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'GET', // set the http method, default is GET
headers: {}, // set the http request headers
});
```
The ROA style client:
```js
var ROAClient = require('@alicloud/pop-core').ROAClient;
var client = new ROAClient({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<secretAccessKey>',
endpoint: '<endpoint>',
apiVersion: '<apiVersion>'
});
// => returns Promise
// request(HTTPMethod, uriPath, queries, body, headers, options);
// options => {timeout}
client.request('GET', '/regions');
// co/yield, async/await
```
### Custom opts
We offer two ways to customize request opts.
One way is passing opts through the Client constructor. You should treat opts passed through the constructor as default custom opts, because all requests will use this opts.
```js
var client = new RPCClient({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
endpoint: '<endpoint>',
apiVersion: '<apiVersion>',
opts: {
timeout: 3000
}
});
```
Another way is passing opts through the function's parameter. You should use this way when you want to just pass opts in specific functions.
```js
client.request(action, params, {
timeout: 3000
});
```
When both ways are used, opts will be merged. But for the opt with the same key, the opts provided by the function parameter overrides the opts provided by the constructor.
### Http Proxy Support
```js
var tunnel = require('tunnel-agent');
var RPCClient = require('@alicloud/pop-core').RPCClient;
var client = new RPCClient({
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
endpoint: '<endpoint>',
apiVersion: '<apiVersion>'
});
client.request(action, params, {
agent: tunnel.httpOverHttp({
proxy: {
host: 'host',
port: port
}
});
});
```
## License
The MIT License
'use strict';
module.exports = require('./lib/rpc');
module.exports.ROAClient = require('./lib/roa');
module.exports.RPCClient = require('./lib/rpc');
'use strict';
const os = require('os');
const pkg = require('../package.json');
exports.DEFAULT_UA = `AlibabaCloud (${os.platform()}; ${os.arch()}) ` +
`Node.js/${process.version} Core/${pkg.version}`;
exports.DEFAULT_CLIENT = `Node.js(${process.version}), ${pkg.name}: ${pkg.version}`;
'use strict';
const assert = require('assert');
const url = require('url');
const querystring = require('querystring');
const kitx = require('kitx');
const httpx = require('httpx');
const xml2js = require('xml2js');
const JSON = require('json-bigint');
const debug = require('debug')('roa');
const helper = require('./helper');
function filter(value) {
return value.replace(/[\t\n\r\f]/g, ' ');
}
function keyLowerify(headers) {
const keys = Object.keys(headers);
const newHeaders = {};
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
newHeaders[key.toLowerCase()] = headers[key];
}
return newHeaders;
}
function getCanonicalizedHeaders(headers) {
const prefix = 'x-acs-';
const keys = Object.keys(headers);
const canonicalizedKeys = [];
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (key.startsWith(prefix)) {
canonicalizedKeys.push(key);
}
}
canonicalizedKeys.sort();
var result = '';
for (let i = 0; i < canonicalizedKeys.length; i++) {
const key = canonicalizedKeys[i];
result += `${key}:${filter(headers[key]).trim()}\n`;
}
return result;
}
function getCanonicalizedResource(uriPattern, query) {
const keys = Object.keys(query).sort();
if (keys.length === 0) {
return uriPattern;
}
var result = [];
for (var i = 0; i < keys.length; i++) {
const key = keys[i];
result.push(`${key}=${query[key]}`);
}
return `${uriPattern}?${result.join('&')}`;
}
function buildStringToSign(method, uriPattern, headers, query) {
const accept = headers['accept'];
const contentMD5 = headers['content-md5'] || '';
const contentType = headers['content-type'] || '';
const date = headers['date'] || '';
const header = `${method}\n${accept}\n${contentMD5}\n${contentType}\n${date}\n`;
const canonicalizedHeaders = getCanonicalizedHeaders(headers);
const canonicalizedResource = getCanonicalizedResource(uriPattern, query);
return `${header}${canonicalizedHeaders}${canonicalizedResource}`;
}
function parseXML(xml) {
const parser = new xml2js.Parser({
// explicitArray: false
});
return new Promise((resolve, reject) => {
parser.parseString(xml, (err, result) => {
if (err) {
return reject(err);
}
resolve(result);
});
});
}
class ACSError extends Error {
constructor(err) {
const message = err.Message[0];
const code = err.Code[0];
const hostid = err.HostId[0];
const requestid = err.RequestId[0];
super(`${message} hostid: ${hostid}, requestid: ${requestid}`);
this.code = code;
}
}
class ROAClient {
constructor(config) {
assert(config, 'must pass "config"');
assert(config.endpoint, 'must pass "config.endpoint"');
if (!config.endpoint.startsWith('https://') &&
!config.endpoint.startsWith('http://')) {
throw new Error(`"config.endpoint" must starts with 'https://' or 'http://'.`);
}
assert(config.apiVersion, 'must pass "config.apiVersion"');
assert(config.accessKeyId, 'must pass "config.accessKeyId"');
assert(config.accessKeySecret, 'must pass "config.accessKeySecret"');
this.endpoint = config.endpoint;
this.apiVersion = config.apiVersion;
this.accessKeyId = config.accessKeyId;
this.accessKeySecret = config.accessKeySecret;
this.securityToken = config.securityToken;
this.host = url.parse(this.endpoint).hostname;
this.opts = config.opts;
var httpModule = this.endpoint.startsWith('https://') ? require('https') : require('http');
this.keepAliveAgent = new httpModule.Agent({
keepAlive: true,
keepAliveMsecs: 3000
});
}
buildHeaders() {
const now = new Date();
var defaultHeaders = {
accept: 'application/json',
date: now.toGMTString(),
host: this.host,
'x-acs-signature-nonce': kitx.makeNonce(),
'x-acs-signature-method': 'HMAC-SHA1',
'x-acs-signature-version': '1.0',
'x-acs-version': this.apiVersion,
'user-agent': helper.DEFAULT_UA,
'x-sdk-client': helper.DEFAULT_CLIENT
};
if (this.securityToken) {
defaultHeaders['x-acs-accesskey-id'] = this.accessKeyId;
defaultHeaders['x-acs-security-token'] = this.securityToken;
}
return defaultHeaders;
}
signature(stringToSign) {
const utf8Buff = Buffer.from(stringToSign, 'utf8');
return kitx.sha1(utf8Buff, this.accessKeySecret, 'base64');
}
buildAuthorization(stringToSign) {
return `acs ${this.accessKeyId}:${this.signature(stringToSign)}`;
}
request(method, uriPattern, query = {}, body = '', headers = {}, opts = {}) {
var postBody = null;
var mixHeaders = Object.assign(this.buildHeaders(), keyLowerify(headers));
postBody = Buffer.from(body, 'utf8');
mixHeaders['content-md5'] = kitx.md5(postBody, 'base64');
mixHeaders['content-length'] = postBody.length;
var url = `${this.endpoint}${uriPattern}`;
if (Object.keys(query).length) {
url += `?${querystring.stringify(query)}`;
}
const stringToSign = buildStringToSign(method, uriPattern, mixHeaders, query);
debug('stringToSign: %s', stringToSign);
mixHeaders['authorization'] = this.buildAuthorization(stringToSign);
const options = Object.assign({
method,
agent: this.keepAliveAgent,
headers: mixHeaders,
data: postBody
}, this.opts, opts);
return httpx.request(url, options).then((response) => {
return httpx.read(response, 'utf8').then((body) => {
// Retrun raw body
if (opts.rawBody) {
return body;
}
const contentType = response.headers['content-type'] || '';
// JSON
if (contentType.startsWith('application/json')) {
const statusCode = response.statusCode;
if (statusCode === 204) {
return body;
}
var result;
try {
result = JSON.parse(body);
} catch (err) {
err.name = 'FormatError';
err.message = 'parse response to json error';
err.body = body;
throw err;
}
if (statusCode >= 400) {
const errorMessage = result.Message || result.errorMsg || '';
const errorCode = result.Code || result.errorCode || '';
const requestId = result.RequestId || '';
var err = new Error(`code: ${statusCode}, ${errorMessage}, requestid: ${requestId}`);
err.name = `${errorCode}Error`;
err.statusCode = statusCode;
err.result = result;
err.code = errorCode;
throw err;
}
return result;
}
if (contentType.startsWith('text/xml')) {
return parseXML(body).then((result) => {
if (result.Error) {
throw new ACSError(result.Error);
}
return result;
});
}
return body;
});
});
}
put(path, query, body, headers, options) {
return this.request('PUT', path, query, body, headers, options);
}
post(path, query, body, headers, options) {
return this.request('POST', path, query, body, headers, options);
}
get(path, query, headers, options) {
return this.request('GET', path, query, '', headers, options);
}
delete(path, query, headers, options) {
return this.request('DELETE', path, query, '', headers, options);
}
}
module.exports = ROAClient;
// Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
// Project: [~THE PROJECT NAME~]
// Definitions by: [~YOUR NAME~] <[~A URL FOR YOU~]>
/*~ This is the module template file for class modules.
*~ You should rename it to index.d.ts and place it in a folder with the same name as the module.
*~ For example, if you were writing a file for "super-greeter", this
*~ file should be 'super-greeter/index.d.ts'
*/
/*~ Note that ES6 modules cannot directly export class objects.
*~ This file should be imported using the CommonJS-style:
*~ import x = require('someLibrary');
*~
*~ Refer to the documentation to understand common
*~ workarounds for this limitation of ES6 modules.
*/
/*~ This declaration specifies that the class constructor function
*~ is the exported object from the file
*/
export = RPCClient;
/*~ Write your module's methods and properties in this class */
declare class RPCClient {
constructor(config: RPCClient.Config);
request<T>(action: String, params: Object, options?: Object): Promise<T>;
}
/*~ If you want to expose types from your module as well, you can
*~ place them in this block.
*/
declare namespace RPCClient {
export interface Config {
endpoint: string;
apiVersion: string;
accessKeyId: string;
accessKeySecret: string;
codes?: (string | number)[];
opts?: object;
}
}
'use strict';
const assert = require('assert');
const httpx = require('httpx');
const kitx = require('kitx');
const JSON = require('json-bigint');
const helper = require('./helper');
function firstLetterUpper(str) {
return str.slice(0, 1).toUpperCase() + str.slice(1);
}
function formatParams(params) {
var keys = Object.keys(params);
var newParams = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
newParams[firstLetterUpper(key)] = params[key];
}
return newParams;
}
function timestamp() {
var date = new Date();
var YYYY = date.getUTCFullYear();
var MM = kitx.pad2(date.getUTCMonth() + 1);
var DD = kitx.pad2(date.getUTCDate());
var HH = kitx.pad2(date.getUTCHours());
var mm = kitx.pad2(date.getUTCMinutes());
var ss = kitx.pad2(date.getUTCSeconds());
// 删除掉毫秒部分
return `${YYYY}-${MM}-${DD}T${HH}:${mm}:${ss}Z`;
}
function encode(str) {
var result = encodeURIComponent(str);
return result.replace(/!/g, '%21')
.replace(/'/g, '%27')
.replace(/\(/g, '%28')
.replace(/\)/g, '%29')
.replace(/\*/g, '%2A');
}
function replaceRepeatList(target, key, repeat) {
for (var i = 0; i < repeat.length; i++) {
var item = repeat[i];
if (item && typeof item === 'object') {
const keys = Object.keys(item);
for (var j = 0; j < keys.length; j++) {
target[`${key}.${i + 1}.${keys[j]}`] = item[keys[j]];
}
} else {
target[`${key}.${i + 1}`] = item;
}
}
}
function flatParams(params) {
var target = {};
var keys = Object.keys(params);
for (let i = 0; i < keys.length; i++) {
var key = keys[i];
var value = params[key];
if (Array.isArray(value)) {
replaceRepeatList(target, key, value);
} else {
target[key] = value;
}
}
return target;
}
function normalize(params) {
var list = [];
var flated = flatParams(params);
var keys = Object.keys(flated).sort();
for (let i = 0; i < keys.length; i++) {
var key = keys[i];
var value = flated[key];
list.push([encode(key), encode(value)]); //push []
}
return list;
}
function canonicalize(normalized) {
var fields = [];
for (var i = 0; i < normalized.length; i++) {
var [key, value] = normalized[i];
fields.push(key + '=' + value);
}
return fields.join('&');
}
class RPCClient {
constructor(config, verbose) {
assert(config, 'must pass "config"');
assert(config.endpoint, 'must pass "config.endpoint"');
if (!config.endpoint.startsWith('https://') &&
!config.endpoint.startsWith('http://')) {
throw new Error(`"config.endpoint" must starts with 'https://' or 'http://'.`);
}
assert(config.apiVersion, 'must pass "config.apiVersion"');
assert(config.accessKeyId, 'must pass "config.accessKeyId"');
var accessKeySecret = config.secretAccessKey || config.accessKeySecret;
assert(accessKeySecret, 'must pass "config.accessKeySecret"');
if (config.endpoint.endsWith('/')) {
config.endpoint = config.endpoint.slice(0, -1);
}
this.endpoint = config.endpoint;
this.apiVersion = config.apiVersion;
this.accessKeyId = config.accessKeyId;
this.accessKeySecret = accessKeySecret;
this.securityToken = config.securityToken;
this.verbose = verbose === true;
// 非 codes 里的值,将抛出异常
this.codes = new Set([200, '200', 'OK', 'Success']);
if (config.codes) {
// 合并 codes
for (var elem of config.codes) {
this.codes.add(elem);
}
}
this.opts = config.opts || {};
var httpModule = this.endpoint.startsWith('https://')
? require('https') : require('http');
this.keepAliveAgent = new httpModule.Agent({
keepAlive: true,
keepAliveMsecs: 3000
});
}
request(action, params = {}, opts = {}) {
// 1. compose params and opts
opts = Object.assign({
headers: {
'x-sdk-client': helper.DEFAULT_CLIENT,
'user-agent': helper.DEFAULT_UA,
'x-acs-action': action,
'x-acs-version': this.apiVersion
}
}, this.opts, opts);
// format action until formatAction is false
if (opts.formatAction !== false) {
action = firstLetterUpper(action);
}
// format params until formatParams is false
if (opts.formatParams !== false) {
params = formatParams(params);
}
var defaults = this._buildParams();
params = Object.assign({Action: action}, defaults, params);
// 2. caculate signature
var method = (opts.method || 'GET').toUpperCase();
var normalized = normalize(params);
var canonicalized = canonicalize(normalized);
// 2.1 get string to sign
var stringToSign = `${method}&${encode('/')}&${encode(canonicalized)}`;
// 2.2 get signature
const key = this.accessKeySecret + '&';
var signature = kitx.sha1(stringToSign, key, 'base64');
// add signature
normalized.push(['Signature', encode(signature)]);
// 3. generate final url
const url = opts.method === 'POST' ? `${this.endpoint}/` : `${this.endpoint}/?${canonicalize(normalized)}`;
// 4. send request
var entry = {
url: url,
request: null,
response: null
};
if (opts && !opts.agent) {
opts.agent = this.keepAliveAgent;
}
if (opts.method === 'POST') {
opts.headers = opts.headers || {};
opts.headers['content-type'] = 'application/x-www-form-urlencoded';
opts.data = canonicalize(normalized);
}
return httpx.request(url, opts).then((response) => {
entry.request = {
headers: response.req.getHeaders ? response.req.getHeaders() : response.req._headers
};
entry.response = {
statusCode: response.statusCode,
headers: response.headers
};
return httpx.read(response);
}).then((buffer) => {
var json = JSON.parse(buffer);
if (json.Code && !this.codes.has(json.Code)) {
var err = new Error(`${json.Message}, URL: ${url}`);
err.name = json.Code + 'Error';
err.data = json;
err.code = json.Code;
err.url = url;
err.entry = entry;
return Promise.reject(err);
}
if (this.verbose) {
return [json, entry];
}
return json;
});
}
_buildParams() {
var defaultParams = {
Format: 'JSON',
SignatureMethod: 'HMAC-SHA1',
SignatureNonce: kitx.makeNonce(),
SignatureVersion: '1.0',
Timestamp: timestamp(),
AccessKeyId: this.accessKeyId,
Version: this.apiVersion,
};
if (this.securityToken) {
defaultParams.SecurityToken = this.securityToken;
}
return defaultParams;
}
}
module.exports = RPCClient;
../../../_json-bigint@1.0.0@json-bigint
\ No newline at end of file
{
"name": "@alicloud/pop-core",
"version": "1.7.10",
"description": "AliCloud POP SDK core",
"main": "index.js",
"types": "lib/rpc.d.ts",
"scripts": {
"lint": "eslint --fix lib test",
"test": "mocha -R spec test/*.test.js",
"test-cov": "nyc -r=html -r=text -r=lcov mocha -t 3000 -R spec test/*.test.js",
"test-integration": "mocha -R spec test/*.integration.js",
"ci": "npm run lint && npm run test-cov && codecov"
},
"keywords": [
"Aliyun",
"AliCloud",
"OpenAPI",
"POP",
"SDK",
"Core"
],
"author": "Jackson Tian",
"license": "MIT",
"dependencies": {
"debug": "^3.1.0",
"httpx": "^2.1.2",
"json-bigint": "^1.0.0",
"kitx": "^1.2.1",
"xml2js": "^0.4.17"
},
"files": [
"lib",
"index.js"
],
"devDependencies": {
"codecov": "^3.0.4",
"eslint": "^6.6.0",
"expect.js": "^0.3.1",
"mocha": "^4",
"muk": "^0.5.3",
"nyc": "^12.0.2",
"rewire": "^4.0.1"
},
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aliyun/openapi-core-nodejs-sdk.git"
},
"bugs": {
"url": "https://github.com/aliyun/openapi-core-nodejs-sdk/issues"
},
"homepage": "https://github.com/aliyun/openapi-core-nodejs-sdk#readme",
"__npminstall_done": "Tue May 18 2021 15:21:41 GMT+0800 (GMT+08:00)",
"_from": "@alicloud/pop-core@1.7.10",
"_resolved": "https://registry.npm.taobao.org/@alicloud/pop-core/download/@alicloud/pop-core-1.7.10.tgz"
}
\ No newline at end of file
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [4.3.5](https://github.com/C2FO/fast-csv/compare/v4.3.4...v4.3.5) (2020-11-03)
### Bug Fixes
* **formatting,#446:** Do not quote fields that do not contain a quote ([13e688c](https://github.com/C2FO/fast-csv/commit/13e688cb38dcb67c7182211968c794146be54692)), closes [#446](https://github.com/C2FO/fast-csv/issues/446)
## [4.3.4](https://github.com/C2FO/fast-csv/compare/v4.3.3...v4.3.4) (2020-11-03)
### Bug Fixes
* **formatter,#503:** Do not ignore rows when headers is false ([1560564](https://github.com/C2FO/fast-csv/commit/1560564819c8b1254ca4ad43487830a4296570f6)), closes [#503](https://github.com/C2FO/fast-csv/issues/503)
## [4.3.3](https://github.com/C2FO/fast-csv/compare/v4.3.2...v4.3.3) (2020-10-30)
**Note:** Version bump only for package @fast-csv/format
## [4.3.1](https://github.com/C2FO/fast-csv/compare/v4.3.0...v4.3.1) (2020-06-23)
**Note:** Version bump only for package @fast-csv/format
# [4.3.0](https://github.com/C2FO/fast-csv/compare/v4.2.0...v4.3.0) (2020-05-27)
**Note:** Version bump only for package @fast-csv/format
# [4.2.0](https://github.com/C2FO/fast-csv/compare/v4.1.6...v4.2.0) (2020-05-19)
### Features
* **parsing:** Less restrictive row parsing type [#356](https://github.com/C2FO/fast-csv/issues/356) ([87d74ec](https://github.com/C2FO/fast-csv/commit/87d74ecd2cb16f3700b1942ebbbec221afe38790))
## [4.1.5](https://github.com/C2FO/fast-csv/compare/v4.1.4...v4.1.5) (2020-05-15)
**Note:** Version bump only for package @fast-csv/format
## [4.1.4](https://github.com/C2FO/fast-csv/compare/v4.1.3...v4.1.4) (2020-05-15)
**Note:** Version bump only for package @fast-csv/format
The MIT License
Copyright (c) 2011-2019 C2FO
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
<p align="center">
<a href="https://c2fo.io/fast-csv" target="blank"><img src="https://c2fo.io/fast-csv/img/logo.svg" width="200" alt="fast-csv Logo" /></a>
</p>
[![npm version](https://img.shields.io/npm/v/@fast-csv/format.svg)](https://www.npmjs.org/package/@fast-csv/format)
[![Build Status](https://travis-ci.org/C2FO/fast-csv.svg?branch=master)](https://travis-ci.org/C2FO/fast-csv)
[![Coverage Status](https://coveralls.io/repos/github/C2FO/fast-csv/badge.svg?branch=master)](https://coveralls.io/github/C2FO/fast-csv?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/C2FO/fast-csv/badge.svg?targetFile=packages/format/package.json)](https://snyk.io/test/github/C2FO/fast-csv?targetFile=packages/format/package.json)
# `@fast-csv/format`
`fast-csv` package to format CSVs.
## Installation
[Install Guide](https://c2fo.io/fast-csv/docs/introduction/install)
## Usage
To get started with `@fast-csv/format` [check out the docs](https://c2fo.io/fast-csv/docs/formatting/getting-started)
/// <reference types="node" />
import { Transform, TransformCallback } from 'stream';
import { FormatterOptions } from './FormatterOptions';
import { Row, RowTransformFunction } from './types';
export declare class CsvFormatterStream<I extends Row, O extends Row> extends Transform {
private formatterOptions;
private rowFormatter;
private hasWrittenBOM;
constructor(formatterOptions: FormatterOptions<I, O>);
transform(transformFunction: RowTransformFunction<I, O>): CsvFormatterStream<I, O>;
_transform(row: I, encoding: string, cb: TransformCallback): void;
_flush(cb: TransformCallback): void;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CsvFormatterStream = void 0;
const stream_1 = require("stream");
const formatter_1 = require("./formatter");
class CsvFormatterStream extends stream_1.Transform {
constructor(formatterOptions) {
super({ writableObjectMode: formatterOptions.objectMode });
this.hasWrittenBOM = false;
this.formatterOptions = formatterOptions;
this.rowFormatter = new formatter_1.RowFormatter(formatterOptions);
// if writeBOM is false then set to true
// if writeBOM is true then set to false by default so it is written out
this.hasWrittenBOM = !formatterOptions.writeBOM;
}
transform(transformFunction) {
this.rowFormatter.rowTransform = transformFunction;
return this;
}
_transform(row, encoding, cb) {
let cbCalled = false;
try {
if (!this.hasWrittenBOM) {
this.push(this.formatterOptions.BOM);
this.hasWrittenBOM = true;
}
this.rowFormatter.format(row, (err, rows) => {
if (err) {
cbCalled = true;
return cb(err);
}
if (rows) {
rows.forEach((r) => {
this.push(Buffer.from(r, 'utf8'));
});
}
cbCalled = true;
return cb();
});
}
catch (e) {
if (cbCalled) {
throw e;
}
cb(e);
}
}
_flush(cb) {
this.rowFormatter.finish((err, rows) => {
if (err) {
return cb(err);
}
if (rows) {
rows.forEach((r) => {
this.push(Buffer.from(r, 'utf8'));
});
}
return cb();
});
}
}
exports.CsvFormatterStream = CsvFormatterStream;
//# sourceMappingURL=CsvFormatterStream.js.map
\ No newline at end of file
{"version":3,"file":"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C,CAAC,CAAC;oBACtC,CAAC,CAAC,CAAC;iBACN;gBACD,QAAQ,GAAG,IAAI,CAAC;gBAChB,OAAO,EAAE,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;SACN;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,QAAQ,EAAE;gBACV,MAAM,CAAC,CAAC;aACX;YACD,EAAE,CAAC,CAAC,CAAC,CAAC;SACT;IACL,CAAC;IAEM,MAAM,CAAC,EAAqB;QAC/B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAQ,EAAE;YACzC,IAAI,GAAG,EAAE;gBACL,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;aAClB;YACD,IAAI,IAAI,EAAE;gBACN,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAQ,EAAE;oBACrB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC;aACN;YACD,OAAO,EAAE,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA9DD,gDA8DC"}
\ No newline at end of file
import { Row, RowTransformFunction } from './types';
interface QuoteColumnMap {
[s: string]: boolean;
}
declare type QuoteColumns = boolean | boolean[] | QuoteColumnMap;
export interface FormatterOptionsArgs<I extends Row, O extends Row> {
objectMode?: boolean;
delimiter?: string;
rowDelimiter?: string;
quote?: string | boolean;
escape?: string;
quoteColumns?: QuoteColumns;
quoteHeaders?: QuoteColumns;
headers?: null | boolean | string[];
writeHeaders?: boolean;
includeEndRowDelimiter?: boolean;
writeBOM?: boolean;
transform?: RowTransformFunction<I, O>;
alwaysWriteHeaders?: boolean;
}
export declare class FormatterOptions<I extends Row, O extends Row> {
readonly objectMode: boolean;
readonly delimiter: string;
readonly rowDelimiter: string;
readonly quote: string;
readonly escape: string;
readonly quoteColumns: QuoteColumns;
readonly quoteHeaders: QuoteColumns;
readonly headers: null | string[];
readonly includeEndRowDelimiter: boolean;
readonly transform?: RowTransformFunction<I, O>;
readonly shouldWriteHeaders: boolean;
readonly writeBOM: boolean;
readonly escapedQuote: string;
readonly BOM: string;
readonly alwaysWriteHeaders: boolean;
constructor(opts?: FormatterOptionsArgs<I, O>);
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormatterOptions = void 0;
class FormatterOptions {
constructor(opts = {}) {
var _a;
this.objectMode = true;
this.delimiter = ',';
this.rowDelimiter = '\n';
this.quote = '"';
this.escape = this.quote;
this.quoteColumns = false;
this.quoteHeaders = this.quoteColumns;
this.headers = null;
this.includeEndRowDelimiter = false;
this.writeBOM = false;
this.BOM = '\ufeff';
this.alwaysWriteHeaders = false;
Object.assign(this, opts || {});
if (typeof (opts === null || opts === void 0 ? void 0 : opts.quoteHeaders) === 'undefined') {
this.quoteHeaders = this.quoteColumns;
}
if ((opts === null || opts === void 0 ? void 0 : opts.quote) === true) {
this.quote = '"';
}
else if ((opts === null || opts === void 0 ? void 0 : opts.quote) === false) {
this.quote = '';
}
if (typeof (opts === null || opts === void 0 ? void 0 : opts.escape) !== 'string') {
this.escape = this.quote;
}
this.shouldWriteHeaders = !!this.headers && ((_a = opts.writeHeaders) !== null && _a !== void 0 ? _a : true);
this.headers = Array.isArray(this.headers) ? this.headers : null;
this.escapedQuote = `${this.escape}${this.quote}`;
}
}
exports.FormatterOptions = FormatterOptions;
//# sourceMappingURL=FormatterOptions.js.map
\ No newline at end of file
{"version":3,"file":"FormatterOptions.js","sourceRoot":"","sources":["../../src/FormatterOptions.ts"],"names":[],"mappings":";;;AAwBA,MAAa,gBAAgB;IA+BzB,YAAmB,OAAmC,EAAE;;QA9BxC,eAAU,GAAY,IAAI,CAAC;QAE3B,cAAS,GAAW,GAAG,CAAC;QAExB,iBAAY,GAAW,IAAI,CAAC;QAE5B,UAAK,GAAW,GAAG,CAAC;QAEpB,WAAM,GAAW,IAAI,CAAC,KAAK,CAAC;QA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CAAC;CACJ;AAjDD,4CAiDC"}
\ No newline at end of file
import { FormatterOptions } from '../FormatterOptions';
import { Row } from '../types';
export declare class FieldFormatter<I extends Row, O extends Row> {
private readonly formatterOptions;
private _headers;
private readonly REPLACE_REGEXP;
private readonly ESCAPE_REGEXP;
constructor(formatterOptions: FormatterOptions<I, O>);
set headers(headers: string[]);
private shouldQuote;
format(field: string, fieldIndex: number, isHeader: boolean): string;
private quoteField;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldFormatter = void 0;
const lodash_isboolean_1 = __importDefault(require("lodash.isboolean"));
const lodash_isnil_1 = __importDefault(require("lodash.isnil"));
const lodash_escaperegexp_1 = __importDefault(require("lodash.escaperegexp"));
class FieldFormatter {
constructor(formatterOptions) {
this._headers = null;
this.formatterOptions = formatterOptions;
if (formatterOptions.headers !== null) {
this.headers = formatterOptions.headers;
}
this.REPLACE_REGEXP = new RegExp(formatterOptions.quote, 'g');
const escapePattern = `[${formatterOptions.delimiter}${lodash_escaperegexp_1.default(formatterOptions.rowDelimiter)}|\r|\n]`;
this.ESCAPE_REGEXP = new RegExp(escapePattern);
}
set headers(headers) {
this._headers = headers;
}
shouldQuote(fieldIndex, isHeader) {
const quoteConfig = isHeader ? this.formatterOptions.quoteHeaders : this.formatterOptions.quoteColumns;
if (lodash_isboolean_1.default(quoteConfig)) {
return quoteConfig;
}
if (Array.isArray(quoteConfig)) {
return quoteConfig[fieldIndex];
}
if (this._headers !== null) {
return quoteConfig[this._headers[fieldIndex]];
}
return false;
}
format(field, fieldIndex, isHeader) {
const preparedField = `${lodash_isnil_1.default(field) ? '' : field}`.replace(/\0/g, '');
const { formatterOptions } = this;
if (formatterOptions.quote !== '') {
const shouldEscape = preparedField.indexOf(formatterOptions.quote) !== -1;
if (shouldEscape) {
return this.quoteField(preparedField.replace(this.REPLACE_REGEXP, formatterOptions.escapedQuote));
}
}
const hasEscapeCharacters = preparedField.search(this.ESCAPE_REGEXP) !== -1;
if (hasEscapeCharacters || this.shouldQuote(fieldIndex, isHeader)) {
return this.quoteField(preparedField);
}
return preparedField;
}
quoteField(field) {
const { quote } = this.formatterOptions;
return `${quote}${field}${quote}`;
}
}
exports.FieldFormatter = FieldFormatter;
//# sourceMappingURL=FieldFormatter.js.map
\ No newline at end of file
{"version":3,"file":"FieldFormatter.js","sourceRoot":"","sources":["../../../src/formatter/FieldFormatter.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAyC;AACzC,gEAAiC;AACjC,8EAA+C;AAI/C,MAAa,cAAc;IASvB,YAAmB,gBAAwC;QANnD,aAAQ,GAAoB,IAAI,CAAC;QAOrC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,gBAAgB,CAAC,OAAO,KAAK,IAAI,EAAE;YACnC,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;SAC3C;QACD,IAAI,CAAC,cAAc,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9D,MAAM,aAAa,GAAG,IAAI,gBAAgB,CAAC,SAAS,GAAG,6BAAY,CAAC,gBAAgB,CAAC,YAAY,CAAC,SAAS,CAAC;QAC5G,IAAI,CAAC,aAAa,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,IAAW,OAAO,CAAC,OAAiB;QAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAEO,WAAW,CAAC,UAAkB,EAAE,QAAiB;QACrD,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC;QACvG,IAAI,0BAAS,CAAC,WAAW,CAAC,EAAE;YACxB,OAAO,WAAW,CAAC;SACtB;QACD,I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AG,KAAK,EAAE,CAAC;IACtC,CAAC;CACJ;AAzDD,wCAyDC"}
\ No newline at end of file
import { FormatterOptions } from '../FormatterOptions';
import { Row, RowArray, RowTransformFunction } from '../types';
declare type RowFormatterCallback = (error: Error | null, data?: RowArray) => void;
export declare class RowFormatter<I extends Row, O extends Row> {
private static isRowHashArray;
private static isRowArray;
private static gatherHeaders;
private static createTransform;
private readonly formatterOptions;
private readonly fieldFormatter;
private readonly shouldWriteHeaders;
private _rowTransform?;
private headers;
private hasWrittenHeaders;
private rowCount;
constructor(formatterOptions: FormatterOptions<I, O>);
set rowTransform(transformFunction: RowTransformFunction<I, O>);
format(row: I, cb: RowFormatterCallback): void;
finish(cb: RowFormatterCallback): void;
private checkHeaders;
private gatherColumns;
private callTransformer;
private formatColumns;
}
export {};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RowFormatter = void 0;
const lodash_isfunction_1 = __importDefault(require("lodash.isfunction"));
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
const FieldFormatter_1 = require("./FieldFormatter");
const types_1 = require("../types");
class RowFormatter {
constructor(formatterOptions) {
this.rowCount = 0;
this.formatterOptions = formatterOptions;
this.fieldFormatter = new FieldFormatter_1.FieldFormatter(formatterOptions);
this.headers = formatterOptions.headers;
this.shouldWriteHeaders = formatterOptions.shouldWriteHeaders;
this.hasWrittenHeaders = false;
if (this.headers !== null) {
this.fieldFormatter.headers = this.headers;
}
if (formatterOptions.transform) {
this.rowTransform = formatterOptions.transform;
}
}
static isRowHashArray(row) {
if (Array.isArray(row)) {
return Array.isArray(row[0]) && row[0].length === 2;
}
return false;
}
static isRowArray(row) {
return Array.isArray(row) && !this.isRowHashArray(row);
}
// get headers from a row item
static gatherHeaders(row) {
if (RowFormatter.isRowHashArray(row)) {
// lets assume a multi-dimesional array with item 0 being the header
return row.map((it) => it[0]);
}
if (Array.isArray(row)) {
return row;
}
return Object.keys(row);
}
// eslint-disable-next-line @typescript-eslint/no-shadow
static createTransform(transformFunction) {
if (types_1.isSyncTransform(transformFunction)) {
return (row, cb) => {
let transformedRow = null;
try {
transformedRow = transformFunction(row);
}
catch (e) {
return cb(e);
}
return cb(null, transformedRow);
};
}
return (row, cb) => {
transformFunction(row, cb);
};
}
set rowTransform(transformFunction) {
if (!lodash_isfunction_1.default(transformFunction)) {
throw new TypeError('The transform should be a function');
}
this._rowTransform = RowFormatter.createTransform(transformFunction);
}
format(row, cb) {
this.callTransformer(row, (err, transformedRow) => {
if (err) {
return cb(err);
}
if (!row) {
return cb(null);
}
const rows = [];
if (transformedRow) {
const { shouldFormatColumns, headers } = this.checkHeaders(transformedRow);
if (this.shouldWriteHeaders && headers && !this.hasWrittenHeaders) {
rows.push(this.formatColumns(headers, true));
this.hasWrittenHeaders = true;
}
if (shouldFormatColumns) {
const columns = this.gatherColumns(transformedRow);
rows.push(this.formatColumns(columns, false));
}
}
return cb(null, rows);
});
}
finish(cb) {
const rows = [];
// check if we should write headers and we didnt get any rows
if (this.formatterOptions.alwaysWriteHeaders && this.rowCount === 0) {
if (!this.headers) {
return cb(new Error('`alwaysWriteHeaders` option is set to true but `headers` option not provided.'));
}
rows.push(this.formatColumns(this.headers, true));
}
if (this.formatterOptions.includeEndRowDelimiter) {
rows.push(this.formatterOptions.rowDelimiter);
}
return cb(null, rows);
}
// check if we need to write header return true if we should also write a row
// could be false if headers is true and the header row(first item) is passed in
checkHeaders(row) {
if (this.headers) {
// either the headers were provided by the user or we have already gathered them.
return { shouldFormatColumns: true, headers: this.headers };
}
const headers = RowFormatter.gatherHeaders(row);
this.headers = headers;
this.fieldFormatter.headers = headers;
if (!this.shouldWriteHeaders) {
// if we are not supposed to write the headers then
// always format the columns
return { shouldFormatColumns: true, headers: null };
}
// if the row is equal to headers dont format
return { shouldFormatColumns: !lodash_isequal_1.default(headers, row), headers };
}
// todo change this method to unknown[]
gatherColumns(row) {
if (this.headers === null) {
throw new Error('Headers is currently null');
}
if (!Array.isArray(row)) {
return this.headers.map((header) => row[header]);
}
if (RowFormatter.isRowHashArray(row)) {
return this.headers.map((header, i) => {
const col = row[i];
if (col) {
return col[1];
}
return '';
});
}
// if its a one dimensional array and headers were not provided
// then just return the row
if (RowFormatter.isRowArray(row) && !this.shouldWriteHeaders) {
return row;
}
return this.headers.map((header, i) => row[i]);
}
callTransformer(row, cb) {
if (!this._rowTransform) {
return cb(null, row);
}
return this._rowTransform(row, cb);
}
formatColumns(columns, isHeadersRow) {
const formattedCols = columns
.map((field, i) => this.fieldFormatter.format(field, i, isHeadersRow))
.join(this.formatterOptions.delimiter);
const { rowCount } = this;
this.rowCount += 1;
if (rowCount) {
return [this.formatterOptions.rowDelimiter, formattedCols].join('');
}
return formattedCols;
}
}
exports.RowFormatter = RowFormatter;
//# sourceMappingURL=RowFormatter.js.map
\ No newline at end of file
{"version":3,"file":"RowFormatter.js","sourceRoot":"","sources":["../../../src/formatter/RowFormatter.ts"],"names":[],"mappings":";;;;;;AAAA,0EAA2C;AAC3C,oEAAqC;AAErC,qDAAkD;AAClD,oCAAoH;AAMpH,MAAa,YAAY;IA0DrB,YAAmB,gBAAwC;QAFnD,aAAQ,GAAG,CAAC,CAAC;QAGjB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CAAC,gBAAgB,CAAC,CAAC;QAE3D,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;QACxC,IAAI,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC;QAC9D,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QAC/B,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;YACvB,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;SAC9C;QACD,IAAI,gBAAgB,CAAC,SAAS,EAAE;YAC5B,IAAI,C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CAAC;IACvC,CAAC;IAEO,aAAa,CAAC,OAAiB,EAAE,YAAqB;QAC1D,MAAM,aAAa,GAAG,OAAO;aACxB,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAU,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;aAC7E,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACnB,IAAI,QAAQ,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACvE;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ;AArLD,oCAqLC"}
\ No newline at end of file
export { RowFormatter } from './RowFormatter';
export { FieldFormatter } from './FieldFormatter';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldFormatter = exports.RowFormatter = void 0;
var RowFormatter_1 = require("./RowFormatter");
Object.defineProperty(exports, "RowFormatter", { enumerable: true, get: function () { return RowFormatter_1.RowFormatter; } });
var FieldFormatter_1 = require("./FieldFormatter");
Object.defineProperty(exports, "FieldFormatter", { enumerable: true, get: function () { return FieldFormatter_1.FieldFormatter; } });
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA"}
\ No newline at end of file
/// <reference types="node" />
import * as fs from 'fs';
import { Row } from './types';
import { FormatterOptionsArgs } from './FormatterOptions';
import { CsvFormatterStream } from './CsvFormatterStream';
export * from './types';
export { CsvFormatterStream } from './CsvFormatterStream';
export { FormatterOptions, FormatterOptionsArgs } from './FormatterOptions';
export declare const format: <I extends Row, O extends Row>(options?: FormatterOptionsArgs<I, O> | undefined) => CsvFormatterStream<I, O>;
export declare const write: <I extends Row, O extends Row>(rows: I[], options?: FormatterOptionsArgs<I, O> | undefined) => CsvFormatterStream<I, O>;
export declare const writeToStream: <T extends NodeJS.WritableStream, I extends Row, O extends Row>(ws: T, rows: I[], options?: FormatterOptionsArgs<I, O> | undefined) => T;
export declare const writeToBuffer: <I extends Row, O extends Row>(rows: I[], opts?: FormatterOptionsArgs<I, O>) => Promise<Buffer>;
export declare const writeToString: <I extends Row, O extends Row>(rows: I[], options?: FormatterOptionsArgs<I, O> | undefined) => Promise<string>;
export declare const writeToPath: <I extends Row, O extends Row>(path: string, rows: I[], options?: FormatterOptionsArgs<I, O> | undefined) => fs.WriteStream;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeToPath = exports.writeToString = exports.writeToBuffer = exports.writeToStream = exports.write = exports.format = exports.FormatterOptions = exports.CsvFormatterStream = void 0;
const util_1 = require("util");
const stream_1 = require("stream");
const fs = __importStar(require("fs"));
const FormatterOptions_1 = require("./FormatterOptions");
const CsvFormatterStream_1 = require("./CsvFormatterStream");
__exportStar(require("./types"), exports);
var CsvFormatterStream_2 = require("./CsvFormatterStream");
Object.defineProperty(exports, "CsvFormatterStream", { enumerable: true, get: function () { return CsvFormatterStream_2.CsvFormatterStream; } });
var FormatterOptions_2 = require("./FormatterOptions");
Object.defineProperty(exports, "FormatterOptions", { enumerable: true, get: function () { return FormatterOptions_2.FormatterOptions; } });
exports.format = (options) => new CsvFormatterStream_1.CsvFormatterStream(new FormatterOptions_1.FormatterOptions(options));
exports.write = (rows, options) => {
const csvStream = exports.format(options);
const promiseWrite = util_1.promisify((row, cb) => {
csvStream.write(row, undefined, cb);
});
rows.reduce((prev, row) => prev.then(() => promiseWrite(row)), Promise.resolve())
.then(() => csvStream.end())
.catch((err) => {
csvStream.emit('error', err);
});
return csvStream;
};
exports.writeToStream = (ws, rows, options) => exports.write(rows, options).pipe(ws);
exports.writeToBuffer = (rows, opts = {}) => {
const buffers = [];
const ws = new stream_1.Writable({
write(data, enc, writeCb) {
buffers.push(data);
writeCb();
},
});
return new Promise((res, rej) => {
ws.on('error', rej).on('finish', () => res(Buffer.concat(buffers)));
exports.write(rows, opts).pipe(ws);
});
};
exports.writeToString = (rows, options) => exports.writeToBuffer(rows, options).then((buffer) => buffer.toString());
exports.writeToPath = (path, rows, options) => {
const stream = fs.createWriteStream(path, { encoding: 'utf8' });
return exports.write(rows, options).pipe(stream);
};
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,mCAAkC;AAClC,uCAAyB;AAEzB,yDAA4E;AAC5E,6DAA0D;AAE1D,0CAAwB;AACxB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,uDAA4E;AAAnE,oHAAA,gBAAgB,OAAA;AAEZ,QAAA,MAAM,GAAG,CAA+B,OA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C,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAQ,EAAE;QAClC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAS,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1E,aAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEW,QAAA,aAAa,GAAG,CACzB,IAAS,EACT,OAAoC,EACrB,EAAE,CAAC,qBAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAU,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAElF,QAAA,WAAW,GAAG,CACvB,IAAY,EACZ,IAAS,EACT,OAAoC,EACtB,EAAE;IAChB,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,OAAO,aAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC,CAAC"}
\ No newline at end of file
export declare type RowMap<V = any> = Record<string, V>;
export declare type RowHashArray<V = any> = [string, V][];
export declare type RowArray = string[];
export declare type Row = RowArray | RowHashArray | RowMap;
export declare type RowTransformCallback<R extends Row> = (error?: Error | null, row?: R) => void;
export declare type SyncRowTransform<I extends Row, O extends Row> = (row: I) => O;
export declare type AsyncRowTransform<I extends Row, O extends Row> = (row: I, cb: RowTransformCallback<O>) => void;
export declare type RowTransformFunction<I extends Row, O extends Row> = SyncRowTransform<I, O> | AsyncRowTransform<I, O>;
export declare const isSyncTransform: <I extends Row, O extends Row>(transform: RowTransformFunction<I, O>) => transform is SyncRowTransform<I, O>;
"use strict";
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSyncTransform = void 0;
exports.isSyncTransform = (transform) => transform.length === 1;
//# sourceMappingURL=types.js.map
\ No newline at end of file
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;AAY1C,QAAA,eAAe,GAAG,CAC3B,SAAqC,EACF,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC"}
\ No newline at end of file
../../../../_@types_node@14.14.45@@types/node
\ No newline at end of file
../../../_lodash.escaperegexp@4.1.2@lodash.escaperegexp
\ No newline at end of file
../../../_lodash.isboolean@3.0.3@lodash.isboolean
\ No newline at end of file
../../../_lodash.isequal@4.5.0@lodash.isequal
\ No newline at end of file
../../../_lodash.isfunction@3.0.9@lodash.isfunction
\ No newline at end of file
../../../_lodash.isnil@4.0.0@lodash.isnil
\ No newline at end of file
{
"name": "@fast-csv/format",
"version": "4.3.5",
"description": "fast-csv formatting module",
"keywords": [
"csv",
"format",
"write"
],
"author": "doug-martin <doug@dougamartin.com>",
"homepage": "http://c2fo.github.com/fast-csv/packages/format",
"license": "MIT",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"directories": {
"lib": "src",
"test": "__tests__"
},
"files": [
"build/src/**"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/C2FO/fast-csv.git",
"directory": "packages/format"
},
"scripts": {
"prepublishOnly": "npm run build",
"build": "npm run clean && npm run compile",
"clean": "rm -rf ./build && rm -rf tsconfig.tsbuildinfo",
"compile": "tsc"
},
"bugs": {
"url": "https://github.com/C2FO/fast-csv/issues"
},
"dependencies": {
"@types/node": "^14.0.1",
"lodash.escaperegexp": "^4.1.2",
"lodash.isboolean": "^3.0.3",
"lodash.isequal": "^4.5.0",
"lodash.isfunction": "^3.0.9",
"lodash.isnil": "^4.0.0"
},
"devDependencies": {
"@types/lodash.escaperegexp": "4.1.6",
"@types/lodash.isboolean": "3.0.6",
"@types/lodash.isequal": "4.5.5",
"@types/lodash.isfunction": "3.0.6",
"@types/lodash.isnil": "4.0.6"
},
"gitHead": "b908170cb49398ae12847d050af5c8e5b0dc812f",
"__npminstall_done": "Tue May 18 2021 15:21:44 GMT+0800 (GMT+08:00)",
"_from": "@fast-csv/format@4.3.5",
"_resolved": "https://registry.nlark.com/@fast-csv/format/download/@fast-csv/format-4.3.5.tgz"
}
\ No newline at end of file
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [4.3.6](https://github.com/C2FO/fast-csv/compare/v4.3.5...v4.3.6) (2020-12-04)
### Bug Fixes
* Simplify empty row check by removing complex regex ([4bbd39f](https://github.com/C2FO/fast-csv/commit/4bbd39f26a8cd7382151ab4f5fb102234b2f829e))
## [4.3.3](https://github.com/C2FO/fast-csv/compare/v4.3.2...v4.3.3) (2020-10-30)
**Note:** Version bump only for package @fast-csv/parse
## [4.3.2](https://github.com/C2FO/fast-csv/compare/v4.3.1...v4.3.2) (2020-09-02)
### Bug Fixes
* **parsing, #423:** Prevent callback from being called multiple times ([040febe](https://github.com/C2FO/fast-csv/commit/040febe17f5fe763a00f45b1d83c5acd47bbbe0b)), closes [#423](https://github.com/C2FO/fast-csv/issues/423)
## [4.3.1](https://github.com/C2FO/fast-csv/compare/v4.3.0...v4.3.1) (2020-06-23)
### Bug Fixes
* **parsing:** Pass errors through callbacks ([84ecdf6](https://github.com/C2FO/fast-csv/commit/84ecdf6ed18b15d68b4ed3e2bfec7eb41b438ad8))
# [4.3.0](https://github.com/C2FO/fast-csv/compare/v4.2.0...v4.3.0) (2020-05-27)
**Note:** Version bump only for package @fast-csv/parse
# [4.2.0](https://github.com/C2FO/fast-csv/compare/v4.1.6...v4.2.0) (2020-05-19)
### Features
* **parsing:** Less restrictive row parsing type [#356](https://github.com/C2FO/fast-csv/issues/356) ([87d74ec](https://github.com/C2FO/fast-csv/commit/87d74ecd2cb16f3700b1942ebbbec221afe38790))
## [4.1.6](https://github.com/C2FO/fast-csv/compare/v4.1.5...v4.1.6) (2020-05-15)
### Bug Fixes
* **parse:** Handle escaped escape properly [#340](https://github.com/C2FO/fast-csv/issues/340) ([78d9b16](https://github.com/C2FO/fast-csv/commit/78d9b160152ee399f31086cc6b5f66a7ca7f9e24))
## [4.1.5](https://github.com/C2FO/fast-csv/compare/v4.1.4...v4.1.5) (2020-05-15)
**Note:** Version bump only for package @fast-csv/parse
## [4.1.4](https://github.com/C2FO/fast-csv/compare/v4.1.3...v4.1.4) (2020-05-15)
**Note:** Version bump only for package @fast-csv/parse
The MIT License
Copyright (c) 2011-2019 C2FO
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
<p align="center">
<a href="https://c2fo.io/fast-csv" target="blank"><img src="https://c2fo.io/fast-csv/img/logo.svg" width="200" alt="fast-csv Logo" /></a>
</p>
[![npm version](https://img.shields.io/npm/v/@fast-csv/parse.svg)](https://www.npmjs.org/package/@fast-csv/parse)
[![Build Status](https://travis-ci.org/C2FO/fast-csv.svg?branch=master)](https://travis-ci.org/C2FO/fast-csv)
[![Coverage Status](https://coveralls.io/repos/github/C2FO/fast-csv/badge.svg?branch=master)](https://coveralls.io/github/C2FO/fast-csv?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/C2FO/fast-csv/badge.svg?targetFile=packages/parse/package.json)](https://snyk.io/test/github/C2FO/fast-csv?targetFile=packages/parse/package.json)
# `@fast-csv/parse`
`fast-csv` package to parse CSVs.
## Installation
[Install Guide](https://c2fo.io/fast-csv/docs/introduction/install)
## Usage
To get started with `@fast-csv/parse` [check out the docs](https://c2fo.io/fast-csv/docs/parsing/getting-started)
/// <reference types="node" />
import { Transform, TransformCallback } from 'stream';
import { ParserOptions } from './ParserOptions';
import { Row, RowTransformFunction, RowValidate } from './types';
export declare class CsvParserStream<I extends Row, O extends Row> extends Transform {
private readonly parserOptions;
private readonly decoder;
private readonly parser;
private readonly headerTransformer;
private readonly rowTransformerValidator;
private lines;
private rowCount;
private parsedRowCount;
private parsedLineCount;
private endEmitted;
private headersEmitted;
constructor(parserOptions: ParserOptions);
private get hasHitRowLimit();
private get shouldEmitRows();
private get shouldSkipLine();
transform(transformFunction: RowTransformFunction<I, O>): CsvParserStream<I, O>;
validate(validateFunction: RowValidate<O>): CsvParserStream<I, O>;
emit(event: string | symbol, ...rest: any[]): boolean;
_transform(data: Buffer, encoding: string, done: TransformCallback): void;
_flush(done: TransformCallback): void;
private parse;
private processRows;
private transformRow;
private checkAndEmitHeaders;
private skipRow;
private pushRow;
private static wrapDoneCallback;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CsvParserStream = void 0;
const string_decoder_1 = require("string_decoder");
const stream_1 = require("stream");
const transforms_1 = require("./transforms");
const parser_1 = require("./parser");
class CsvParserStream extends stream_1.Transform {
constructor(parserOptions) {
super({ objectMode: parserOptions.objectMode });
this.lines = '';
this.rowCount = 0;
this.parsedRowCount = 0;
this.parsedLineCount = 0;
this.endEmitted = false;
this.headersEmitted = false;
this.parserOptions = parserOptions;
this.parser = new parser_1.Parser(parserOptions);
this.headerTransformer = new transforms_1.HeaderTransformer(parserOptions);
this.decoder = new string_decoder_1.StringDecoder(parserOptions.encoding);
this.rowTransformerValidator = new transforms_1.RowTransformerValidator();
}
get hasHitRowLimit() {
return this.parserOptions.limitRows && this.rowCount >= this.parserOptions.maxRows;
}
get shouldEmitRows() {
return this.parsedRowCount > this.parserOptions.skipRows;
}
get shouldSkipLine() {
return this.parsedLineCount <= this.parserOptions.skipLines;
}
transform(transformFunction) {
this.rowTransformerValidator.rowTransform = transformFunction;
return this;
}
validate(validateFunction) {
this.rowTransformerValidator.rowValidator = validateFunction;
return this;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
emit(event, ...rest) {
if (event === 'end') {
if (!this.endEmitted) {
this.endEmitted = true;
super.emit('end', this.rowCount);
}
return false;
}
return super.emit(event, ...rest);
}
_transform(data, encoding, done) {
// if we have hit our maxRows parsing limit then skip parsing
if (this.hasHitRowLimit) {
return done();
}
const wrappedCallback = CsvParserStream.wrapDoneCallback(done);
try {
const { lines } = this;
const newLine = lines + this.decoder.write(data);
const rows = this.parse(newLine, true);
return this.processRows(rows, wrappedCallback);
}
catch (e) {
return wrappedCallback(e);
}
}
_flush(done) {
const wrappedCallback = CsvParserStream.wrapDoneCallback(done);
// if we have hit our maxRows parsing limit then skip parsing
if (this.hasHitRowLimit) {
return wrappedCallback();
}
try {
const newLine = this.lines + this.decoder.end();
const rows = this.parse(newLine, false);
return this.processRows(rows, wrappedCallback);
}
catch (e) {
return wrappedCallback(e);
}
}
parse(data, hasMoreData) {
if (!data) {
return [];
}
const { line, rows } = this.parser.parse(data, hasMoreData);
this.lines = line;
return rows;
}
processRows(rows, cb) {
const rowsLength = rows.length;
const iterate = (i) => {
const callNext = (err) => {
if (err) {
return cb(err);
}
if (i % 100 === 0) {
// incase the transform are sync insert a next tick to prevent stack overflow
setImmediate(() => iterate(i + 1));
return undefined;
}
return iterate(i + 1);
};
this.checkAndEmitHeaders();
// if we have emitted all rows or we have hit the maxRows limit option
// then end
if (i >= rowsLength || this.hasHitRowLimit) {
return cb();
}
this.parsedLineCount += 1;
if (this.shouldSkipLine) {
return callNext();
}
const row = rows[i];
this.rowCount += 1;
this.parsedRowCount += 1;
const nextRowCount = this.rowCount;
return this.transformRow(row, (err, transformResult) => {
if (err) {
this.rowCount -= 1;
return callNext(err);
}
if (!transformResult) {
return callNext(new Error('expected transform result'));
}
if (!transformResult.isValid) {
this.emit('data-invalid', transformResult.row, nextRowCount, transformResult.reason);
}
else if (transformResult.row) {
return this.pushRow(transformResult.row, callNext);
}
return callNext();
});
};
iterate(0);
}
transformRow(parsedRow, cb) {
try {
this.headerTransformer.transform(parsedRow, (err, withHeaders) => {
if (err) {
return cb(err);
}
if (!withHeaders) {
return cb(new Error('Expected result from header transform'));
}
if (!withHeaders.isValid) {
if (this.shouldEmitRows) {
return cb(null, { isValid: false, row: parsedRow });
}
// skipped because of skipRows option remove from total row count
return this.skipRow(cb);
}
if (withHeaders.row) {
if (this.shouldEmitRows) {
return this.rowTransformerValidator.transformAndValidate(withHeaders.row, cb);
}
// skipped because of skipRows option remove from total row count
return this.skipRow(cb);
}
// this is a header row dont include in the rowCount or parsedRowCount
this.rowCount -= 1;
this.parsedRowCount -= 1;
return cb(null, { row: null, isValid: true });
});
}
catch (e) {
cb(e);
}
}
checkAndEmitHeaders() {
if (!this.headersEmitted && this.headerTransformer.headers) {
this.headersEmitted = true;
this.emit('headers', this.headerTransformer.headers);
}
}
skipRow(cb) {
// skipped because of skipRows option remove from total row count
this.rowCount -= 1;
return cb(null, { row: null, isValid: true });
}
pushRow(row, cb) {
try {
if (!this.parserOptions.objectMode) {
this.push(JSON.stringify(row));
}
else {
this.push(row);
}
cb();
}
catch (e) {
cb(e);
}
}
static wrapDoneCallback(done) {
let errorCalled = false;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (err, ...args) => {
if (err) {
if (errorCalled) {
throw err;
}
errorCalled = true;
done(err);
return;
}
done(...args);
};
}
}
exports.CsvParserStream = CsvParserStream;
//# sourceMappingURL=CsvParserStream.js.map
\ No newline at end of file
{"version":3,"file":"CsvParserStream.js","sourceRoot":"","sources":["../../src/CsvParserStream.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAC/C,mCAAsD;AAEtD,6CAA0E;AAC1E,qCAAkC;AAGlC,MAAa,eAA8C,SAAQ,kBAAS;IAuBxE,YAAmB,aAA4B;QAC3C,KAAK,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC;QAb5C,UAAK,GAAG,EAAE,CAAC;QAEX,aAAQ,GAAG,CAAC,CAAC;QAEb,mBAAc,GAAG,CAAC,CAAC;QAEnB,oBAAe,GAAG,CAAC,CAAC;QAEpB,eAAU,GAAG,KAAK,CAAC;QAEnB,mBAAc,GAAG,KAAK,CAAC;QAI3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,aAAa,CAAC,CAAC;QACxC,IAAI,CAAC,iBAAiB,GAAG,IAAI,8BAAiB,CAAC,aAAa,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,8BAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,uBAAuB,GAAG,IAAI,oCAAuB,EAAE,CAAC;IACjE,CAAC;IAED,IAAY,cAAc;QACtB,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;IACvF,CAAC;IAED,IAAY,cAAc;QACtB,OAAO,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;IAC7D,CAAC;IAED,IAAY,cAAc;QACtB,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;IAChE,CAAC;IAEM,SA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,CAAC,iBAAiB,CAAC,OAAO,EAAE;YACxD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;SACxD;IACL,CAAC;IAEO,OAAO,CAAC,EAA2B;QACvC,iEAAiE;QACjE,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACnB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAEO,OAAO,CAAC,GAAQ,EAAE,EAAyB;QAC/C,IAAI;YACA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE;gBAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;aAClC;iBAAM;gBACH,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;YACD,EAAE,EAAE,CAAC;SACR;QAAC,OAAO,CAAC,EAAE;YACR,EAAE,CAAC,CAAC,CAAC,CAAC;SACT;IACL,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,IAAuB;QACnD,IAAI,WAAW,GAAG,KAAK,CAAC;QACxB,8DAA8D;QAC9D,OAAO,CAAC,GAA6B,EAAE,GAAG,IAAW,EAAQ,EAAE;YAC3D,IAAI,GAAG,EAAE;gBACL,IAAI,WAAW,EAAE;oBACb,MAAM,GAAG,CAAC;iBACb;gBACD,WAAW,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC,GAAG,CAAC,CAAC;gBACV,OAAO;aACV;YACD,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC;IACN,CAAC;CACJ;AAnOD,0CAmOC"}
\ No newline at end of file
/// <reference types="node" />
import { HeaderArray, HeaderTransformFunction } from './types';
export interface ParserOptionsArgs {
objectMode?: boolean;
delimiter?: string;
quote?: string | null;
escape?: string;
headers?: boolean | HeaderTransformFunction | HeaderArray;
renameHeaders?: boolean;
ignoreEmpty?: boolean;
comment?: string;
strictColumnHandling?: boolean;
discardUnmappedColumns?: boolean;
trim?: boolean;
ltrim?: boolean;
rtrim?: boolean;
encoding?: string;
maxRows?: number;
skipLines?: number;
skipRows?: number;
}
export declare class ParserOptions {
readonly escapedDelimiter: string;
readonly objectMode: boolean;
readonly delimiter: string;
readonly ignoreEmpty: boolean;
readonly quote: string | null;
readonly escape: string | null;
readonly escapeChar: string | null;
readonly comment: string | null;
readonly supportsComments: boolean;
readonly ltrim: boolean;
readonly rtrim: boolean;
readonly trim: boolean;
readonly headers: boolean | HeaderTransformFunction | HeaderArray | null;
readonly renameHeaders: boolean;
readonly strictColumnHandling: boolean;
readonly discardUnmappedColumns: boolean;
readonly carriageReturn: string;
readonly NEXT_TOKEN_REGEXP: RegExp;
readonly encoding: BufferEncoding;
readonly limitRows: boolean;
readonly maxRows: number;
readonly skipLines: number;
readonly skipRows: number;
constructor(opts?: ParserOptionsArgs);
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParserOptions = void 0;
const lodash_escaperegexp_1 = __importDefault(require("lodash.escaperegexp"));
const lodash_isnil_1 = __importDefault(require("lodash.isnil"));
class ParserOptions {
constructor(opts) {
var _a;
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';
this.limitRows = false;
this.maxRows = 0;
this.skipLines = 0;
this.skipRows = 0;
Object.assign(this, opts || {});
if (this.delimiter.length > 1) {
throw new Error('delimiter option must be one character long');
}
this.escapedDelimiter = lodash_escaperegexp_1.default(this.delimiter);
this.escapeChar = (_a = this.escape) !== null && _a !== void 0 ? _a : this.quote;
this.supportsComments = !lodash_isnil_1.default(this.comment);
this.NEXT_TOKEN_REGEXP = new RegExp(`([^\\s]|\\r\\n|\\n|\\r|${this.escapedDelimiter})`);
if (this.maxRows > 0) {
this.limitRows = true;
}
}
}
exports.ParserOptions = ParserOptions;
//# sourceMappingURL=ParserOptions.js.map
\ No newline at end of file
{"version":3,"file":"ParserOptions.js","sourceRoot":"","sources":["../../src/ParserOptions.ts"],"names":[],"mappings":";;;;;;AAAA,8EAA+C;AAC/C,gEAAiC;AAuBjC,MAAa,aAAa;IA+CtB,YAAmB,IAAwB;;QA5C3B,eAAU,GAAY,IAAI,CAAC;QAE3B,cAAS,GAAW,GAAG,CAAC;QAExB,gBAAW,GAAY,KAAK,CAAC;QAE7B,UAAK,GAAkB,GAAG,CAAC;QAE3B,WAAM,GAAkB,IAAI,CAAC;QAE7B,eAAU,GAAkB,IAAI,CAAC,KAAK,CAAC;QAEvC,YAAO,GAAkB,IAAI,CAAC;QAE9B,qBAAgB,GAAY,KAAK,CAAC;QAElC,UAAK,GAAY,KAAK,CAAC;QAEvB,UAAK,GAAY,KAAK,CAAC;QAEvB,SAAI,GAAY,KAAK,CAAC;QAEtB,YAAO,GAA2D,IAAI,CAAC;QAEvE,kBAAa,GAAY,KAAK,CAAC;QAE/B,yBAAoB,GAAY,KAAK,CAAC;QAEtC,2BAAsB,GAAY,KAAK,CAAC;QAExC,mBAAc,GAAW,IAAI,CAAC;QAI9B,aAAQ,GAAmB,MAAM,CAAC;QAElC,cAAS,GAAY,KAAK,CAAC;QAE3B,YAAO,GAAW,CAAC,CAAC;QAEpB,cAAS,GAAW,CAAC,CAAC;QAEtB,aAAQ,GAAW,CAAC,CAAC;QAGjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAClE;QACD,IAAI,CAAC,gBAAgB,GAAG,6BAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,SAAG,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC,KAAK,CAAC;QAC5C,IAAI,CAAC,gBAAgB,GAAG,CAAC,sBAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,iBAAiB,GAAG,IAAI,MAAM,CAAC,0BAA0B,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAExF,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE;YAClB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;SACzB;IACL,CAAC;CACJ;AA7DD,sCA6DC"}
\ No newline at end of file
/// <reference types="node" />
import { ParserOptionsArgs } from './ParserOptions';
import { CsvParserStream } from './CsvParserStream';
import { Row } from './types';
export * from './types';
export { CsvParserStream } from './CsvParserStream';
export { ParserOptions, ParserOptionsArgs } from './ParserOptions';
export declare const parse: <I extends Row<any>, O extends Row<any>>(args?: ParserOptionsArgs | undefined) => CsvParserStream<I, O>;
export declare const parseStream: <I extends Row<any>, O extends Row<any>>(stream: NodeJS.ReadableStream, options?: ParserOptionsArgs | undefined) => CsvParserStream<I, O>;
export declare const parseFile: <I extends Row<any>, O extends Row<any>>(location: string, options?: ParserOptionsArgs) => CsvParserStream<I, O>;
export declare const parseString: <I extends Row<any>, O extends Row<any>>(string: string, options?: ParserOptionsArgs | undefined) => CsvParserStream<I, O>;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseString = exports.parseFile = exports.parseStream = exports.parse = exports.ParserOptions = exports.CsvParserStream = void 0;
const fs = __importStar(require("fs"));
const stream_1 = require("stream");
const ParserOptions_1 = require("./ParserOptions");
const CsvParserStream_1 = require("./CsvParserStream");
__exportStar(require("./types"), exports);
var CsvParserStream_2 = require("./CsvParserStream");
Object.defineProperty(exports, "CsvParserStream", { enumerable: true, get: function () { return CsvParserStream_2.CsvParserStream; } });
var ParserOptions_2 = require("./ParserOptions");
Object.defineProperty(exports, "ParserOptions", { enumerable: true, get: function () { return ParserOptions_2.ParserOptions; } });
exports.parse = (args) => new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(args));
exports.parseStream = (stream, options) => stream.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
exports.parseFile = (location, options = {}) => fs.createReadStream(location).pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
exports.parseString = (string, options) => {
const rs = new stream_1.Readable();
rs.push(string);
rs.push(null);
return rs.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
};
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,mCAAkC;AAClC,mDAAmE;AACnE,uDAAoD;AAGpD,0CAAwB;AACxB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,iDAAmE;AAA1D,8GAAA,aAAa,OAAA;AAET,QAAA,KAAK,GAAG,CAA+B,IAAwB,EAAyB,EAAE,CACnG,IAAI,iCAAe,CAAC,IAAI,6BAAa,CAAC,IAAI,CAAC,CAAC,CAAC;AAEpC,QAAA,WAAW,GAAG,CACvB,MAA6B,EAC7B,OAA2B,EACN,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,iCAAe,CAAC,IAAI,6BAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE5E,QAAA,SAAS,GAAG,CACrB,QAAgB,EAChB,UAA6B,EAAE,EACV,EAAE,CAAC,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,iCAAe,CAAC,IAAI,6BAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnG,QAAA,WAAW,GAAG,CACvB,MAAc,EACd,OAA2B,EACN,EAAE;IACvB,MAAM,EAAE,GAAG,IAAI,iBAAQ,EAAE,CAAC;IAC1B,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,iCAAe,CAAC,IAAI,6BAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC"}
\ No newline at end of file
import { ParserOptions } from '../ParserOptions';
export interface ParseResult {
line: string;
rows: string[][];
}
export declare class Parser {
private static removeBOM;
private readonly parserOptions;
private readonly rowParser;
constructor(parserOptions: ParserOptions);
parse(line: string, hasMoreData: boolean): ParseResult;
private parseWithoutComments;
private parseWithComments;
private parseRow;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = void 0;
const Scanner_1 = require("./Scanner");
const RowParser_1 = require("./RowParser");
const Token_1 = require("./Token");
class Parser {
constructor(parserOptions) {
this.parserOptions = parserOptions;
this.rowParser = new RowParser_1.RowParser(this.parserOptions);
}
static removeBOM(line) {
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
// conversion translates it to FEFF (UTF-16 BOM)
if (line && line.charCodeAt(0) === 0xfeff) {
return line.slice(1);
}
return line;
}
parse(line, hasMoreData) {
const scanner = new Scanner_1.Scanner({
line: Parser.removeBOM(line),
parserOptions: this.parserOptions,
hasMoreData,
});
if (this.parserOptions.supportsComments) {
return this.parseWithComments(scanner);
}
return this.parseWithoutComments(scanner);
}
parseWithoutComments(scanner) {
const rows = [];
let shouldContinue = true;
while (shouldContinue) {
shouldContinue = this.parseRow(scanner, rows);
}
return { line: scanner.line, rows };
}
parseWithComments(scanner) {
const { parserOptions } = this;
const rows = [];
for (let nextToken = scanner.nextCharacterToken; nextToken !== null; nextToken = scanner.nextCharacterToken) {
if (Token_1.Token.isTokenComment(nextToken, parserOptions)) {
const cursor = scanner.advancePastLine();
if (cursor === null) {
return { line: scanner.lineFromCursor, rows };
}
if (!scanner.hasMoreCharacters) {
return { line: scanner.lineFromCursor, rows };
}
scanner.truncateToCursor();
}
else if (!this.parseRow(scanner, rows)) {
break;
}
}
return { line: scanner.line, rows };
}
parseRow(scanner, rows) {
const nextToken = scanner.nextNonSpaceToken;
if (!nextToken) {
return false;
}
const row = this.rowParser.parse(scanner);
if (row === null) {
return false;
}
if (this.parserOptions.ignoreEmpty && RowParser_1.RowParser.isEmptyRow(row)) {
return true;
}
rows.push(row);
return true;
}
}
exports.Parser = Parser;
//# sourceMappingURL=Parser.js.map
\ No newline at end of file
{"version":3,"file":"Parser.js","sourceRoot":"","sources":["../../../src/parser/Parser.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,2CAAwC;AAGxC,mCAAgC;AAMhC,MAAa,MAAM;IAcf,YAAmB,aAA4B;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS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,CAAC,cAAc,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE;gBAChD,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;gBACzC,IAAI,MAAM,KAAK,IAAI,EAAE;oBACjB,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC;iBACjD;gBACD,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;oBAC5B,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC;iBACjD;gBACD,OAAO,CAAC,gBAAgB,EAAE,CAAC;aAC9B;iBAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;gBACtC,MAAM;aACT;SACJ;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;IAEO,QAAQ,CAAC,OAAgB,EAAE,IAAgB;QAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC;QAC5C,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,IAAI,EAAE;YACd,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,IAAI,qBAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC7D,OAAO,IAAI,CAAC;SACf;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA3ED,wBA2EC"}
\ No newline at end of file
import { Scanner } from './Scanner';
import { ParserOptions } from '../ParserOptions';
import { RowArray } from '../types';
export declare class RowParser {
static isEmptyRow(row: RowArray): boolean;
private readonly parserOptions;
private readonly columnParser;
constructor(parserOptions: ParserOptions);
parse(scanner: Scanner): RowArray | null;
private getStartToken;
private shouldSkipColumnParse;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RowParser = void 0;
const column_1 = require("./column");
const Token_1 = require("./Token");
const EMPTY_STRING = '';
class RowParser {
constructor(parserOptions) {
this.parserOptions = parserOptions;
this.columnParser = new column_1.ColumnParser(parserOptions);
}
static isEmptyRow(row) {
return row.join(EMPTY_STRING).replace(/\s+/g, EMPTY_STRING) === EMPTY_STRING;
}
parse(scanner) {
const { parserOptions } = this;
const { hasMoreData } = scanner;
const currentScanner = scanner;
const columns = [];
let currentToken = this.getStartToken(currentScanner, columns);
while (currentToken) {
if (Token_1.Token.isTokenRowDelimiter(currentToken)) {
currentScanner.advancePastToken(currentToken);
// if ends with CR and there is more data, keep unparsed due to possible
// coming LF in CRLF
if (!currentScanner.hasMoreCharacters &&
Token_1.Token.isTokenCarriageReturn(currentToken, parserOptions) &&
hasMoreData) {
return null;
}
currentScanner.truncateToCursor();
return columns;
}
if (!this.shouldSkipColumnParse(currentScanner, currentToken, columns)) {
const item = this.columnParser.parse(currentScanner);
if (item === null) {
return null;
}
columns.push(item);
}
currentToken = currentScanner.nextNonSpaceToken;
}
if (!hasMoreData) {
currentScanner.truncateToCursor();
return columns;
}
return null;
}
getStartToken(scanner, columns) {
const currentToken = scanner.nextNonSpaceToken;
if (currentToken !== null && Token_1.Token.isTokenDelimiter(currentToken, this.parserOptions)) {
columns.push('');
return scanner.nextNonSpaceToken;
}
return currentToken;
}
shouldSkipColumnParse(scanner, currentToken, columns) {
const { parserOptions } = this;
if (Token_1.Token.isTokenDelimiter(currentToken, parserOptions)) {
scanner.advancePastToken(currentToken);
// if the delimiter is at the end of a line
const nextToken = scanner.nextCharacterToken;
if (!scanner.hasMoreCharacters || (nextToken !== null && Token_1.Token.isTokenRowDelimiter(nextToken))) {
columns.push('');
return true;
}
if (nextToken !== null && Token_1.Token.isTokenDelimiter(nextToken, parserOptions)) {
columns.push('');
return true;
}
}
return false;
}
}
exports.RowParser = RowParser;
//# sourceMappingURL=RowParser.js.map
\ No newline at end of file
{"version":3,"file":"RowParser.js","sourceRoot":"","sources":["../../../src/parser/RowParser.ts"],"names":[],"mappings":";;;AACA,qCAAwC;AAGxC,mCAA4C;AAE5C,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAa,SAAS;IASlB,YAAmB,aAA4B;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAY,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC;IAXD,MAAM,CAAC,UAAU,CAAC,GAAa;QAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK,YAAY,CAAC;IACjF,CAAC;IAWM,KAAK,CAAC,OAAgB;QACzB,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;QAC/B,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAChC,MAAM,cAAc,GAAG,OAAO,CAAC;QAC/B,MAAM,OAAO,GAAqB,EAAE,CAAC;QACrC,IAAI,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO,YAAY,EAAE;YACjB,IAAI,aAAK,CAAC,mBAAmB,CAAC,YAAY,CAAC,EAAE;gBACzC,cAAc,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAC9C,wEAAwE;gBACxE,oBAAoB;gBACpB,IACI,CAAC,cAAc,CAAC,iBAAiB;oBACjC,aAAK,CAAC,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC;oBACxD,WAAW,EACb;oBACE,OAAO,IAAI,CAAC;iBACf;gBACD,cAAc,CAAC,gBAAgB,EAAE,CAAC;gBAClC,OAAO,OAAO,CAAC;aAClB;YACD,IAAI,CAAC,IAAI,CAAC,qBAAqB,C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AI,CAAC;aACf;YACD,IAAI,SAAS,KAAK,IAAI,IAAI,aAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE;gBACxE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACjB,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA7ED,8BA6EC"}
\ No newline at end of file
import { ParserOptions } from '../ParserOptions';
import { MaybeToken, Token } from './Token';
export interface ScannerArgs {
line: string;
parserOptions: ParserOptions;
hasMoreData: boolean;
cursor?: number;
}
export declare class Scanner {
line: string;
private readonly parserOptions;
lineLength: number;
readonly hasMoreData: boolean;
cursor: number;
constructor(args: ScannerArgs);
get hasMoreCharacters(): boolean;
get nextNonSpaceToken(): MaybeToken;
get nextCharacterToken(): MaybeToken;
get lineFromCursor(): string;
advancePastLine(): Scanner | null;
advanceTo(cursor: number): Scanner;
advanceToToken(token: Token): Scanner;
advancePastToken(token: Token): Scanner;
truncateToCursor(): Scanner;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Scanner = void 0;
const Token_1 = require("./Token");
const ROW_DELIMITER = /((?:\r\n)|\n|\r)/;
class Scanner {
constructor(args) {
this.cursor = 0;
this.line = args.line;
this.lineLength = this.line.length;
this.parserOptions = args.parserOptions;
this.hasMoreData = args.hasMoreData;
this.cursor = args.cursor || 0;
}
get hasMoreCharacters() {
return this.lineLength > this.cursor;
}
get nextNonSpaceToken() {
const { lineFromCursor } = this;
const regex = this.parserOptions.NEXT_TOKEN_REGEXP;
if (lineFromCursor.search(regex) === -1) {
return null;
}
const match = regex.exec(lineFromCursor);
if (match == null) {
return null;
}
const token = match[1];
const startCursor = this.cursor + (match.index || 0);
return new Token_1.Token({
token,
startCursor,
endCursor: startCursor + token.length - 1,
});
}
get nextCharacterToken() {
const { cursor, lineLength } = this;
if (lineLength <= cursor) {
return null;
}
return new Token_1.Token({
token: this.line[cursor],
startCursor: cursor,
endCursor: cursor,
});
}
get lineFromCursor() {
return this.line.substr(this.cursor);
}
advancePastLine() {
const match = ROW_DELIMITER.exec(this.lineFromCursor);
if (!match) {
if (this.hasMoreData) {
return null;
}
this.cursor = this.lineLength;
return this;
}
this.cursor += (match.index || 0) + match[0].length;
return this;
}
advanceTo(cursor) {
this.cursor = cursor;
return this;
}
advanceToToken(token) {
this.cursor = token.startCursor;
return this;
}
advancePastToken(token) {
this.cursor = token.endCursor + 1;
return this;
}
truncateToCursor() {
this.line = this.lineFromCursor;
this.lineLength = this.line.length;
this.cursor = 0;
return this;
}
}
exports.Scanner = Scanner;
//# sourceMappingURL=Scanner.js.map
\ No newline at end of file
{"version":3,"file":"Scanner.js","sourceRoot":"","sources":["../../../src/parser/Scanner.ts"],"names":[],"mappings":";;;AACA,mCAA4C;AAE5C,MAAM,aAAa,GAAG,kBAAkB,CAAC;AASzC,MAAa,OAAO;IAWhB,YAAmB,IAAiB;QAF7B,WAAM,GAAG,CAAC,CAAC;QAGd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,CAAC;IAED,IAAW,iBAAiB;QACxB,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC;QACnD,IAAI,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;YACrC,OAAO,IAAI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D,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,cAAc,CAAC,KAAY;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,gBAAgB,CAAC,KAAY;QAChC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,gBAAgB;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA5FD,0BA4FC"}
\ No newline at end of file
import { ParserOptions } from '../ParserOptions';
export declare type MaybeToken = Token | null;
export interface TokenArgs {
token: string;
startCursor: number;
endCursor: number;
}
export declare class Token {
static isTokenRowDelimiter(token: Token): boolean;
static isTokenCarriageReturn(token: Token, parserOptions: ParserOptions): boolean;
static isTokenComment(token: Token, parserOptions: ParserOptions): boolean;
static isTokenEscapeCharacter(token: Token, parserOptions: ParserOptions): boolean;
static isTokenQuote(token: Token, parserOptions: ParserOptions): boolean;
static isTokenDelimiter(token: Token, parserOptions: ParserOptions): boolean;
readonly token: string;
readonly startCursor: number;
readonly endCursor: number;
constructor(tokenArgs: TokenArgs);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Token = void 0;
class Token {
constructor(tokenArgs) {
this.token = tokenArgs.token;
this.startCursor = tokenArgs.startCursor;
this.endCursor = tokenArgs.endCursor;
}
static isTokenRowDelimiter(token) {
const content = token.token;
return content === '\r' || content === '\n' || content === '\r\n';
}
static isTokenCarriageReturn(token, parserOptions) {
return token.token === parserOptions.carriageReturn;
}
static isTokenComment(token, parserOptions) {
return parserOptions.supportsComments && !!token && token.token === parserOptions.comment;
}
static isTokenEscapeCharacter(token, parserOptions) {
return token.token === parserOptions.escapeChar;
}
static isTokenQuote(token, parserOptions) {
return token.token === parserOptions.quote;
}
static isTokenDelimiter(token, parserOptions) {
return token.token === parserOptions.delimiter;
}
}
exports.Token = Token;
//# sourceMappingURL=Token.js.map
\ No newline at end of file
{"version":3,"file":"Token.js","sourceRoot":"","sources":["../../../src/parser/Token.ts"],"names":[],"mappings":";;;AAUA,MAAa,KAAK;IAgCd,YAAmB,SAAoB;QACnC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;IACzC,CAAC;IAnCM,MAAM,CAAC,mBAAmB,CAAC,KAAY;QAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC;QAC5B,OAAO,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,CAAC;IACtE,CAAC;IAEM,MAAM,CAAC,qBAAqB,CAAC,KAAY,EAAE,aAA4B;QAC1E,OAAO,KAAK,CAAC,KAAK,KAAK,aAAa,CAAC,cAAc,CAAC;IACxD,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,KAAY,EAAE,aAA4B;QACnE,OAAO,aAAa,CAAC,gBAAgB,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,aAAa,CAAC,OAAO,CAAC;IAC9F,CAAC;IAEM,MAAM,CAAC,sBAAsB,CAAC,KAAY,EAAE,aAA4B;QAC3E,OAAO,KAAK,CAAC,KAAK,KAAK,aAAa,CAAC,UAAU,CAAC;IACpD,CAAC;IAEM,MAAM,CAAC,YAAY,CAAC,KAAY,EAAE,aAA4B;QACjE,OAAO,KAAK,CAAC,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC;IAC/C,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,KAAY,EAAE,aAA4B;QACrE,OAAO,KAAK,CAAC,KAAK,KAAK,aAAa,CAAC,SAAS,CAAC;IACnD,CAAC;CAaJ;AArCD,sBAqCC"}
\ No newline at end of file
import { ParserOptions } from '../../ParserOptions';
export declare class ColumnFormatter {
readonly format: (col: string) => string;
constructor(parserOptions: ParserOptions);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ColumnFormatter = void 0;
class ColumnFormatter {
constructor(parserOptions) {
if (parserOptions.trim) {
this.format = (col) => col.trim();
}
else if (parserOptions.ltrim) {
this.format = (col) => col.trimLeft();
}
else if (parserOptions.rtrim) {
this.format = (col) => col.trimRight();
}
else {
this.format = (col) => col;
}
}
}
exports.ColumnFormatter = ColumnFormatter;
//# sourceMappingURL=ColumnFormatter.js.map
\ No newline at end of file
{"version":3,"file":"ColumnFormatter.js","sourceRoot":"","sources":["../../../../src/parser/column/ColumnFormatter.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAGxB,YAAmB,aAA4B;QAC3C,IAAI,aAAa,CAAC,IAAI,EAAE;YACpB,IAAI,CAAC,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACrD;aAAM,IAAI,aAAa,CAAC,KAAK,EAAE;YAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;SACzD;aAAM,IAAI,aAAa,CAAC,KAAK,EAAE;YAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;SAC1D;aAAM;YACH,IAAI,CAAC,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC;SAC9C;IACL,CAAC;CACJ;AAdD,0CAcC"}
\ No newline at end of file
import { ParserOptions } from '../../ParserOptions';
import { NonQuotedColumnParser } from './NonQuotedColumnParser';
import { QuotedColumnParser } from './QuotedColumnParser';
import { Scanner } from '../Scanner';
export declare class ColumnParser {
private readonly parserOptions;
readonly nonQuotedColumnParser: NonQuotedColumnParser;
readonly quotedColumnParser: QuotedColumnParser;
constructor(parserOptions: ParserOptions);
parse(scanner: Scanner): string | null;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ColumnParser = void 0;
const NonQuotedColumnParser_1 = require("./NonQuotedColumnParser");
const QuotedColumnParser_1 = require("./QuotedColumnParser");
const Token_1 = require("../Token");
class ColumnParser {
constructor(parserOptions) {
this.parserOptions = parserOptions;
this.quotedColumnParser = new QuotedColumnParser_1.QuotedColumnParser(parserOptions);
this.nonQuotedColumnParser = new NonQuotedColumnParser_1.NonQuotedColumnParser(parserOptions);
}
parse(scanner) {
const { nextNonSpaceToken } = scanner;
if (nextNonSpaceToken !== null && Token_1.Token.isTokenQuote(nextNonSpaceToken, this.parserOptions)) {
scanner.advanceToToken(nextNonSpaceToken);
return this.quotedColumnParser.parse(scanner);
}
return this.nonQuotedColumnParser.parse(scanner);
}
}
exports.ColumnParser = ColumnParser;
//# sourceMappingURL=ColumnParser.js.map
\ No newline at end of file
{"version":3,"file":"ColumnParser.js","sourceRoot":"","sources":["../../../../src/parser/column/ColumnParser.ts"],"names":[],"mappings":";;;AACA,mEAAgE;AAChE,6DAA0D;AAE1D,oCAAiC;AAEjC,MAAa,YAAY;IAOrB,YAAmB,aAA4B;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,kBAAkB,GAAG,IAAI,uCAAkB,CAAC,aAAa,CAAC,CAAC;QAChE,IAAI,CAAC,qBAAqB,GAAG,IAAI,6CAAqB,CAAC,aAAa,CAAC,CAAC;IAC1E,CAAC;IAEM,KAAK,CAAC,OAAgB;QACzB,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;QACtC,IAAI,iBAAiB,KAAK,IAAI,IAAI,aAAK,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE;YACzF,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACjD;QACD,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;CACJ;AArBD,oCAqBC"}
\ No newline at end of file
import { ParserOptions } from '../../ParserOptions';
import { Scanner } from '../Scanner';
export declare class NonQuotedColumnParser {
private readonly parserOptions;
private readonly columnFormatter;
constructor(parserOptions: ParserOptions);
parse(scanner: Scanner): string | null;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NonQuotedColumnParser = void 0;
const ColumnFormatter_1 = require("./ColumnFormatter");
const Token_1 = require("../Token");
class NonQuotedColumnParser {
constructor(parserOptions) {
this.parserOptions = parserOptions;
this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
}
parse(scanner) {
if (!scanner.hasMoreCharacters) {
return null;
}
const { parserOptions } = this;
const characters = [];
let nextToken = scanner.nextCharacterToken;
for (; nextToken; nextToken = scanner.nextCharacterToken) {
if (Token_1.Token.isTokenDelimiter(nextToken, parserOptions) || Token_1.Token.isTokenRowDelimiter(nextToken)) {
break;
}
characters.push(nextToken.token);
scanner.advancePastToken(nextToken);
}
return this.columnFormatter.format(characters.join(''));
}
}
exports.NonQuotedColumnParser = NonQuotedColumnParser;
//# sourceMappingURL=NonQuotedColumnParser.js.map
\ No newline at end of file
{"version":3,"file":"NonQuotedColumnParser.js","sourceRoot":"","sources":["../../../../src/parser/column/NonQuotedColumnParser.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AAEpD,oCAAiC;AAEjC,MAAa,qBAAqB;IAK9B,YAAmB,aAA4B;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,CAAC,aAAa,CAAC,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,OAAgB;QACzB,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAC5B,OAAO,IAAI,CAAC;SACf;QACD,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;QAC/B,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC;QAC3C,OAAO,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,kBAAkB,EAAE;YACtD,IAAI,aAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,IAAI,aAAK,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE;gBAC1F,MAAM;aACT;YACD,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACjC,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;SACvC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5D,CAAC;CACJ;AA1BD,sDA0BC"}
\ No newline at end of file
import { ParserOptions } from '../../ParserOptions';
import { Scanner } from '../Scanner';
export declare class QuotedColumnParser {
private readonly parserOptions;
private readonly columnFormatter;
constructor(parserOptions: ParserOptions);
parse(scanner: Scanner): string | null;
private gatherDataBetweenQuotes;
private checkForMalformedColumn;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuotedColumnParser = void 0;
const ColumnFormatter_1 = require("./ColumnFormatter");
const Token_1 = require("../Token");
class QuotedColumnParser {
constructor(parserOptions) {
this.parserOptions = parserOptions;
this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
}
parse(scanner) {
if (!scanner.hasMoreCharacters) {
return null;
}
const originalCursor = scanner.cursor;
const { foundClosingQuote, col } = this.gatherDataBetweenQuotes(scanner);
if (!foundClosingQuote) {
// reset the cursor to the original
scanner.advanceTo(originalCursor);
// if we didnt find a closing quote but we potentially have more data then skip the parsing
// and return the original scanner.
if (!scanner.hasMoreData) {
throw new Error(`Parse Error: missing closing: '${this.parserOptions.quote || ''}' in line: at '${scanner.lineFromCursor.replace(/[\r\n]/g, "\\n'")}'`);
}
return null;
}
this.checkForMalformedColumn(scanner);
return col;
}
gatherDataBetweenQuotes(scanner) {
const { parserOptions } = this;
let foundStartingQuote = false;
let foundClosingQuote = false;
const characters = [];
let nextToken = scanner.nextCharacterToken;
for (; !foundClosingQuote && nextToken !== null; nextToken = scanner.nextCharacterToken) {
const isQuote = Token_1.Token.isTokenQuote(nextToken, parserOptions);
// ignore first quote
if (!foundStartingQuote && isQuote) {
foundStartingQuote = true;
}
else if (foundStartingQuote) {
if (Token_1.Token.isTokenEscapeCharacter(nextToken, parserOptions)) {
// advance past the escape character so we can get the next one in line
scanner.advancePastToken(nextToken);
const tokenFollowingEscape = scanner.nextCharacterToken;
// if the character following the escape is a quote character then just add
// the quote and advance to that character
if (tokenFollowingEscape !== null &&
(Token_1.Token.isTokenQuote(tokenFollowingEscape, parserOptions) ||
Token_1.Token.isTokenEscapeCharacter(tokenFollowingEscape, parserOptions))) {
characters.push(tokenFollowingEscape.token);
nextToken = tokenFollowingEscape;
}
else if (isQuote) {
// if the escape is also a quote then we found our closing quote and finish early
foundClosingQuote = true;
}
else {
// other wise add the escape token to the characters since it wast escaping anything
characters.push(nextToken.token);
}
}
else if (isQuote) {
// we found our closing quote!
foundClosingQuote = true;
}
else {
// add the token to the characters
characters.push(nextToken.token);
}
}
scanner.advancePastToken(nextToken);
}
return { col: this.columnFormatter.format(characters.join('')), foundClosingQuote };
}
checkForMalformedColumn(scanner) {
const { parserOptions } = this;
const { nextNonSpaceToken } = scanner;
if (nextNonSpaceToken) {
const isNextTokenADelimiter = Token_1.Token.isTokenDelimiter(nextNonSpaceToken, parserOptions);
const isNextTokenARowDelimiter = Token_1.Token.isTokenRowDelimiter(nextNonSpaceToken);
if (!(isNextTokenADelimiter || isNextTokenARowDelimiter)) {
// if the final quote was NOT followed by a column (,) or row(\n) delimiter then its a bad column
// tldr: only part of the column was quoted
const linePreview = scanner.lineFromCursor.substr(0, 10).replace(/[\r\n]/g, "\\n'");
throw new Error(`Parse Error: expected: '${parserOptions.escapedDelimiter}' OR new line got: '${nextNonSpaceToken.token}'. at '${linePreview}`);
}
scanner.advanceToToken(nextNonSpaceToken);
}
else if (!scanner.hasMoreData) {
scanner.advancePastLine();
}
}
}
exports.QuotedColumnParser = QuotedColumnParser;
//# sourceMappingURL=QuotedColumnParser.js.map
\ No newline at end of file
{"version":3,"file":"QuotedColumnParser.js","sourceRoot":"","sources":["../../../../src/parser/column/QuotedColumnParser.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAGpD,oCAAiC;AAOjC,MAAa,kBAAkB;IAK3B,YAAmB,aAA4B;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,CAAC,aAAa,CAAC,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,OAAgB;QACzB,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAC5B,OAAO,IAAI,CAAC;SACf;QACD,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;QACtC,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACzE,IAAI,CAAC,iBAAiB,EAAE;YACpB,mCAAmC;YACnC,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;YAClC,2FAA2F;YAC3F,mCAAmC;YACnC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;gBACtB,MAAM,IAAI,KAAK,CACX,kCACI,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,EAChC,k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CAAC;aACL;YACD,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;SAC7C;aAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAC7B,OAAO,CAAC,eAAe,EAAE,CAAC;SAC7B;IACL,CAAC;CACJ;AAlGD,gDAkGC"}
\ No newline at end of file
export { ColumnParser } from './ColumnParser';
export { NonQuotedColumnParser } from './NonQuotedColumnParser';
export { QuotedColumnParser } from './QuotedColumnParser';
export { ColumnFormatter } from './ColumnFormatter';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ColumnFormatter = exports.QuotedColumnParser = exports.NonQuotedColumnParser = exports.ColumnParser = void 0;
var ColumnParser_1 = require("./ColumnParser");
Object.defineProperty(exports, "ColumnParser", { enumerable: true, get: function () { return ColumnParser_1.ColumnParser; } });
var NonQuotedColumnParser_1 = require("./NonQuotedColumnParser");
Object.defineProperty(exports, "NonQuotedColumnParser", { enumerable: true, get: function () { return NonQuotedColumnParser_1.NonQuotedColumnParser; } });
var QuotedColumnParser_1 = require("./QuotedColumnParser");
Object.defineProperty(exports, "QuotedColumnParser", { enumerable: true, get: function () { return QuotedColumnParser_1.QuotedColumnParser; } });
var ColumnFormatter_1 = require("./ColumnFormatter");
Object.defineProperty(exports, "ColumnFormatter", { enumerable: true, get: function () { return ColumnFormatter_1.ColumnFormatter; } });
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/parser/column/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA"}
\ No newline at end of file
export { Parser } from './Parser';
export { RowParser } from './RowParser';
export { Scanner } from './Scanner';
export { Token, MaybeToken } from './Token';
export { ColumnParser, NonQuotedColumnParser, QuotedColumnParser } from './column';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuotedColumnParser = exports.NonQuotedColumnParser = exports.ColumnParser = exports.Token = exports.Scanner = exports.RowParser = exports.Parser = void 0;
var Parser_1 = require("./Parser");
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return Parser_1.Parser; } });
var RowParser_1 = require("./RowParser");
Object.defineProperty(exports, "RowParser", { enumerable: true, get: function () { return RowParser_1.RowParser; } });
var Scanner_1 = require("./Scanner");
Object.defineProperty(exports, "Scanner", { enumerable: true, get: function () { return Scanner_1.Scanner; } });
var Token_1 = require("./Token");
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return Token_1.Token; } });
var column_1 = require("./column");
Object.defineProperty(exports, "ColumnParser", { enumerable: true, get: function () { return column_1.ColumnParser; } });
Object.defineProperty(exports, "NonQuotedColumnParser", { enumerable: true, get: function () { return column_1.NonQuotedColumnParser; } });
Object.defineProperty(exports, "QuotedColumnParser", { enumerable: true, get: function () { return column_1.QuotedColumnParser; } });
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/parser/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,iCAA4C;AAAnC,8FAAA,KAAK,OAAA;AACd,mCAAmF;AAA1E,sGAAA,YAAY,OAAA;AAAE,+GAAA,qBAAqB,OAAA;AAAE,4GAAA,kBAAkB,OAAA"}
\ No newline at end of file
import { ParserOptions } from '../ParserOptions';
import { HeaderArray, Row, RowArray, RowValidatorCallback } from '../types';
export declare class HeaderTransformer<O extends Row> {
private readonly parserOptions;
headers: HeaderArray | null;
private receivedHeaders;
private readonly shouldUseFirstRow;
private processedFirstRow;
private headersLength;
private readonly headersTransform?;
constructor(parserOptions: ParserOptions);
transform(row: RowArray, cb: RowValidatorCallback<O>): void;
private shouldMapRow;
private processRow;
private mapHeaders;
private setHeaders;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment