On 17/01/15 03:21, Roelof Wobben wrote:

Does anyone have a tip if this can be done and how I can do this ?

var fs= require("fs");
var stream= require("stream");
var util= require("util");
var inFile= fs.createReadStream("in.txt", {encoding: "utf8"});
var outFile= fs.createWriteStream("out.txt");

var UpperTransform = function(options) {
    if (!(this instanceof UpperTransform)) {
      return new UpperTransform(options);
    }
    stream.Transform.call(this, options);
};
util.inherits(UpperTransform, stream.Transform);

UpperTransform.prototype._transform = function(line, enc, done) {
    this.push(line.toUpperCase());
    done();
};

var upper = new UpperTransform({ objectMode: true });

upper.on("error", function(err) {
  console.log(err)
});

inFile.pipe(upper).pipe(outFile);

Enjoy !

Luca Morandini
Data Architect - AURIN project
Melbourne eResearch Group
Department of Computing and Information Systems
University of Melbourne




--
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/m9d0ib%24n6s%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to