-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
110 additions
and
17 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
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
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,8 @@ | ||
import PapaParse, { UnparseConfig } from 'papaparse'; | ||
import PapaParse, { UnparseObject, UnparseConfig } from 'papaparse'; | ||
|
||
export function jsonToCSV(json: any, options: UnparseConfig = {}) { | ||
export function jsonToCSV<T>( | ||
json: T[] | UnparseObject<T>, | ||
options: UnparseConfig = {}, | ||
) { | ||
return PapaParse.unparse(json, options); | ||
} |
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,8 +1,13 @@ | ||
import PapaParse, { ParseWorkerConfig } from 'papaparse'; | ||
import PapaParse, { NODE_STREAM_INPUT, ParseResult } from 'papaparse'; | ||
|
||
import { ReadStringConfig } from './model'; | ||
|
||
export function readString<T>( | ||
csvString: string, | ||
config: ParseWorkerConfig<T> & { download?: false | undefined }, | ||
csvString: string | typeof NODE_STREAM_INPUT, | ||
config: ReadStringConfig<T> & { | ||
download?: false | undefined; | ||
complete(results: ParseResult<T>): void; | ||
}, | ||
) { | ||
return PapaParse.parse(csvString, config); | ||
return PapaParse.parse(csvString as typeof NODE_STREAM_INPUT, config); | ||
} |
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