helpers.js
function asBuffer(data, encoding) {
    let result = data;
    if (!isNullOrUndefined(result)) {
        if ('object' !== typeof result) {
            // handle as string
            encoding = normalizeString(encoding);
            if (!encoding) {
                encoding = 'utf8';
            }
            result = new Buffer(toStringSafe(result), encoding);
        }
    }
    return result;
}
function asBuffer(data, encoding) {
    let result = data;
    if (!isNullOrUndefined(result)) {
        if ('object' !== typeof result) {
            // handle as string
            encoding = normalizeString(encoding);
            if (!encoding) {
                encoding = 'utf8';
            }
            result = new Buffer(toStringSafe(result), encoding);
        }
    }
    return result;
}
function asBuffer ( data , encoding ) { let result = data ; if ( ! isNullOrUndefined ( result ) ) { if ( 'object' !== typeof result ) { // handle as string
 encoding = normalizeString ( encoding ) ; if ( ! encoding ) { encoding = 'utf8' ; } result = new Buffer ( toStringSafe ( result ) , encoding ) ; } } return result ; }
Returns data as buffer.

@param {any} data The input data.
@param {string} [encoding] The custom encoding to use if 'data' is NOT a buffer.

@return {Buffer} The output data.
Returns data as buffer .