convert-csv-to-json 4.14.0 → 4.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci-cd.yml +1 -1
- package/docs/.nojekyll +0 -0
- package/docs/README.md +44 -0
- package/docs/demo.bundle.js +1708 -0
- package/docs/index.html +536 -0
- package/eslint.config.js +1 -1
- package/package.json +5 -1
- package/docs/api/BrowserApi.html +0 -2662
- package/docs/api/BrowserApiError.html +0 -669
- package/docs/api/ConfigurationError.html +0 -745
- package/docs/api/CsvFormatError.html +0 -677
- package/docs/api/CsvParsingError.html +0 -511
- package/docs/api/CsvToJson.html +0 -3367
- package/docs/api/CsvToJsonAsync.html +0 -2880
- package/docs/api/FileOperationError.html +0 -382
- package/docs/api/FileUtils.html +0 -1150
- package/docs/api/InputValidationError.html +0 -407
- package/docs/api/JsonUtil.html +0 -452
- package/docs/api/JsonValidationError.html +0 -357
- package/docs/api/StringUtils.html +0 -833
- package/docs/api/global.html +0 -3498
- package/docs/api/index.html +0 -414
- package/docs/api/index.js.html +0 -447
- package/docs/api/scripts/app.min.js +0 -1
- package/docs/api/scripts/linenumber.js +0 -26
- package/docs/api/scripts/search.js +0 -39
- package/docs/api/src_browserApi.js.html +0 -362
- package/docs/api/src_csvToJson.js.html +0 -696
- package/docs/api/src_csvToJsonAsync.js.html +0 -335
- package/docs/api/src_util_errors.js.html +0 -472
- package/docs/api/src_util_fileUtils.js.html +0 -238
- package/docs/api/src_util_jsonUtils.js.html +0 -166
- package/docs/api/src_util_stringUtils.js.html +0 -306
- package/docs/api/styles/app.min.css +0 -1
- package/docs/api/styles/iframe.css +0 -13
- package/docs/api/styles/prettify-jsdoc.css +0 -111
- package/docs/api/styles/prettify-tomorrow.css +0 -132
- package/docs/api/styles/reset.css +0 -44
package/docs/api/index.js.html
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<!DOCTYPE html>
|
|
4
|
-
<html lang="en">
|
|
5
|
-
|
|
6
|
-
<head>
|
|
7
|
-
|
|
8
|
-
<meta charset="utf-8">
|
|
9
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
-
<title> index.js</title>
|
|
11
|
-
|
|
12
|
-
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
|
13
|
-
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
|
14
|
-
<script src="./build/entry.js"></script>
|
|
15
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
16
|
-
<!--[if lt IE 9]>
|
|
17
|
-
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
18
|
-
<![endif]-->
|
|
19
|
-
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
|
20
|
-
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
|
21
|
-
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
|
22
|
-
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
|
23
|
-
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
|
24
|
-
<link type="text/css" rel="stylesheet" href="./node_modules/better-docs/css/better-docs.css">
|
|
25
|
-
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</head>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<body class="layout small-header">
|
|
33
|
-
<div id="stickyNavbarOverlay"></div>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<div class="top-nav">
|
|
37
|
-
<div class="inner">
|
|
38
|
-
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
|
39
|
-
<span aria-hidden="true"></span>
|
|
40
|
-
<span aria-hidden="true"></span>
|
|
41
|
-
<span aria-hidden="true"></span>
|
|
42
|
-
</a>
|
|
43
|
-
<div class="logo">
|
|
44
|
-
|
|
45
|
-
<a class="image" href="index.html">
|
|
46
|
-
<img src="https://raw.githubusercontent.com/iuccio/CSVtoJSON/master/CSVtoJSON.png" alt="logo">
|
|
47
|
-
</a>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<a href="index.html">
|
|
51
|
-
<h1 class="navbar-item">Convert CSV to JSON</h1>
|
|
52
|
-
</a>
|
|
53
|
-
|
|
54
|
-
</div>
|
|
55
|
-
<div class="menu">
|
|
56
|
-
|
|
57
|
-
<div class="navigation">
|
|
58
|
-
<a
|
|
59
|
-
href="index.html"
|
|
60
|
-
class="link"
|
|
61
|
-
>
|
|
62
|
-
Documentation
|
|
63
|
-
</a>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<a
|
|
68
|
-
class="link user-link "
|
|
69
|
-
href="https://github.com/iuccio/CSVtoJSON"
|
|
70
|
-
>
|
|
71
|
-
GitHub
|
|
72
|
-
</a>
|
|
73
|
-
|
|
74
|
-
<a
|
|
75
|
-
class="link user-link "
|
|
76
|
-
href="https://www.npmjs.com/package/convert-csv-to-json"
|
|
77
|
-
>
|
|
78
|
-
NPM
|
|
79
|
-
</a>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
<div id="main">
|
|
88
|
-
<div
|
|
89
|
-
class="sidebar "
|
|
90
|
-
id="sidebarNav"
|
|
91
|
-
>
|
|
92
|
-
|
|
93
|
-
<nav>
|
|
94
|
-
|
|
95
|
-
<h2><a href="index.html">Documentation</a></h2><div class="category"></div><div class="category"><h2>1-Core API</h2><h3>Global</h3><ul><li><a href="global.html#asciiEncoding">asciiEncoding</a></li><li><a href="global.html#base64Encoding">base64Encoding</a></li><li><a href="global.html#csvStringToJson">csvStringToJson</a></li><li><a href="global.html#csvStringToJsonStringified">csvStringToJsonStringified</a></li><li><a href="global.html#csvToJsonAsync">csvToJsonAsync</a></li><li><a href="global.html#customEncoding">customEncoding</a></li><li><a href="global.html#fieldDelimiter">fieldDelimiter</a></li><li><a href="global.html#formatValueByType">formatValueByType</a></li><li><a href="global.html#generateJsonFileFromCsv">generateJsonFileFromCsv</a></li><li><a href="global.html#getJsonFromCsv">getJsonFromCsv</a></li><li><a href="global.html#hexEncoding">hexEncoding</a></li><li><a href="global.html#indexHeader">indexHeader</a></li><li><a href="global.html#latin1Encoding">latin1Encoding</a></li><li><a href="global.html#mapRows">mapRows</a></li><li><a href="global.html#parseSubArray">parseSubArray</a></li><li><a href="global.html#supportQuotedField">supportQuotedField</a></li><li><a href="global.html#trimHeaderFieldWhiteSpace">trimHeaderFieldWhiteSpace</a></li><li><a href="global.html#ucs2Encoding">ucs2Encoding</a></li><li><a href="global.html#utf16leEncoding">utf16leEncoding</a></li><li><a href="global.html#utf8Encoding">utf8Encoding</a></li></ul></div><div class="category"><h2>2-Sync</h2><h3>Classes</h3><ul><li><a href="CsvToJson.html">CsvToJson</a></li></ul></div><div class="category"><h2>3-Async</h2><h3>Classes</h3><ul><li><a href="CsvToJsonAsync.html">CsvToJsonAsync</a></li></ul></div><div class="category"><h2>4-Browser</h2><h3>Classes</h3><ul><li><a href="BrowserApi.html">BrowserApi</a></li></ul></div><div class="category"><h2>Error Classes</h2><h3>Classes</h3><ul><li><a href="BrowserApiError.html">BrowserApiError</a></li><li><a href="ConfigurationError.html">ConfigurationError</a></li><li><a href="CsvFormatError.html">CsvFormatError</a></li><li><a href="CsvParsingError.html">CsvParsingError</a></li><li><a href="FileOperationError.html">FileOperationError</a></li><li><a href="InputValidationError.html">InputValidationError</a></li><li><a href="JsonValidationError.html">JsonValidationError</a></li></ul></div><div class="category"><h2>Utilities</h2><h3>Classes</h3><ul><li><a href="FileUtils.html">FileUtils</a></li><li><a href="JsonUtil.html">JsonUtil</a></li><li><a href="StringUtils.html">StringUtils</a></li></ul></div>
|
|
96
|
-
|
|
97
|
-
</nav>
|
|
98
|
-
</div>
|
|
99
|
-
<div class="core" id="main-content-wrapper">
|
|
100
|
-
<div class="content">
|
|
101
|
-
<header class="page-title">
|
|
102
|
-
<p>Source</p>
|
|
103
|
-
<h1>index.js</h1>
|
|
104
|
-
</header>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<section>
|
|
111
|
-
<article>
|
|
112
|
-
<pre class="prettyprint source linenums"><code>/**
|
|
113
|
-
* CsvToJson - CSV to JSON converter library
|
|
114
|
-
* Main entry point providing chainable API for CSV parsing with multiple configuration options
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
/* globals FileOperationError, CsvFormatError, JsonValidationError, InputValidationError */
|
|
118
|
-
|
|
119
|
-
"use strict";
|
|
120
|
-
|
|
121
|
-
let csvToJson = require("./src/csvToJson.js");
|
|
122
|
-
|
|
123
|
-
const encodingOps = {
|
|
124
|
-
utf8: 'utf8',
|
|
125
|
-
ucs2: 'ucs2',
|
|
126
|
-
utf16le: 'utf16le',
|
|
127
|
-
latin1: 'latin1',
|
|
128
|
-
ascii: 'ascii',
|
|
129
|
-
base64: 'base64',
|
|
130
|
-
hex: 'hex'
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Enable or disable automatic type formatting for values
|
|
135
|
-
* Converts numeric strings to numbers, 'true'/'false' to booleans
|
|
136
|
-
* @category 1-Core API
|
|
137
|
-
* @param {boolean} active - Whether to format values by type (default: true)
|
|
138
|
-
* @returns {object} Module context for method chaining
|
|
139
|
-
*/
|
|
140
|
-
exports.formatValueByType = function (active = true) {
|
|
141
|
-
csvToJson.formatValueByType(active);
|
|
142
|
-
return this;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Enable or disable support for RFC 4180 quoted fields
|
|
147
|
-
* When enabled, fields wrapped in double quotes can contain delimiters and newlines
|
|
148
|
-
* @category 1-Core API
|
|
149
|
-
* @param {boolean} active - Whether to support quoted fields (default: false)
|
|
150
|
-
* @returns {object} Module context for method chaining
|
|
151
|
-
*/
|
|
152
|
-
exports.supportQuotedField = function (active = false) {
|
|
153
|
-
csvToJson.supportQuotedField(active);
|
|
154
|
-
return this;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Set the field delimiter character used to separate CSV fields
|
|
158
|
-
* @category 1-Core API
|
|
159
|
-
* @param {string} delimiter - Character(s) to use as field separator (default: ',')
|
|
160
|
-
* @returns {object} Module context for method chaining
|
|
161
|
-
*/
|
|
162
|
-
exports.fieldDelimiter = function (delimiter) {
|
|
163
|
-
csvToJson.fieldDelimiter(delimiter);
|
|
164
|
-
return this;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Configure whitespace handling in CSV header field names
|
|
169
|
-
* When active, removes all whitespace from header names (e.g., "My Name" → "MyName")
|
|
170
|
-
* When inactive, only trims leading and trailing whitespace
|
|
171
|
-
* @category 1-Core API
|
|
172
|
-
* @param {boolean} active - Whether to remove all whitespace from headers (default: false)
|
|
173
|
-
* @returns {object} Module context for method chaining
|
|
174
|
-
*/
|
|
175
|
-
exports.trimHeaderFieldWhiteSpace = function (active = false) {
|
|
176
|
-
csvToJson.trimHeaderFieldWhiteSpace(active);
|
|
177
|
-
return this;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Set the row index where CSV headers are located
|
|
182
|
-
* Use this if headers are not on the first line (row 0)
|
|
183
|
-
* @category 1-Core API
|
|
184
|
-
* @param {number} index - Zero-based row index containing headers
|
|
185
|
-
* @returns {object} Module context for method chaining
|
|
186
|
-
*/
|
|
187
|
-
exports.indexHeader = function (index) {
|
|
188
|
-
csvToJson.indexHeader(index);
|
|
189
|
-
return this;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Configure sub-array parsing for special field values
|
|
194
|
-
* Fields bracketed by delimiter and containing separator are parsed into arrays
|
|
195
|
-
* @category 1-Core API
|
|
196
|
-
* @param {string} delimiter - Bracket character (default: '*')
|
|
197
|
-
* @param {string} separator - Item separator within brackets (default: ',')
|
|
198
|
-
* @returns {object} Module context for method chaining
|
|
199
|
-
* @example
|
|
200
|
-
* // Input field: "*val1,val2,val3*"
|
|
201
|
-
* // Output array: ["val1", "val2", "val3"]
|
|
202
|
-
* csvToJson.parseSubArray('*', ',')
|
|
203
|
-
*/
|
|
204
|
-
exports.parseSubArray = function (delimiter, separator) {
|
|
205
|
-
csvToJson.parseSubArray(delimiter, separator);
|
|
206
|
-
return this;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Set custom file encoding for reading CSV files
|
|
211
|
-
* Useful for non-UTF8 encoded files
|
|
212
|
-
* @category 1-Core API
|
|
213
|
-
* @param {string} encoding - Node.js supported encoding (e.g., 'utf8', 'latin1', 'ascii')
|
|
214
|
-
* @returns {object} Module context for method chaining
|
|
215
|
-
*/
|
|
216
|
-
exports.customEncoding = function (encoding) {
|
|
217
|
-
csvToJson.encoding = encoding;
|
|
218
|
-
return this;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Set UTF-8 encoding (default encoding)
|
|
223
|
-
* @category 1-Core API
|
|
224
|
-
* @returns {object} Module context for method chaining
|
|
225
|
-
*/
|
|
226
|
-
exports.utf8Encoding = function utf8Encoding() {
|
|
227
|
-
csvToJson.encoding = encodingOps.utf8;
|
|
228
|
-
return this;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Set UCS-2 encoding for reading files
|
|
233
|
-
* @category 1-Core API
|
|
234
|
-
* @returns {object} Module context for method chaining
|
|
235
|
-
*/
|
|
236
|
-
exports.ucs2Encoding = function () {
|
|
237
|
-
csvToJson.encoding = encodingOps.ucs2;
|
|
238
|
-
return this;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Set UTF-16 LE encoding for reading files
|
|
243
|
-
* @category 1-Core API
|
|
244
|
-
* @returns {object} Module context for method chaining
|
|
245
|
-
*/
|
|
246
|
-
exports.utf16leEncoding = function () {
|
|
247
|
-
csvToJson.encoding = encodingOps.utf16le;
|
|
248
|
-
return this;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Set Latin-1 (ISO-8859-1) encoding for reading files
|
|
253
|
-
* @category 1-Core API
|
|
254
|
-
* @returns {object} Module context for method chaining
|
|
255
|
-
*/
|
|
256
|
-
exports.latin1Encoding = function () {
|
|
257
|
-
csvToJson.encoding = encodingOps.latin1;
|
|
258
|
-
return this;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Set ASCII encoding for reading files
|
|
263
|
-
* @category 1-Core API
|
|
264
|
-
* @returns {object} Module context for method chaining
|
|
265
|
-
*/
|
|
266
|
-
exports.asciiEncoding = function () {
|
|
267
|
-
csvToJson.encoding = encodingOps.ascii;
|
|
268
|
-
return this;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Set Base64 encoding for reading files
|
|
273
|
-
* @category 1-Core API
|
|
274
|
-
* @returns {object} Module context for method chaining
|
|
275
|
-
*/
|
|
276
|
-
exports.base64Encoding = function () {
|
|
277
|
-
this.csvToJson = encodingOps.base64;
|
|
278
|
-
return this;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Set Hex encoding for reading files
|
|
283
|
-
* @category 1-Core API
|
|
284
|
-
* @returns {object} Module context for method chaining
|
|
285
|
-
*/
|
|
286
|
-
exports.hexEncoding = function () {
|
|
287
|
-
this.csvToJson = encodingOps.hex;
|
|
288
|
-
return this;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Set a mapper function to transform each row after conversion
|
|
293
|
-
* The mapper function receives (row, index) where row is the JSON object
|
|
294
|
-
* and index is the 0-based row number. Return null/undefined to filter out rows.
|
|
295
|
-
* @category 1-Core API
|
|
296
|
-
* @param {function(object, number): (object|null)} mapperFn - Function to transform each row
|
|
297
|
-
* @returns {object} Module context for method chaining
|
|
298
|
-
* @example
|
|
299
|
-
* csvToJson
|
|
300
|
-
* .mapRows((row, idx) => idx % 2 === 0 ? row : null) // Keep every other row
|
|
301
|
-
* .getJsonFromCsv('input.csv')
|
|
302
|
-
*/
|
|
303
|
-
exports.mapRows = function (mapperFn) {
|
|
304
|
-
csvToJson.mapRows(mapperFn);
|
|
305
|
-
return this;
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Parse CSV file and write the parsed JSON to an output file (synchronous)
|
|
310
|
-
* @param {string} inputFileName - Path to input CSV file
|
|
311
|
-
* @param {string} outputFileName - Path to output JSON file
|
|
312
|
-
* @throws {Error} If inputFileName or outputFileName is not defined
|
|
313
|
-
* @throws {FileOperationError} If file operations fail
|
|
314
|
-
* @throws {CsvFormatError} If CSV is malformed
|
|
315
|
-
* @category 1-Core API
|
|
316
|
-
* @example
|
|
317
|
-
* const csvToJson = require('convert-csv-to-json');
|
|
318
|
-
* csvToJson.generateJsonFileFromCsv('input.csv', 'output.json');
|
|
319
|
-
*/
|
|
320
|
-
exports.generateJsonFileFromCsv = function(inputFileName, outputFileName) {
|
|
321
|
-
if (!inputFileName) {
|
|
322
|
-
throw new Error("inputFileName is not defined!!!");
|
|
323
|
-
}
|
|
324
|
-
if (!outputFileName) {
|
|
325
|
-
throw new Error("outputFileName is not defined!!!");
|
|
326
|
-
}
|
|
327
|
-
csvToJson.generateJsonFileFromCsv(inputFileName, outputFileName);
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Parse CSV file and return parsed data as JSON array of objects (synchronous)
|
|
332
|
-
* @param {string} inputFileName - Path to input CSV file
|
|
333
|
-
* @returns {Array<object>} Array of objects representing CSV rows
|
|
334
|
-
* @throws {Error} If inputFileName is not defined
|
|
335
|
-
* @throws {FileOperationError} If file read fails
|
|
336
|
-
* @throws {CsvFormatError} If CSV is malformed
|
|
337
|
-
* @category 1-Core API
|
|
338
|
-
* @example
|
|
339
|
-
* const csvToJson = require('convert-csv-to-json');
|
|
340
|
-
* const rows = csvToJson.getJsonFromCsv('resource/input.csv');
|
|
341
|
-
* console.log(rows);
|
|
342
|
-
*/
|
|
343
|
-
exports.getJsonFromCsv = function(inputFileName) {
|
|
344
|
-
if (!inputFileName) {
|
|
345
|
-
throw new Error("inputFileName is not defined!!!");
|
|
346
|
-
}
|
|
347
|
-
return csvToJson.getJsonFromCsv(inputFileName);
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Parse CSV file asynchronously and return parsed data as JSON array
|
|
352
|
-
* @param {string} inputFileNameOrCsv - Path to file or CSV string
|
|
353
|
-
* @param {object} options - Configuration options
|
|
354
|
-
* @param {boolean} options.raw - If true, treats first param as CSV content; if false, reads from file
|
|
355
|
-
* @returns {Promise<Array<object>>} Promise resolving to array of objects
|
|
356
|
-
* @throws {InputValidationError} If input is invalid
|
|
357
|
-
* @throws {FileOperationError} If file read fails
|
|
358
|
-
* @throws {CsvFormatError} If CSV is malformed
|
|
359
|
-
* @category 1-Core API
|
|
360
|
-
* @example
|
|
361
|
-
* const csvToJson = require('convert-csv-to-json');
|
|
362
|
-
* const data = await csvToJson.getJsonFromCsvAsync('resource/input.csv');
|
|
363
|
-
* console.log(data);
|
|
364
|
-
*/
|
|
365
|
-
const csvToJsonAsync = require('./src/csvToJsonAsync');
|
|
366
|
-
|
|
367
|
-
// Re-export all async API methods
|
|
368
|
-
Object.assign(exports, {
|
|
369
|
-
getJsonFromCsvAsync: function(input, options) {
|
|
370
|
-
return csvToJsonAsync.getJsonFromCsvAsync(input, options);
|
|
371
|
-
},
|
|
372
|
-
csvStringToJsonAsync: function(input, options) {
|
|
373
|
-
return csvToJsonAsync.csvStringToJsonAsync(input, options);
|
|
374
|
-
},
|
|
375
|
-
csvStringToJsonStringifiedAsync: function(input) {
|
|
376
|
-
return csvToJsonAsync.csvStringToJsonStringifiedAsync(input);
|
|
377
|
-
},
|
|
378
|
-
generateJsonFileFromCsvAsync: function(input, output) {
|
|
379
|
-
return csvToJsonAsync.generateJsonFileFromCsv(input, output);
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Parse a CSV string and return as JSON array of objects (synchronous)
|
|
385
|
-
* @param {string} csvString - CSV content as string
|
|
386
|
-
* @returns {Array<object>} Array of objects representing CSV rows
|
|
387
|
-
* @throws {InputValidationError} If csvString is invalid
|
|
388
|
-
* @throws {CsvFormatError} If CSV is malformed
|
|
389
|
-
* @category 1-Core API
|
|
390
|
-
* @example
|
|
391
|
-
* const csvToJson = require('convert-csv-to-json');
|
|
392
|
-
* const rows = csvToJson.csvStringToJson('name,age\nAlice,30');
|
|
393
|
-
* console.log(rows); // [{ name: 'Alice', age: '30' }]
|
|
394
|
-
*/
|
|
395
|
-
exports.csvStringToJson = function(csvString) {
|
|
396
|
-
return csvToJson.csvStringToJson(csvString);
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Parse CSV string and return as stringified JSON (synchronous)
|
|
401
|
-
* @param {string} csvString - CSV content as string
|
|
402
|
-
* @returns {string} JSON stringified array of objects
|
|
403
|
-
* @throws {InputValidationError} If csvString is invalid
|
|
404
|
-
* @throws {CsvFormatError} If CSV is malformed
|
|
405
|
-
* @throws {JsonValidationError} If JSON generation fails
|
|
406
|
-
* @category 1-Core API
|
|
407
|
-
*/
|
|
408
|
-
exports.csvStringToJsonStringified = function(csvString) {
|
|
409
|
-
if (csvString === undefined || csvString === null) {
|
|
410
|
-
throw new Error("csvString is not defined!!!");
|
|
411
|
-
}
|
|
412
|
-
return csvToJson.csvStringToJsonStringified(csvString);
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
exports.browser = require('./src/browserApi');
|
|
418
|
-
</code></pre>
|
|
419
|
-
</article>
|
|
420
|
-
</section>
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
</div>
|
|
426
|
-
|
|
427
|
-
<footer class="footer">
|
|
428
|
-
<div class="content has-text-centered">
|
|
429
|
-
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a></p>
|
|
430
|
-
<p class="sidebar-created-by">
|
|
431
|
-
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
432
|
-
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
433
|
-
</p>
|
|
434
|
-
</div>
|
|
435
|
-
</footer>
|
|
436
|
-
|
|
437
|
-
</div>
|
|
438
|
-
<div id="side-nav" class="side-nav">
|
|
439
|
-
</div>
|
|
440
|
-
</div>
|
|
441
|
-
<script src="scripts/app.min.js"></script>
|
|
442
|
-
<script>PR.prettyPrint();</script>
|
|
443
|
-
<script src="scripts/linenumber.js"> </script>
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
</body>
|
|
447
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";$().ready(function(){});var sidebarIsVisible=!1,toggleSidebar=function(e){var a=!(0<arguments.length&&void 0!==e)||e;$("#sidebarNav").toggleClass("sticky",a),$("#stickyNavbarOverlay").toggleClass("active",a),$("#hamburger").toggleClass("is-active"),sidebarIsVisible=a};$().ready(function(){$("#hamburger").click(function(){toggleSidebar(!sidebarIsVisible)}),$("#stickyNavbarOverlay").click(function(){sidebarIsVisible&&toggleSidebar(!1)})});var OFFSET=150;$().ready(function(){var o=$("#side-nav"),c=[];if($(".vertical-section").length||o.hide(),$(".vertical-section").each(function(e,a){var i=$(a),t=i.find("> h1").text();if(t){o.append($("<h3/>").text(t));var s=$("<ul></ul>");i.find(".members h4.name").each(function(e,a){var i=$(a),t=i.find(".code-name").clone().children().remove().end().text(),n=i.find("a").attr("href"),r=$('<a href="'.concat(n,'" />')).text(t);s.append($("<li></li>").append(r)),c.push({link:r,offset:i.offset().top})}),o.append(s)}else i.find(".members h4.name").each(function(e,a){var i=$(a),t=i.find(".code-name").clone().children().remove().end().text(),n=i.find("a").attr("href"),r=$('<a href="'.concat(n,'" />')).text(t);o.append(r),c.push({link:r,offset:i.offset().top})})}),!$.trim(o.text()))return o.hide();function e(){for(var e=n.scrollTop(),a=!1,i=c.length-1;0<=i;i--){var t=c[i];t.link.removeClass("is-active"),e+OFFSET>=t.offset?a?t.link.addClass("is-past"):(t.link.addClass("is-active"),a=!0):t.link.removeClass("is-past")}}var n=$("#main-content-wrapper");n.on("scroll",e),e(),c.forEach(function(e){e.link.click(function(){n.animate({scrollTop:e.offset-OFFSET+1},500)})})}),$().ready(function(){$("#sidebarNav a").each(function(e,a){var i=$(a).attr("href");window.location.pathname.match("/"+i)&&($(a).addClass("active"),$("#sidebarNav").scrollTop($(a).offset().top-150))})});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*global document */
|
|
2
|
-
|
|
3
|
-
(function() {
|
|
4
|
-
var source = document.getElementsByClassName('prettyprint source linenums');
|
|
5
|
-
var i = 0;
|
|
6
|
-
var lineNumber = 0;
|
|
7
|
-
var lineId;
|
|
8
|
-
var lines;
|
|
9
|
-
var totalLines;
|
|
10
|
-
var anchorHash;
|
|
11
|
-
|
|
12
|
-
if (source && source[0]) {
|
|
13
|
-
anchorHash = document.location.hash.substring(1);
|
|
14
|
-
lines = source[0].getElementsByTagName('li');
|
|
15
|
-
totalLines = lines.length;
|
|
16
|
-
|
|
17
|
-
for (; i < totalLines; i++) {
|
|
18
|
-
lineNumber++;
|
|
19
|
-
lineId = 'line' + lineNumber;
|
|
20
|
-
lines[i].id = lineId;
|
|
21
|
-
if (lineId === anchorHash) {
|
|
22
|
-
lines[i].className += ' selected';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
})();
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
const input = document.querySelector('#search')
|
|
3
|
-
const targets = [ ...document.querySelectorAll('#sidebarNav li')]
|
|
4
|
-
input.addEventListener('keyup', () => {
|
|
5
|
-
// loop over each targets and hide the not corresponding ones
|
|
6
|
-
targets.forEach(target => {
|
|
7
|
-
if (!target.innerText.toLowerCase().includes(input.value.toLowerCase())) {
|
|
8
|
-
target.style.display = 'none'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Detects an empty list
|
|
12
|
-
* Remove the list and the list's title if the list is not displayed
|
|
13
|
-
*/
|
|
14
|
-
const list = [...target.parentNode.childNodes].filter( elem => elem.style.display !== 'none')
|
|
15
|
-
|
|
16
|
-
if (!list.length) {
|
|
17
|
-
target.parentNode.style.display = 'none'
|
|
18
|
-
target.parentNode.previousSibling.style.display = 'none'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Detects empty category
|
|
23
|
-
* Remove the entire category if no item is displayed
|
|
24
|
-
*/
|
|
25
|
-
const category = [...target.parentNode.parentNode.childNodes]
|
|
26
|
-
.filter( elem => elem.tagName !== 'H2' && elem.style.display !== 'none')
|
|
27
|
-
|
|
28
|
-
if (!category.length) {
|
|
29
|
-
target.parentNode.parentNode.style.display = 'none'
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
target.parentNode.style.display = 'block'
|
|
33
|
-
target.parentNode.previousSibling.style.display = 'block'
|
|
34
|
-
target.parentNode.parentNode.style.display = 'block'
|
|
35
|
-
target.style.display = 'block'
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})()
|