-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: apply lint to demo and exclude dist
- Loading branch information
Showing
29 changed files
with
414 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
|
||
// Import the package main module | ||
const csv = require('csv'); | ||
const csv = require("csv"); | ||
|
||
// Run the pipeline | ||
csv | ||
// Generate 20 records | ||
.generate({ | ||
delimiter: '|', | ||
length: 20 | ||
}) | ||
// Transform CSV data into records | ||
.pipe(csv.parse({ | ||
delimiter: '|' | ||
})) | ||
// Transform each value into uppercase | ||
.pipe(csv.transform((record) => { | ||
return record.map((value) => { | ||
return value.toUpperCase() | ||
}); | ||
})) | ||
// Convert objects into a stream | ||
.pipe(csv.stringify({ | ||
quoted: true, | ||
encoding: 'utf8' // Support for Node.js 8 | ||
})) | ||
// Print the CSV stream to stdout | ||
.pipe(process.stdout, {end: false}) | ||
// Generate 20 records | ||
.generate({ | ||
delimiter: "|", | ||
length: 20, | ||
}) | ||
// Transform CSV data into records | ||
.pipe( | ||
csv.parse({ | ||
delimiter: "|", | ||
}), | ||
) | ||
// Transform each value into uppercase | ||
.pipe( | ||
csv.transform((record) => { | ||
return record.map((value) => { | ||
return value.toUpperCase(); | ||
}); | ||
}), | ||
) | ||
// Convert objects into a stream | ||
.pipe( | ||
csv.stringify({ | ||
quoted: true, | ||
encoding: "utf8", // Support for Node.js 8 | ||
}), | ||
) | ||
// Print the CSV stream to stdout | ||
.pipe(process.stdout, { end: false }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
|
||
// Import the package sync module | ||
const version = parseInt(/^v(\d+)/.exec(process.version)[1], 10) | ||
const csv = require( | ||
version >= 14 ? 'csv/sync' : 'csv/dist/cjs/sync.cjs' | ||
); | ||
const version = parseInt(/^v(\d+)/.exec(process.version)[1], 10); | ||
const csv = require(version >= 14 ? "csv/sync" : "csv/dist/cjs/sync.cjs"); | ||
|
||
// Generate 20 records | ||
const input = csv.generate({ | ||
delimiter: '|', | ||
length: 20 | ||
delimiter: "|", | ||
length: 20, | ||
}); | ||
// Transform CSV data into records | ||
const records = csv.parse(input, { | ||
delimiter: '|' | ||
delimiter: "|", | ||
}); | ||
// Transform each value into uppercase | ||
const uppercaseRecords = csv.transform(records, (record) => { | ||
return record.map((value) => { | ||
return value.toUpperCase() | ||
}); | ||
return record.map((value) => { | ||
return value.toUpperCase(); | ||
}); | ||
}); | ||
// Convert objects into a stream | ||
const output = csv.stringify(uppercaseRecords, { | ||
quoted: true | ||
quoted: true, | ||
}); | ||
// Print the CSV stream to stdout | ||
process.stdout.write(output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
|
||
const assert = require('node:assert'); | ||
const version = parseInt(/^v(\d+)/.exec(process.version)[1], 10) | ||
const assert = require("node:assert"); | ||
const version = parseInt(/^v(\d+)/.exec(process.version)[1], 10); | ||
const { parse } = require( | ||
version >= 14 ? 'csv-parse/sync' : 'csv-parse/dist/cjs/sync.cjs' | ||
version >= 14 ? "csv-parse/sync" : "csv-parse/dist/cjs/sync.cjs", | ||
); | ||
|
||
// Create the parser | ||
const records = parse([ | ||
"a:b:c\n", | ||
"1:2:3\n" | ||
].join(''), { | ||
delimiter: ':' | ||
const records = parse(["a:b:c\n", "1:2:3\n"].join(""), { | ||
delimiter: ":", | ||
}); | ||
// Test that the parsed records matched what's expected | ||
assert.deepStrictEqual( | ||
records, | ||
[ | ||
[ 'a','b','c' ], | ||
[ '1','2','3' ] | ||
] | ||
); | ||
assert.deepStrictEqual(records, [ | ||
["a", "b", "c"], | ||
["1", "2", "3"], | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const { stringify } = require('csv-stringify/sync'); | ||
const { stringify } = require("csv-stringify/sync"); | ||
|
||
const output = stringify([['a', 'b', 'c']]); | ||
const output = stringify([["a", "b", "c"]]); | ||
|
||
console.log(output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
|
||
// Import the package main module | ||
import * as csv from 'csv' | ||
import * as csv from "csv"; | ||
|
||
// Run the pipeline | ||
csv | ||
// Generate 20 records | ||
.generate({ | ||
delimiter: '|', | ||
length: 20 | ||
}) | ||
// Transform CSV data into records | ||
.pipe(csv.parse({ | ||
delimiter: '|' | ||
})) | ||
// Transform each value into uppercase | ||
.pipe(csv.transform((record) => { | ||
return record.map((value) => { | ||
return value.toUpperCase() | ||
}); | ||
})) | ||
// Convert objects into a stream | ||
.pipe(csv.stringify({ | ||
quoted: true | ||
})) | ||
// Print the CSV stream to stdout | ||
.pipe(process.stdout) | ||
// Generate 20 records | ||
.generate({ | ||
delimiter: "|", | ||
length: 20, | ||
}) | ||
// Transform CSV data into records | ||
.pipe( | ||
csv.parse({ | ||
delimiter: "|", | ||
}), | ||
) | ||
// Transform each value into uppercase | ||
.pipe( | ||
csv.transform((record) => { | ||
return record.map((value) => { | ||
return value.toUpperCase(); | ||
}); | ||
}), | ||
) | ||
// Convert objects into a stream | ||
.pipe( | ||
csv.stringify({ | ||
quoted: true, | ||
}), | ||
) | ||
// Print the CSV stream to stdout | ||
.pipe(process.stdout); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
|
||
// Import the package sync module | ||
import * as csv from 'csv/sync'; | ||
import * as csv from "csv/sync"; | ||
|
||
// Generate 20 records | ||
const input = csv.generate({ | ||
delimiter: '|', | ||
length: 20 | ||
delimiter: "|", | ||
length: 20, | ||
}); | ||
// Transform CSV data into records | ||
const records = csv.parse(input, { | ||
delimiter: '|' | ||
delimiter: "|", | ||
}); | ||
// Transform each value into uppercase | ||
const uppercaseRecords = csv.transform(records, (record) => { | ||
return record.map((value) => { | ||
return value.toUpperCase() | ||
}); | ||
return record.map((value) => { | ||
return value.toUpperCase(); | ||
}); | ||
}); | ||
// Convert objects into a stream | ||
const output = csv.stringify(uppercaseRecords, { | ||
quoted: true | ||
quoted: true, | ||
}); | ||
// Print the CSV stream to stdout | ||
process.stdout.write(output); |
Oops, something went wrong.