Skip to content

Instantly share code, notes, and snippets.

@ianjsikes
Created May 1, 2019 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianjsikes/77b70a7a503f10c3770c7639a17ae3f2 to your computer and use it in GitHub Desktop.
Save ianjsikes/77b70a7a503f10c3770c7639a17ae3f2 to your computer and use it in GitHub Desktop.
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