Last active
December 19, 2016 18:32
-
-
Save briandk/b5f1b3ba4e6dacfa46a1b3bfbbb57885 to your computer and use it in GitHub Desktop.
How to handle operations on large arrays in ECMAScript6, say for parsing bibfiles
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
const parseRecord = function (rawRecord) { | |
// Parsing logic goes here | |
} | |
const fs = require('fs') | |
const records = fs.readFileSync('myBibfile.bib') | |
.split('@') // @ is the delimiter in bibfiles | |
// Array.from() takes an iterable argument *and* a mapping function | |
// if you want to map elements from the source array | |
let parsedRecords = Array.from(records, parseRecord) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment