Skip to content

Instantly share code, notes, and snippets.

@briandk
Last active December 19, 2016 18:32
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 briandk/b5f1b3ba4e6dacfa46a1b3bfbbb57885 to your computer and use it in GitHub Desktop.
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
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