read-excel-file 5.3.3 → 5.3.4

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 (54) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +21 -14
  3. package/bundle/read-excel-file.min.js +1 -1
  4. package/bundle/read-excel-file.min.js.map +1 -1
  5. package/commonjs/read/isDateTimestamp.js +112 -0
  6. package/commonjs/read/isDateTimestamp.js.map +1 -0
  7. package/commonjs/read/parseCell.js +5 -0
  8. package/commonjs/read/parseCell.js.map +1 -1
  9. package/commonjs/read/parseCellValue.js +66 -82
  10. package/commonjs/read/parseCellValue.js.map +1 -1
  11. package/commonjs/read/parseDate.js.map +1 -1
  12. package/commonjs/read/schema/convertToJson.js +87 -26
  13. package/commonjs/read/schema/convertToJson.js.map +1 -1
  14. package/commonjs/read/schema/convertToJson.test.js.map +1 -1
  15. package/commonjs/xml/dom.js +29 -0
  16. package/commonjs/xml/dom.js.map +1 -1
  17. package/commonjs/xml/xlsx.js.map +1 -1
  18. package/commonjs/xml/xml.js +2 -4
  19. package/commonjs/xml/xml.js.map +1 -1
  20. package/commonjs/xml/{xlsx-xpath.js → xpath/xlsx-xpath.js} +1 -0
  21. package/commonjs/xml/xpath/xlsx-xpath.js.map +1 -0
  22. package/commonjs/xml/{xpathBrowser.js → xpath/xpathBrowser.js} +1 -0
  23. package/commonjs/xml/xpath/xpathBrowser.js.map +1 -0
  24. package/commonjs/xml/{xpathNode.js → xpath/xpathNode.js} +1 -1
  25. package/commonjs/xml/xpath/xpathNode.js.map +1 -0
  26. package/modules/read/isDateTimestamp.js +104 -0
  27. package/modules/read/isDateTimestamp.js.map +1 -0
  28. package/modules/read/parseCell.js +5 -1
  29. package/modules/read/parseCell.js.map +1 -1
  30. package/modules/read/parseCellValue.js +64 -80
  31. package/modules/read/parseCellValue.js.map +1 -1
  32. package/modules/read/parseDate.js.map +1 -1
  33. package/modules/read/schema/convertToJson.js +87 -26
  34. package/modules/read/schema/convertToJson.js.map +1 -1
  35. package/modules/read/schema/convertToJson.test.js.map +1 -1
  36. package/modules/xml/dom.js +27 -0
  37. package/modules/xml/dom.js.map +1 -1
  38. package/modules/xml/xlsx.js.map +1 -1
  39. package/modules/xml/xml.js +2 -2
  40. package/modules/xml/xml.js.map +1 -1
  41. package/modules/xml/{xlsx-xpath.js → xpath/xlsx-xpath.js} +1 -0
  42. package/modules/xml/xpath/xlsx-xpath.js.map +1 -0
  43. package/modules/xml/{xpathBrowser.js → xpath/xpathBrowser.js} +1 -0
  44. package/modules/xml/xpath/xpathBrowser.js.map +1 -0
  45. package/modules/xml/{xpathNode.js → xpath/xpathNode.js} +1 -1
  46. package/modules/xml/xpath/xpathNode.js.map +1 -0
  47. package/package.json +1 -1
  48. package/types.d.ts +1 -0
  49. package/commonjs/xml/xlsx-xpath.js.map +0 -1
  50. package/commonjs/xml/xpathBrowser.js.map +0 -1
  51. package/commonjs/xml/xpathNode.js.map +0 -1
  52. package/modules/xml/xlsx-xpath.js.map +0 -1
  53. package/modules/xml/xpathBrowser.js.map +0 -1
  54. package/modules/xml/xpathNode.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 5.3.4 / 11.06.2022
2
+ ==================
3
+
4
+ * Added an optional `reason?: string` property of a with-schema parsing error.
5
+
1
6
  5.3.3 / 24.05.2022
2
7
  ==================
3
8
 
package/README.md CHANGED
@@ -157,7 +157,7 @@ const schema = {
157
157
  }
158
158
 
159
159
  readXlsxFile(file, { schema }).then(({ rows, errors }) => {
160
- // `errors` list items have shape: `{ row, column, error, value }`.
160
+ // `errors` list items have shape: `{ row, column, error, reason?, value?, type? }`.
161
161
  errors.length === 0
162
162
 
163
163
  rows === [{
@@ -241,27 +241,34 @@ const { rows, errors } = convertToJson(data, schema)
241
241
  ```js
242
242
  import { parseExcelDate } from 'read-excel-file'
243
243
 
244
- function ParseExcelError({ children: error }) {
245
- // Get a human-readable value.
246
- let value = error.value
247
- if (error.type === Date) {
248
- value = parseExcelDate(value).toString()
249
- }
250
- // Render error summary.
244
+ function ParseExcelError({ children }) {
245
+ const { type, value, error, reason, row, column } = children
246
+
247
+ // Error summary.
251
248
  return (
252
249
  <div>
253
- <code>"{error.error}"</code>
250
+ <code>"{error}"</code>
251
+ {reason && ' '}
252
+ {reason && <code>("{reason}")</code>}
254
253
  {' for value '}
255
- <code>"{value}"</code>
254
+ <code>{stringifyValue(value)}</code>
256
255
  {' in column '}
257
- <code>"{error.column}"</code>
258
- {error.type && ' of type '}
259
- {error.type && <code>"{error.type.name}"</code>}
256
+ <code>"{column}"</code>
257
+ {type && type.name && ' of type '}
258
+ {type && type.name && <code>"{type.name}"</code>}
260
259
  {' in row '}
261
- <code>"{error.row}"</code>
260
+ <code>{row}</code>
262
261
  </div>
263
262
  )
264
263
  }
264
+
265
+ function stringifyValue(value) {
266
+ // Wrap strings in quotes.
267
+ if (typeof value === 'string') {
268
+ return '"' + value + '"'
269
+ }
270
+ return String(value)
271
+ }
265
272
  ```
266
273
  </details>
267
274