and.js 554 Bytes
/**
 * Created by LiuChuanYang on 2017/01/19.
 */
'use strict';

module.exports = function() {
    var options = arguments[arguments.length - 1];
    var ret = false;
    var len = arguments.length - 1;
    var i = 1;

    if (len > 0) {
        ret = arguments[0];
        while (i < len) {
            ret = ret && arguments[i];
            i++;
        }
    }

    if (options.fn) {
        if (ret) {
            return options.fn(this);
        } else {
            return options.inverse(this);
        }
    } else {
        return ret;
    }
};