Created
February 22, 2017 05:59
-
-
Save fuchao2012/584992f7dd355559a68307d27d3a249c to your computer and use it in GitHub Desktop.
ES6-Original-Module-Demo
This file contains hidden or 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
| 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