first-line
v4.0.0
Published
Get the first line of a file
Downloads
1,100
Readme
first-line
Get the first line of a file.
Example
$ cat fixture.txt
1
2
3
var firstLine = require('first-line');
var path = require('path');
var p = path.resolve(__dirname, 'fixture.txt');
firstLine(p, function(error, line) {
if (error) {
throw error;
}
console.log(line.toString());
// => '1'
});
Installation
$ npm install first-line
API
var firstLine = require('first-line');
firstLine(file, callback)
Reads the file at String file
and calls callback(error, line)
, where
error
is any Error encountered and line
is a Buffer of the first line of
file
.