Code coverage report for lib\streams\RequestStream.js

Statements: 60% (18 / 30)      Branches: 37.5% (6 / 16)      Functions: 33.33% (1 / 3)      Lines: 60% (18 / 30)      Ignored: none     

All files » lib\streams\ » RequestStream.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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64  1   1 3 3   3         3 2 2 2 2 2                           1           1 1 1 1 1                                           1
'use strict';
var BaseStream = require('./BaseStream.js');
 
var RequestStream = function RequestStream(type, options) {
    Eif (options === undefined) {
        options = {};
    }
    var self = this,
        port = options.port || 3000,
        host = options.host,
        httpStream = require('./HttpStream.js')(port, host);
 
    if (self instanceof RequestStream) {
        this.init();
        self.type = type;
        self.options = options;
        Eif (type === undefined) {
            return self;
        }
 
        if (type === 'http') {
            self.from(httpStream);
            return self;
        }
 
        if (type === 'socket') {
            return self;
        }
 
        return self;
    }
    return new RequestStream(type);
 
};
 
 
 
RequestStream.prototype = new BaseStream();
RequestStream.prototype.type = null;
RequestStream.prototype.options = null;
RequestStream.prototype.constructor = RequestStream;
RequestStream.prototype.handleRoute = function handleRoute(route) {
    if (typeof route === 'function') {
        return {
            predicate : route
        };
    }
 
    if (typeof route === 'string') {
        var regex = new RegExp(route),
            p = function genericPredicate(val) {
                return regex.test(val.url);
            };
        return {
            predicate : p,
            url : route,
            regex : regex
        };
    }
};
 
 
 
module.exports = RequestStream;