Skip to content

Commit

Permalink
docs(csv): sample simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Jan 9, 2024
1 parent 49f9ccc commit 83537a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/csv/samples/pipe.js
Expand Up @@ -23,5 +23,5 @@ csv
.pipe(csv.stringify({
quoted: true
}))
// Print the CSV stream to stdout
// Print the CSV stream to stdout
.pipe(process.stdout);
21 changes: 7 additions & 14 deletions packages/csv/samples/sync.js
@@ -1,19 +1,12 @@

import assert from 'node:assert';
import {generate, parse, transform, stringify} from 'csv/sync';
import assert from "node:assert";
import { generate, parse, transform, stringify } from "csv/sync";

// Run the pipeline
const input = generate({seed: 1, columns: 2, length: 5});
const input = generate({ seed: 1, columns: 2, length: 2 });
const rawRecords = parse(input);
const refinedRecords = transform(rawRecords, function(data){
return data.map(function(value){return value.toUpperCase();});
});
const refinedRecords = transform(rawRecords, (data) =>
data.map((value) => value.toUpperCase())
);
const output = stringify(refinedRecords);
// Print the final result
assert.equal(output,
`OMH,ONKCHHJMJADOA
D,GEACHIN
NNMIN,CGFDKB
NIL,JNNMJADNMINL
KB,DMIM
`);
assert.equal(output, `OMH,ONKCHHJMJADOA\nD,GEACHIN\n`);

0 comments on commit 83537a2

Please sign in to comment.