Code coverage report for lib/body-parser.js

Statements: 100% (12 / 12)      Branches: 100% (0 / 0)      Functions: 100% (3 / 3)      Lines: 100% (12 / 12)     

All files » lib/ » body-parser.js
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 261 1   1   5   5       1   1   8 8     1   5     1  
var Stream = require('stream');
var util = require('util');
 
function BodyParser() {
    // Call the Stream.Transform constructor
    Stream.Transform.call(this);
 
    this.body = "";
}
 
// Set up the inheritance
util.inherits(BodyParser, Stream.Transform);
 
BodyParser.prototype._transform = function(chunk, encoding, callback) {
    // Just append this chunk to the body
    this.body += chunk.toString('binary');
    callback();
};
 
BodyParser.prototype._flush = function(callback) {
    // Emit body event
    this.emit('body', this.body.trim());
};
 
module.exports = BodyParser;