Skip to content

Instantly share code, notes, and snippets.

@likai24
Created September 20, 2017 10:17
Show Gist options
  • Save likai24/972a5ed0a70f090d4f2026fcf9ac53b8 to your computer and use it in GitHub Desktop.
Save likai24/972a5ed0a70f090d4f2026fcf9ac53b8 to your computer and use it in GitHub Desktop.
用nodejs来读文件 node file.js 文件名
var fs = require('fs');
var path = process.argv.slice(2).pop();
var start = new Date();
var readStream = fs.createReadStream(path);
readStream
.on('data', function (chunk) {
})
.on('end', function () {
var end = new Date();
console.log((end - start)/1000 + "second ")
console.log(path + " load is done");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment