convert-csv-to-json 4.13.0 → 4.14.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/api/BrowserApi.html +1255 -1028
- package/docs/api/BrowserApiError.html +326 -179
- package/docs/api/ConfigurationError.html +375 -224
- package/docs/api/CsvFormatError.html +334 -187
- package/docs/api/CsvParsingError.html +259 -132
- package/docs/api/CsvToJson.html +1545 -1314
- package/docs/api/CsvToJsonAsync.html +1356 -1148
- package/docs/api/FileOperationError.html +213 -101
- package/docs/api/FileUtils.html +568 -430
- package/docs/api/InputValidationError.html +229 -115
- package/docs/api/JsonUtil.html +222 -110
- package/docs/api/JsonValidationError.html +197 -87
- package/docs/api/StringUtils.html +833 -0
- package/docs/api/global.html +1537 -1354
- package/docs/api/index.html +114 -26
- package/docs/api/index.js.html +137 -31
- package/docs/api/scripts/app.min.js +1 -0
- package/docs/api/scripts/linenumber.js +10 -9
- package/docs/api/scripts/search.js +39 -0
- package/docs/api/src_browserApi.js.html +120 -29
- package/docs/api/src_csvToJson.js.html +119 -28
- package/docs/api/src_csvToJsonAsync.js.html +118 -27
- package/docs/api/src_util_errors.js.html +126 -28
- package/docs/api/src_util_fileUtils.js.html +117 -26
- package/docs/api/src_util_jsonUtils.js.html +117 -26
- package/docs/api/src_util_stringUtils.js.html +121 -27
- package/docs/api/styles/app.min.css +1 -0
- package/docs/api/styles/iframe.css +13 -0
- package/docs/api/styles/reset.css +44 -0
- package/eslint.config.js +115 -0
- package/index.js +21 -5
- package/jsdoc.json +29 -4
- package/package.json +5 -3
- package/src/browserApi.js +4 -3
- package/src/csvToJson.js +3 -2
- package/src/csvToJsonAsync.js +2 -1
- package/src/util/errors.js +10 -2
- package/src/util/fileUtils.js +1 -0
- package/src/util/jsonUtils.js +1 -0
- package/src/util/stringUtils.js +5 -1
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -48
- package/docs/api/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/api/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/api/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/api/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/api/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/api/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/api/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/api/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/api/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/api/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/api/scripts/prettify/lang-css.js +0 -2
- package/docs/api/scripts/prettify/prettify.js +0 -28
- package/docs/api/styles/jsdoc-default.css +0 -358
|
@@ -1,26 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
<!DOCTYPE html>
|
|
2
4
|
<html lang="en">
|
|
5
|
+
|
|
3
6
|
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title> src/browserApi.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
|
+
|
|
14
28
|
</head>
|
|
15
29
|
|
|
16
|
-
<body>
|
|
17
30
|
|
|
18
|
-
<div id="main">
|
|
19
|
-
|
|
20
|
-
<h1 class="page-title">Source: src/browserApi.js</h1>
|
|
21
31
|
|
|
32
|
+
<body class="layout small-header">
|
|
33
|
+
<div id="stickyNavbarOverlay"></div>
|
|
22
34
|
|
|
23
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>src/browserApi.js</h1>
|
|
104
|
+
</header>
|
|
105
|
+
|
|
106
|
+
|
|
24
107
|
|
|
25
108
|
|
|
26
109
|
|
|
@@ -37,6 +120,7 @@ const { InputValidationError, BrowserApiError } = require('./util/errors');
|
|
|
37
120
|
* Browser-friendly CSV to JSON API
|
|
38
121
|
* Provides methods for parsing CSV strings and File/Blob objects in browser environments
|
|
39
122
|
* Proxies configuration to sync csvToJson instance
|
|
123
|
+
* @category 4-Browser
|
|
40
124
|
*/
|
|
41
125
|
class BrowserApi {
|
|
42
126
|
/**
|
|
@@ -110,7 +194,7 @@ class BrowserApi {
|
|
|
110
194
|
|
|
111
195
|
/**
|
|
112
196
|
* Set a mapper function to transform each row after conversion
|
|
113
|
-
* @param {
|
|
197
|
+
* @param {function(object, number): (object|null)} mapperFn - Function receiving (row, index) that returns transformed row or null to filter
|
|
114
198
|
* @returns {this} For method chaining
|
|
115
199
|
*/
|
|
116
200
|
mapRows(mapperFn) {
|
|
@@ -197,8 +281,8 @@ class BrowserApi {
|
|
|
197
281
|
/**
|
|
198
282
|
* Parse a browser File or Blob object to JSON array.
|
|
199
283
|
* @param {File|Blob} file - File or Blob to read as text
|
|
200
|
-
* @param {object} options - options: { encoding?: string }
|
|
201
|
-
* @returns {Promise<
|
|
284
|
+
* @param {object} [options] - options: { encoding?: string }
|
|
285
|
+
* @returns {Promise<object[]>} Promise resolving to parsed JSON rows
|
|
202
286
|
* @example
|
|
203
287
|
* const csvToJson = require('convert-csv-to-json');
|
|
204
288
|
* const fileInput = document.querySelector('#csvfile').files[0];
|
|
@@ -253,19 +337,26 @@ module.exports = new BrowserApi();
|
|
|
253
337
|
|
|
254
338
|
|
|
255
339
|
|
|
256
|
-
</div>
|
|
257
|
-
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
</
|
|
261
|
-
|
|
262
|
-
<
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
<footer class="footer">
|
|
343
|
+
<div class="content has-text-centered">
|
|
344
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a></p>
|
|
345
|
+
<p class="sidebar-created-by">
|
|
346
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
347
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
348
|
+
</p>
|
|
349
|
+
</div>
|
|
350
|
+
</footer>
|
|
351
|
+
|
|
352
|
+
</div>
|
|
353
|
+
<div id="side-nav" class="side-nav">
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
<script src="scripts/app.min.js"></script>
|
|
357
|
+
<script>PR.prettyPrint();</script>
|
|
358
|
+
<script src="scripts/linenumber.js"> </script>
|
|
263
359
|
|
|
264
|
-
<footer>
|
|
265
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Mar 20 2026 16:08:52 GMT+0000 (Coordinated Universal Time)
|
|
266
|
-
</footer>
|
|
267
360
|
|
|
268
|
-
<script> prettyPrint(); </script>
|
|
269
|
-
<script src="scripts/linenumber.js"> </script>
|
|
270
361
|
</body>
|
|
271
362
|
</html>
|
|
@@ -1,26 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
<!DOCTYPE html>
|
|
2
4
|
<html lang="en">
|
|
5
|
+
|
|
3
6
|
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title> src/csvToJson.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
|
+
|
|
14
28
|
</head>
|
|
15
29
|
|
|
16
|
-
<body>
|
|
17
30
|
|
|
18
|
-
<div id="main">
|
|
19
|
-
|
|
20
|
-
<h1 class="page-title">Source: src/csvToJson.js</h1>
|
|
21
31
|
|
|
32
|
+
<body class="layout small-header">
|
|
33
|
+
<div id="stickyNavbarOverlay"></div>
|
|
22
34
|
|
|
23
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>src/csvToJson.js</h1>
|
|
104
|
+
</header>
|
|
105
|
+
|
|
106
|
+
|
|
24
107
|
|
|
25
108
|
|
|
26
109
|
|
|
@@ -47,6 +130,7 @@ const CR = '\r';
|
|
|
47
130
|
/**
|
|
48
131
|
* Main CSV to JSON converter class
|
|
49
132
|
* Provides chainable API for configuring and converting CSV data
|
|
133
|
+
* @category 2-Sync
|
|
50
134
|
*/
|
|
51
135
|
class CsvToJson {
|
|
52
136
|
|
|
@@ -136,8 +220,8 @@ class CsvToJson {
|
|
|
136
220
|
|
|
137
221
|
/**
|
|
138
222
|
* Sets a mapper function to transform each row after conversion
|
|
139
|
-
* @param {
|
|
140
|
-
* @returns {this}
|
|
223
|
+
* @param {function(object, number): (object|null)} mapperFn - Function that receives (row, index) and returns transformed row or null to filter out
|
|
224
|
+
* @returns {this} For method chaining
|
|
141
225
|
*/
|
|
142
226
|
mapRows(mapperFn) {
|
|
143
227
|
if (typeof mapperFn !== 'function') {
|
|
@@ -587,19 +671,26 @@ module.exports = new CsvToJson();
|
|
|
587
671
|
|
|
588
672
|
|
|
589
673
|
|
|
590
|
-
</div>
|
|
591
|
-
|
|
592
|
-
<
|
|
593
|
-
|
|
594
|
-
</
|
|
595
|
-
|
|
596
|
-
<
|
|
674
|
+
</div>
|
|
675
|
+
|
|
676
|
+
<footer class="footer">
|
|
677
|
+
<div class="content has-text-centered">
|
|
678
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a></p>
|
|
679
|
+
<p class="sidebar-created-by">
|
|
680
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
681
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
682
|
+
</p>
|
|
683
|
+
</div>
|
|
684
|
+
</footer>
|
|
685
|
+
|
|
686
|
+
</div>
|
|
687
|
+
<div id="side-nav" class="side-nav">
|
|
688
|
+
</div>
|
|
689
|
+
</div>
|
|
690
|
+
<script src="scripts/app.min.js"></script>
|
|
691
|
+
<script>PR.prettyPrint();</script>
|
|
692
|
+
<script src="scripts/linenumber.js"> </script>
|
|
597
693
|
|
|
598
|
-
<footer>
|
|
599
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Mar 20 2026 16:08:52 GMT+0000 (Coordinated Universal Time)
|
|
600
|
-
</footer>
|
|
601
694
|
|
|
602
|
-
<script> prettyPrint(); </script>
|
|
603
|
-
<script src="scripts/linenumber.js"> </script>
|
|
604
695
|
</body>
|
|
605
696
|
</html>
|
|
@@ -1,26 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
<!DOCTYPE html>
|
|
2
4
|
<html lang="en">
|
|
5
|
+
|
|
3
6
|
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title> src/csvToJsonAsync.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
|
+
|
|
14
28
|
</head>
|
|
15
29
|
|
|
16
|
-
<body>
|
|
17
30
|
|
|
18
|
-
<div id="main">
|
|
19
|
-
|
|
20
|
-
<h1 class="page-title">Source: src/csvToJsonAsync.js</h1>
|
|
21
31
|
|
|
32
|
+
<body class="layout small-header">
|
|
33
|
+
<div id="stickyNavbarOverlay"></div>
|
|
22
34
|
|
|
23
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>src/csvToJsonAsync.js</h1>
|
|
104
|
+
</header>
|
|
105
|
+
|
|
106
|
+
|
|
24
107
|
|
|
25
108
|
|
|
26
109
|
|
|
@@ -36,6 +119,7 @@ const { InputValidationError } = require('./util/errors');
|
|
|
36
119
|
/**
|
|
37
120
|
* Asynchronous CSV to JSON converter
|
|
38
121
|
* Proxies configuration to sync instance but provides async file I/O methods
|
|
122
|
+
* @category 3-Async
|
|
39
123
|
*/
|
|
40
124
|
class CsvToJsonAsync {
|
|
41
125
|
/**
|
|
@@ -109,7 +193,7 @@ class CsvToJsonAsync {
|
|
|
109
193
|
|
|
110
194
|
/**
|
|
111
195
|
* Set a mapper function to transform each row after conversion
|
|
112
|
-
* @param {
|
|
196
|
+
* @param {function(object, number): (object|null)} mapperFn - Function receiving (row, index) that returns transformed row or null to filter
|
|
113
197
|
* @returns {this} For method chaining
|
|
114
198
|
*/
|
|
115
199
|
mapRows(mapperFn) {
|
|
@@ -226,19 +310,26 @@ module.exports = new CsvToJsonAsync();</code></pre>
|
|
|
226
310
|
|
|
227
311
|
|
|
228
312
|
|
|
229
|
-
</div>
|
|
230
|
-
|
|
231
|
-
<
|
|
232
|
-
|
|
233
|
-
</
|
|
234
|
-
|
|
235
|
-
<
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<footer class="footer">
|
|
316
|
+
<div class="content has-text-centered">
|
|
317
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a></p>
|
|
318
|
+
<p class="sidebar-created-by">
|
|
319
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
320
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
321
|
+
</p>
|
|
322
|
+
</div>
|
|
323
|
+
</footer>
|
|
324
|
+
|
|
325
|
+
</div>
|
|
326
|
+
<div id="side-nav" class="side-nav">
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
<script src="scripts/app.min.js"></script>
|
|
330
|
+
<script>PR.prettyPrint();</script>
|
|
331
|
+
<script src="scripts/linenumber.js"> </script>
|
|
236
332
|
|
|
237
|
-
<footer>
|
|
238
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Mar 20 2026 16:08:52 GMT+0000 (Coordinated Universal Time)
|
|
239
|
-
</footer>
|
|
240
333
|
|
|
241
|
-
<script> prettyPrint(); </script>
|
|
242
|
-
<script src="scripts/linenumber.js"> </script>
|
|
243
334
|
</body>
|
|
244
335
|
</html>
|