Skip to content

Commit

Permalink
refactor(csv-issues-esm): use desm
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Jan 31, 2023
1 parent 8ce415a commit 568364e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 4 additions & 6 deletions demo/issues-esm/lib/365.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@

import fs from 'fs/promises'
import { parse } from 'csv-parse/sync'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
import desm from 'desm';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const dirname = desm(import.meta.url);

(async () => {
const data = await fs.readFile(`${__dirname}/365-utf16le-bom-windows.csv`)
const data = await fs.readFile(`${dirname}/365-utf16le-bom-windows.csv`)
const records = parse(data, {bom: true})
console.log('utf16le', records)
})();

(async () => {
const data = await fs.readFile(`${__dirname}/365-utf8-bom-windows.csv`)
const data = await fs.readFile(`${dirname}/365-utf8-bom-windows.csv`)
const records = parse(data, {bom: true})
console.log('utf8', records)
})();
3 changes: 3 additions & 0 deletions demo/issues-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
},
"scripts": {
"test": "mocha 'test/**/*.coffee'"
},
"dependencies": {
"desm": "^1.3.0"
}
}

0 comments on commit 568364e

Please sign in to comment.