Skip to content

Commit cb29ed9

Browse files
committed
Use new json2csv api
1 parent b39e25c commit cb29ed9

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

package-lock.json

Lines changed: 19 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"fp-ts": "^2.5.3",
4848
"io-ts": "^2.1.3",
4949
"io-ts-excess": "^1.0.1",
50-
"json2csv": "^4.5.4",
50+
"json2csv": "^5.0.0",
5151
"lodash": "^4.17.15",
5252
"puppeteer": "^2.1.1",
5353
"tmp": "^0.1.0",
@@ -67,7 +67,7 @@
6767
"@types/concat-stream": "^1.6.0",
6868
"@types/express": "^4.17.6",
6969
"@types/jest": "^25.2.1",
70-
"@types/json2csv": "^4.5.1",
70+
"@types/json2csv": "^5.0.0",
7171
"@types/node": "^13.11.1",
7272
"@types/puppeteer": "^2.0.1",
7373
"@types/tmp": "^0.1.0",

src/http/download.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from "axios";
22
import * as fs from "fs";
3-
import * as json2csv from "json2csv";
3+
import {Parser, transforms} from "json2csv";
44
import * as winston from "winston";
55

66
interface IDownload {
@@ -50,7 +50,7 @@ export async function download(
5050
* Save list of posts to a CSV file
5151
*/
5252
export async function toCSV(posts: object[], filePath: string) {
53-
const parser = new json2csv.Parser({flatten: true});
53+
const parser = new Parser({transforms: [transforms.flatten()]});
5454
const csv = parser.parse(posts);
5555
fs.writeFileSync(filePath, csv);
5656
}

0 commit comments

Comments
 (0)