packages/browser-sync-client/index.js
function init(options, requestBody, type) {
    /**
     * If the user asked for a file, simply return the string.
     */
    if (type && type === "file") {
        return processItems(requestBody);
    }

    /**
     * Otherwise return a function to be used a middleware
     */
    return function(req, res) {
        /**
         * default to using the uncompressed string
         * @type {String}
         */
        var output = processItems(requestBody);

        /**
         * Set the appropriate headers for caching
         */
        setHeaders(res, output);
        if (isConditionalGet(req) && fresh(req.headers, res._headers)) {
            return notModified(res);
        }

        /**
         * If gzip is supported, compress the string once
         * and save for future requests
         */
        if (supportsGzip(req)) {
            res.setHeader("Content-Encoding", "gzip");
            var buf = new Buffer(output, "utf-8");
            zlib.gzip(buf, function(_, result) {
                res.end(result);
            });
        } else {
            res.end(output);
        }
    };
}
function init(options, requestBody, type) {
    /**
     * If the user asked for a file, simply return the string.
     */
    if (type && type === "file") {
        return processItems(requestBody);
    }

    /**
     * Otherwise return a function to be used a middleware
     */
    return function(req, res) {
        /**
         * default to using the uncompressed string
         * @type {String}
         */
        var output = processItems(requestBody);

        /**
         * Set the appropriate headers for caching
         */
        setHeaders(res, output);
        if (isConditionalGet(req) && fresh(req.headers, res._headers)) {
            return notModified(res);
        }

        /**
         * If gzip is supported, compress the string once
         * and save for future requests
         */
        if (supportsGzip(req)) {
            res.setHeader("Content-Encoding", "gzip");
            var buf = new Buffer(output, "utf-8");
            zlib.gzip(buf, function(_, result) {
                res.end(result);
            });
        } else {
            res.end(output);
        }
    };
}
function init ( options , requestBody , type ) { /**
     * If the user asked for a file, simply return the string.
     */ if ( type && type === "file" ) { return processItems ( requestBody ) ; } /**
     * Otherwise return a function to be used a middleware
     */ return function ( req , res ) { /**
         * default to using the uncompressed string
         * @type {String}
         */ var output = processItems ( requestBody ) ; /**
         * Set the appropriate headers for caching
         */ setHeaders ( res , output ) ; if ( isConditionalGet ( req ) && fresh ( req . headers , res . _headers ) ) { return notModified ( res ) ; } /**
         * If gzip is supported, compress the string once
         * and save for future requests
         */ if ( supportsGzip ( req ) ) { res . setHeader ( "Content-Encoding" , "gzip" ) ; var buf = new Buffer ( output , "utf-8" ) ; zlib . gzip ( buf , function ( _ , result ) { res . end ( result ) ; } ) ; } else { res . end ( output ) ; } } ; }
Public method for returning either a middleware fn
or the content as a string
@param {Object} options
@param requestBody
@param {String} type - either `file` or `middleware`
@returns {*}
Public method for returning either a middleware fn or the content as a string