}
/**
- * A `TransformStream` to transform a `Array<CSVNormalizerField>` into an array that can be converted to CSV data.
+ * A `TransformStream` to transform a `Array<CSVNormalizerField>` into an `Array<string>` that can be converted to CSV data.
* @extends TransformStream
*/
export class CSVDenormalizer extends TransformStream {
firstRow = false;
controller.enqueue(chunk.map(f => f?.displayName ?? f.name));
}
- controller.enqueue(chunk.map(f => f.value instanceof Date ? f.value.toISOString() : f.value));
+ controller.enqueue(chunk.map(f => f.value instanceof Date ? f.value.toISOString() : f.value.toString()));
}
});
}
.pipeThrough(new CSVDenormalizer())
.pipeTo(csvStreamEqualWritable([
['columnA', 'columnB'],
- [123, 456]
+ ['123', '456']
]));
});
test('can pass through BigInt', { concurrency: true }, async () => {
.pipeThrough(new CSVDenormalizer())
.pipeTo(csvStreamEqualWritable([
['columnA', 'columnB'],
- [123n, 456n]
+ ['123', '456']
]));
});
test('can pass through date', { concurrency: true }, async () => {
.pipeThrough(new CSVDenormalizer())
.pipeTo(csvStreamEqualWritable([
['String Column', 'Number Column', 'BigInt Column', 'Date Column'],
- ['abc ๐จโ๐ฉโ๐งโ๐ฆ', 123456789.123456, 1000000000000000000n, '2024-01-01T00:00:00.000Z'],
- [', " ๐ดโโ ๏ธ', 1000, -1234567890000000000000000n, '2024-06-01T00:00:00.000Z'],
- ['N/A', 123100, 1000000000000000000n, '2024-12-31T08:00:00.000Z']
+ ['abc ๐จโ๐ฉโ๐งโ๐ฆ', '123456789.123456', '1000000000000000000', '2024-01-01T00:00:00.000Z'],
+ [', " ๐ดโโ ๏ธ', '1000', '-1234567890000000000000000', '2024-06-01T00:00:00.000Z'],
+ ['N/A', '123100', '1000000000000000000', '2024-12-31T08:00:00.000Z']
]));
});
test('can normalize with transformation', { concurrency: true }, async () => {