Skip to content

Instantly share code, notes, and snippets.

@fuchao2012
Created February 22, 2017 05:59
Show Gist options
  • Select an option

  • Save fuchao2012/584992f7dd355559a68307d27d3a249c to your computer and use it in GitHub Desktop.

Select an option

Save fuchao2012/584992f7dd355559a68307d27d3a249c to your computer and use it in GitHub Desktop.
ES6-Original-Module-Demo
import fs from 'fs'
import readline from 'readline'
import path from 'path'
const noop = () => false
let Module = {
readLineInFile(filename, cb = noop, done = noop){
let rl = readline.createInterface({
input: fs.createReadStream(path.resolve(__dirname, './big_file.txt'))
})
rl.on('line', line=> cb(line))
rl.on('close', done)
return rl
}
}
export default Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment