Created
May 1, 2019 19:41
-
-
Save ianjsikes/77b70a7a503f10c3770c7639a17ae3f2 to your computer and use it in GitHub Desktop.
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
export const readJsonl = (path: string): any[] => { | |
const text = fs.readFileSync(path, 'utf8'); | |
return text.split('\n').map(line => JSON.parse(line)); | |
}; | |
export const writeJsonl = (path: string, data: any[]) => { | |
const text = data.map(item => JSON.stringify(item)).join('\n'); | |
fs.writeFileSync(path, text); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment