Blame view

public/js/common/helpers/or.js 555 Bytes
m  
刘传洋 authored
1 2 3 4
/**
 * Created by LiuChuanYang on 2017/01/19.
 */
m  
刘传洋 authored
5 6
'use strict';
m  
刘传洋 authored
7
module.exports = function() {
m  
刘传洋 authored
8 9 10 11
    var options = arguments[arguments.length - 1];
    var ret = false;
    var len = arguments.length - 1;
    var i = 1;
m  
刘传洋 authored
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

    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;
    }
};