SOURCE

const userlimits = ["read","write"]

let strategies = {
    isReadAble : function(value){
        if(userlimits.indexOf(value)>-1)
        {
         
            return true
        }
        return false
    },
    isWriteAble : function(value)
    {
        if(userlimits.indexOf(value)>-1)
        {
            return true
        }
        return false
    },
    isExecute : function(value)
    {
        if(userlimits.indexOf(value)>-1)
        {
            alert(1)
            return true
        }
        return false
    }

}

var Validator = function()
{
    this.catch = [];
    this.add = function(value,method)
    {
        this.catch.push(
            function(){
                return strategies[method](value)
            }
        )
    }
    this.check = function()
    {
        for(let i=0;i<this.catch.length;i++)
        {
            let valiFn = this.catch[i];
            // console.log(valiFn)
            let data = valiFn();
            console.log(data)
            if(!data)
            {
                return false
            }
           
        }
         return true
    }
}
var compose1 = function()
{
    var validator = new Validator()
    validator.add("read","isReadAble")
    validator.add("execute","isExecute")
    let res = validator.check();
    return res
}
console.log(compose1())
console 命令行工具 X clear

                    
>
console