lib/runner/instruction.js
function (name, payload, args) {
        var processor = processors[name];

        if (!_.isString(name) || !_.isFunction(processor)) {
            throw new Error('run-instruction: invalid construction');
        }

        // ensure that payload is an object so that data storage can be done. also ensure arguments is an array
        !_.isObject(payload) && (payload = {});
        !_.isArray(args) && (args = []);

        _.assign(this, /** @lends Instruction.prototype */ {
            /**
             * @type {String}
             */
            action: name,

            /**
             * @type {Object}
             */
            payload: payload,

            /**
             * @type {Array}
             */
            in: args,

            /**
             * @type {Timings}
             */
            timings: Timings.create(),

            /**
             * @private
             * @type {Function}
             */
            _processor: processor
        });

        // record the timing when this instruction was created
        this.timings.record('created');
    }
function (name, payload, args) {
        var processor = processors[name];

        if (!_.isString(name) || !_.isFunction(processor)) {
            throw new Error('run-instruction: invalid construction');
        }

        // ensure that payload is an object so that data storage can be done. also ensure arguments is an array
        !_.isObject(payload) && (payload = {});
        !_.isArray(args) && (args = []);

        _.assign(this, /** @lends Instruction.prototype */ {
            /**
             * @type {String}
             */
            action: name,

            /**
             * @type {Object}
             */
            payload: payload,

            /**
             * @type {Array}
             */
            in: args,

            /**
             * @type {Timings}
             */
            timings: Timings.create(),

            /**
             * @private
             * @type {Function}
             */
            _processor: processor
        });

        // record the timing when this instruction was created
        this.timings.record('created');
    }
function ( name , payload , args ) { var processor = processors [ name ] ; if ( ! _ . isString ( name ) || ! _ . isFunction ( processor ) ) { throw new Error ( 'run-instruction: invalid construction' ) ; } // ensure that payload is an object so that data storage can be done. also ensure arguments is an array ! _ . isObject ( payload ) && ( payload = { } ) ; ! _ . isArray ( args ) && ( args = [ ] ) ; _ . assign ( this , /** @lends Instruction.prototype */ { /**
             * @type {String}
             */ action : name , /**
             * @type {Object}
             */ payload : payload , /**
             * @type {Array}
             */ in : args , /**
             * @type {Timings}
             */ timings : Timings . create ( ) , /**
             * @private
             * @type {Function}
             */ _processor : processor } ) ; // record the timing when this instruction was created this . timings . record ( 'created' ) ; }
Create a new instruction to be executed later

@constructor

@param {String} name - name of the instruction. this is useful for later lookup of the `processor` function when
deserialising this object
@param {Object} [payload] - a **JSON compatible** object that will be forwarded as the 2nd last parameter to the
processor.
@param {Array} [args] - all the arguments that needs to be passed to the processor is in this array
@private
@example
var inst = Instruction.create(function (arg1, payload, next) {
console.log(payload);
next(null, 'hello-on-execute with ' + arg1);
}, 'sample-instruction', {
payloadData1: 'value'
}, ['one-arg']);

// now, when we do execute, the result will be a console.log of payload and message will be as expected
instance.execute(function (err, message) {
console.log(message);
});
Create a new instruction to be executed later