mirror of
https://github.com/thangisme/notes.git
synced 2025-09-24 03:34:06 -04:00
Initial commit
This commit is contained in:
22
node_modules/read-file-stdin/index.js
generated
vendored
Normal file
22
node_modules/read-file-stdin/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
var gather = require('gather-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
/**
|
||||
* Expose `read`.
|
||||
*/
|
||||
|
||||
module.exports = read;
|
||||
|
||||
/**
|
||||
* Read from a `file`, falling back to stdin, and `callback(err, buffer)`.
|
||||
*
|
||||
* @param {String} file
|
||||
* @param {Function} callback
|
||||
*/
|
||||
|
||||
function read (file, callback) {
|
||||
if ('function' == typeof file) callback = file, file = null;
|
||||
var stream = file ? fs.createReadStream(file) : process.stdin;
|
||||
stream.pipe(gather(callback));
|
||||
}
|
Reference in New Issue
Block a user