Skip to content

Commit ddd750f

Browse files
committed
docs: simplify dirname declaration
1 parent a312a7c commit ddd750f

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

packages/csv-parse/samples/columns-discovery.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import fs from 'fs';
33
import { parse } from 'csv-parse';
44

5-
import { dirname } from 'path';
6-
import { fileURLToPath } from 'url';
7-
const __dirname = dirname(fileURLToPath(import.meta.url));
5+
const __dirname = new URL( '.', import.meta.url).pathname
86

97
// Using the first line of the CSV data to discover the column names
108
const rs = fs.createReadStream(__dirname+'/columns-discovery.in');

packages/csv-parse/samples/fs_read.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import fs from 'fs';
33
import { parse } from 'csv-parse';
44

5-
import { dirname } from 'path';
6-
import { fileURLToPath } from 'url';
7-
const __dirname = dirname(fileURLToPath(import.meta.url));
5+
const __dirname = new URL( '.', import.meta.url).pathname
86

97
const parser = parse({delimiter: ';'}, function(err, data){
108
console.log(data);

packages/csv-parse/samples/recipe.async.iterator.coffee

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import fs from 'fs'
33
import { parse } from 'csv-parse'
44

5-
import { dirname } from 'path'
6-
import { fileURLToPath } from 'url';
7-
__dirname = dirname fileURLToPath `import.meta.url`
5+
const __dirname = new URL( '.', import.meta.url).pathname
86

97
processFile = () ->
108
records = []

packages/csv-parse/samples/recipe.async.iterator.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import fs from 'fs';
33
import { parse } from 'csv-parse';
44

5-
import { dirname } from 'path';
6-
import { fileURLToPath } from 'url';
7-
const __dirname = dirname(fileURLToPath(import.meta.url));
5+
const __dirname = new URL( '.', import.meta.url).pathname
86

97
const processFile = async () => {
108
const records = [];

0 commit comments

Comments
 (0)