UNPKG

etl

Version:

Collection of stream-based components that form an ETL pipeline

34 lines (25 loc) 698 B
var fs = require('fs'), util = require('util'), 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); var 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) { var obj = Object.create(this.info); obj.text = d; this.push(obj); }; module.exports = File;