Get the first line of a file
npm install first-lineGet the first line of a file.
`` bash`
$ cat fixture.txt
1
2
3
` javascript
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'
});
`
` bash`
$ npm install first-line
` javascript`
var firstLine = require('first-line');
Reads the file at _String_ file and calls callback(error, line), whereerror is any _Error_ encountered and line is a _Buffer_ of the first line offile`.