#gulp #plugin.
Hi ) I'm not a javascript guru, so ...
I've already made the task, but have problems with the speed
I stacked with stream.Transform.push. Here is test code
var fs = require("fs"),
through2 = require("through2"),
Transform = require("stream").Transform,
vinyl = require("vinyl"),
async = require("async");
.
.
.
resolveDependant = function(file, stream, cb){
/**
* @var array tree - list of files[], aka driectory tree
*/
var reg = new RegExp("Catch me!", "gm"),//ignore
seriesList = []; //for threading
for(var f in tree){
seriesList.push( //ignore
function(file){ //ignore
return function(callback){ //ignore
fs.readFile(file, { encoding : "utf8" }, function(
err, data){ //ignore
if(reg.exec(data)){ //trying to catch him!
stream.push( //here is time leak! For 4
files it spent 1.6s.
new vinyl({ //without previous line it
spent 0.4s for same 4 files
path : file,
contents :
new Buffer(data)
})
);
}
callback();
});
}
}(tree[f])
);
}
.
.
.
this.chain = function() { //gulp.pipe(obj.chain()) call
return through2.obj(function (file, enconding, cb) {
/**
* @var array tree - list of files[], aka driectory tree
*/
if(!tree.length) //just ensure that chain was called after
initialization
return cb(null, file);
var stream = this;
resolveDependant(file.path, stream, function(){
stream.push(file); //test mode ignore any input
cb(); //return control to pipe
});
});
}
Can anyone explain me why it spent so much time to push vinyl files into
stream
stream.push( ... );
Any help, books, advices and etc. will be helpfull.
Thanks
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/b4765ae6-70b4-4f81-92e6-dc3d7cc8a033%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.