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.
Files changed (38) hide show
  1. package/.github/workflows/ci-cd.yml +1 -1
  2. package/docs/.nojekyll +0 -0
  3. package/docs/README.md +44 -0
  4. package/docs/demo.bundle.js +1708 -0
  5. package/docs/index.html +536 -0
  6. package/eslint.config.js +1 -1
  7. package/package.json +5 -1
  8. package/docs/api/BrowserApi.html +0 -2662
  9. package/docs/api/BrowserApiError.html +0 -669
  10. package/docs/api/ConfigurationError.html +0 -745
  11. package/docs/api/CsvFormatError.html +0 -677
  12. package/docs/api/CsvParsingError.html +0 -511
  13. package/docs/api/CsvToJson.html +0 -3367
  14. package/docs/api/CsvToJsonAsync.html +0 -2880
  15. package/docs/api/FileOperationError.html +0 -382
  16. package/docs/api/FileUtils.html +0 -1150
  17. package/docs/api/InputValidationError.html +0 -407
  18. package/docs/api/JsonUtil.html +0 -452
  19. package/docs/api/JsonValidationError.html +0 -357
  20. package/docs/api/StringUtils.html +0 -833
  21. package/docs/api/global.html +0 -3498
  22. package/docs/api/index.html +0 -414
  23. package/docs/api/index.js.html +0 -447
  24. package/docs/api/scripts/app.min.js +0 -1
  25. package/docs/api/scripts/linenumber.js +0 -26
  26. package/docs/api/scripts/search.js +0 -39
  27. package/docs/api/src_browserApi.js.html +0 -362
  28. package/docs/api/src_csvToJson.js.html +0 -696
  29. package/docs/api/src_csvToJsonAsync.js.html +0 -335
  30. package/docs/api/src_util_errors.js.html +0 -472
  31. package/docs/api/src_util_fileUtils.js.html +0 -238
  32. package/docs/api/src_util_jsonUtils.js.html +0 -166
  33. package/docs/api/src_util_stringUtils.js.html +0 -306
  34. package/docs/api/styles/app.min.css +0 -1
  35. package/docs/api/styles/iframe.css +0 -13
  36. package/docs/api/styles/prettify-jsdoc.css +0 -111
  37. package/docs/api/styles/prettify-tomorrow.css +0 -132
  38. package/docs/api/styles/reset.css +0 -44
