]> git.ardis.lu - csvio/commitdiff
Demonstrate string shorthand
authorArdis Lu <ardisglu@gmail.com>
Sun, 19 Oct 2025 06:39:23 +0000 (23:39 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 19 Oct 2025 06:39:23 +0000 (23:39 -0700)
examples/ex4_2.js

index 499d85d39188af0fcf3a211c4897c3f75fb4993f..7764201311e1873f4883e3efcc33a78a02a247f9 100644 (file)
@@ -8,14 +8,14 @@ import { CSVReader, CSVWriter, CSVNormalizer, CSVDenormalizer, CSVTransformer }
 /** @import { CSVNormalizerHeader } from '../src/normalization.js'; */
 
 // A minimal declaration to tell `CSVNormalizer` to trim empty rows and columns but otherwise don't touch the data
-/** @type {Array<CSVNormalizerHeader>} */
+/** @type {Array<string|CSVNormalizerHeader>} */
 const headers = [
-  { name: 'columnA' },
-  { name: 'columnB' },
-  { name: 'columnC' },
-  { name: 'sparse1' },
-  { name: 'sparse2' },
-  { name: 'sparse3' }
+  'columnA', // Same as { name: 'columnA' } which is the same as { name: 'columnA', type: 'string' }
+  { name: 'columnB' }, // You can mix string and CSVNormalizerHeader in the same array
+  'columnC',
+  'sparse1',
+  'sparse2',
+  'sparse3'
 ];
 
 function transform(row) {
This page took 0.035812 seconds and 4 git commands to generate.