index.js
function send_commands(cmds, cb) {
        function callback(value) {
            if (cb) cb(value)
            this.locked = false
        }
        function run() { 
            if (this.locked = cmds.length > 0) send_command(cmds.shift(), (success) => {
                if (success) setTimeout(run, 200);
                else callback(false);
            });
            else callback(true); 
        };
        if(!this.locked) run();
    }
function send_commands(cmds, cb) {
        function callback(value) {
            if (cb) cb(value)
            this.locked = false
        }
        function run() { 
            if (this.locked = cmds.length > 0) send_command(cmds.shift(), (success) => {
                if (success) setTimeout(run, 200);
                else callback(false);
            });
            else callback(true); 
        };
        if(!this.locked) run();
    }
function send_commands ( cmds , cb ) { function callback ( value ) { if ( cb ) cb ( value ) this . locked = false } function run ( ) { if ( this . locked = cmds . length > 0 ) send_command ( cmds . shift ( ) , ( success ) => { if ( success ) setTimeout ( run , 200 ) ; else callback ( false ) ; } ) ; else callback ( true ) ; } ; if ( ! this . locked ) run ( ) ; }
Send Multiple Commands
Send Multiple Commands