@@ -1,306 +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> src/util/stringUtils.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>src/util/stringUtils.js</h1>
104
- </header>
105
-
106
-
107
-
108
-
109
-
110
- <section>
111
- <article>
112
- <pre class="prettyprint source linenums"><code>'use strict';
113
-
114
- /**
115
- * String processing utilities for CSV parsing
116
- * @category Utilities
117
- */
118
- class StringUtils {
119
- // Regular expressions as constants for better maintainability
120
- static PATTERNS = {
121
- INTEGER: /^-?\d+$/,
122
- FLOAT: /^-?\d*\.\d+$/,
123
- WHITESPACE: /\s/g
124
- };
125
-
126
- static BOOLEAN_VALUES = {
127
- TRUE: 'true',
128
- FALSE: 'false'
129
- };
130
-
131
- /**
132
- * Removes whitespace from property names based on configuration
133
- * @param {boolean} shouldTrimAll - If true, removes all whitespace, otherwise only trims edges
134
- * @param {string} propertyName - The property name to process
135
- * @returns {string} The processed property name
136
- */
137
- trimPropertyName(shouldTrimAll, propertyName) {
138
- if (!propertyName) {
139
- return '';
140
- }
141
- return shouldTrimAll ?
142
- propertyName.replace(StringUtils.PATTERNS.WHITESPACE, '') :
143
- propertyName.trim();
144
- }
145
-
146
- /**
147
- * Converts a string value to its appropriate type while preserving data integrity
148
- * @param {string} value - The input value to convert
149
- * @returns {string|number|boolean} The converted value
150
- */
151
- getValueFormatByType(value) {
152
- if (this.isEmpty(value)) {
153
- return String();
154
- }
155
-
156
- if (this.isBoolean(value)) {
157
- return this.convertToBoolean(value);
158
- }
159
-
160
- if (this.isInteger(value)) {
161
- return this.convertInteger(value);
162
- }
163
-
164
- if (this.isFloat(value)) {
165
- return this.convertFloat(value);
166
- }
167
-
168
- return String(value);
169
- }
170
-
171
- /**
172
- * Checks if a value array contains any non-empty values
173
- * @param {Array} values - Array to check for content
174
- * @returns {boolean} True if array has any non-empty values
175
- */
176
- hasContent(values = []) {
177
- return Array.isArray(values) &amp;&amp;
178
- values.some(value => Boolean(value));
179
- }
180
-
181
- // Private helper methods for type checking and conversion
182
- /**
183
- * Check if a value is empty (undefined or empty string)
184
- * @param {unknown} value - Value to check
185
- * @returns {boolean} True if value is undefined or empty string
186
- * @private
187
- */
188
- isEmpty(value) {
189
- return value === undefined || value === '';
190
- }
191
-
192
- /**
193
- * Check if a value is a boolean string ('true' or 'false', case-insensitive)
194
- * @param {string} value - Value to check
195
- * @returns {boolean} True if value is 'true' or 'false'
196
- * @private
197
- */
198
- isBoolean(value) {
199
- const normalizedValue = value.toLowerCase();
200
- return normalizedValue === StringUtils.BOOLEAN_VALUES.TRUE ||
201
- normalizedValue === StringUtils.BOOLEAN_VALUES.FALSE;
202
- }
203
-
204
- /**
205
- * Check if a value is an integer string (with optional leading minus sign)
206
- * @param {string} value - Value to check
207
- * @returns {boolean} True if value matches integer pattern
208
- * @private
209
- */
210
- isInteger(value) {
211
- return StringUtils.PATTERNS.INTEGER.test(value);
212
- }
213
-
214
- /**
215
- * Check if a value is a float string (decimal number with optional leading minus sign)
216
- * @param {string} value - Value to check
217
- * @returns {boolean} True if value matches float pattern
218
- * @private
219
- */
220
- isFloat(value) {
221
- return StringUtils.PATTERNS.FLOAT.test(value);
222
- }
223
-
224
- /**
225
- * Check if a numeric string has a leading zero (e.g., '01' or '-01')
226
- * Leading zeros indicate the value should be kept as a string to preserve formatting
227
- * @param {string} value - Numeric string value to check
228
- * @returns {boolean} True if value has a leading zero
229
- * @private
230
- */
231
- hasLeadingZero(value) {
232
- const isPositiveWithLeadingZero = value.length > 1 &amp;&amp; value[0] === '0';
233
- const isNegativeWithLeadingZero = value.length > 2 &amp;&amp; value[0] === '-' &amp;&amp; value[1] === '0';
234
- return isPositiveWithLeadingZero || isNegativeWithLeadingZero;
235
- }
236
-
237
- /**
238
- * Convert a boolean string to native boolean value
239
- * Safely converts 'true' to true and 'false' to false
240
- * @param {string} value - Boolean string ('true' or 'false')
241
- * @returns {boolean} Native boolean value
242
- * @private
243
- */
244
- convertToBoolean(value) {
245
- return JSON.parse(value.toLowerCase());
246
- }
247
-
248
- /**
249
- * Convert an integer string to number or keep as string if it has leading zeros
250
- * Preserves leading zeros in strings (e.g., '007' stays as string)
251
- * @param {string} value - Integer string to convert
252
- * @returns {number|string} Number if safe, otherwise string value
253
- * @private
254
- */
255
- convertInteger(value) {
256
- if (this.hasLeadingZero(value)) {
257
- return String(value);
258
- }
259
-
260
- const num = Number(value);
261
- return Number.isSafeInteger(num) ? num : String(value);
262
- }
263
-
264
- /**
265
- * Convert a float string to number or keep as string if conversion is unsafe
266
- * @param {string} value - Float string to convert
267
- * @returns {number|string} Number if finite and valid, otherwise string value
268
- * @private
269
- */
270
- convertFloat(value) {
271
- const num = Number(value);
272
- return Number.isFinite(num) ? num : String(value);
273
- }
274
- }
275
-
276
- module.exports = new StringUtils();
277
- </code></pre>
278
- </article>
279
- </section>
280
-
281
-
282
-
283
-
284
- </div>
285
-
286
- <footer class="footer">
287
- <div class="content has-text-centered">
288
- <p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a></p>
289
- <p class="sidebar-created-by">
290
- <a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
291
- <a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
292
- </p>
293
- </div>
294
- </footer>
295
-
296
- </div>
297
- <div id="side-nav" class="side-nav">
298
- </div>
299
- </div>
300
- <script src="scripts/app.min.js"></script>
301
- <script>PR.prettyPrint();</script>
302
- <script src="scripts/linenumber.js"> </script>
303
-
304
-
305
- </body>
306
- </html>