All files / app/lib file.js

100% Statements 34/34
100% Branches 9/9
100% Functions 2/2
100% Lines 34/34

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 3421x 21x 21x 21x 8x 8x 8x 4x 4x 4x 8x 8x 8x 4x 4x 4x 4x 4x 4x 4x 8x 8x 8x 8x 21x 21x 21x 21x 4x 4x 4x 21x 21x 21x
const fs = require('fs');
const util = require('util');
const Streamz = require('streamz');
 
function File(file,options) {
  if (!(this instanceof File))
    return new File(file,options);
 
  Streamz.call(this);
 
  options = options || {};
  if (options.encoding === undefined)
    options.encoding = 'utf-8';
 
  fs.createReadStream(file,options)
    .pipe(this);
 
  let filename = file.split('/');
  filename = filename[filename.length-1];
 
  this.info = options.info || {};
  this.info.__path = file;
  this.info.__filename = filename;
}
 
util.inherits(File,Streamz);
 
File.prototype._fn = function(d) {
  const obj = Object.create(this.info);
  obj.text = d;
  this.push(obj);
};
 
module.exports = File;