mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-22 03:06:20 +10:00
34 lines
769 B
JavaScript
34 lines
769 B
JavaScript
/*jslint unparam: true*/
|
|
|
|
(function () {
|
|
'use strict';
|
|
|
|
var util = require('util'),
|
|
Transform = require('stream').Transform,
|
|
fs = require('fs');
|
|
|
|
function FileOpener() {
|
|
Transform.call(this, {objectMode: true});
|
|
}
|
|
|
|
util.inherits(FileOpener, Transform);
|
|
|
|
function FileOpener_transform(file, encoding, callback) {
|
|
var stream = this;
|
|
fs.readFile(file, 'utf8', function (err, data) {
|
|
if (err) {
|
|
stream.emit('error', err);
|
|
return;
|
|
}
|
|
|
|
stream.push({file: file, body: data});
|
|
callback();
|
|
});
|
|
}
|
|
|
|
/*jslint nomen:true*/
|
|
FileOpener.prototype._transform = FileOpener_transform;
|
|
|
|
module.exports = FileOpener;
|
|
}());
|