build/tincan.js
function (stmt, callback) {
            this.log("sendStatement");

            // would prefer to use .bind instead of 'self'
            var self = this,
                lrs,
                statement = this.prepareStatement(stmt),
                rsCount = this.recordStores.length,
                i,
                results = [],
                callbackWrapper,
                callbackResults = []
            ;

            if (rsCount > 0) {
                /*
                   if there is a callback that is a function then we need
                   to wrap that function with a function that becomes
                   the new callback that reduces a closure count of the
                   requests that don't have allowFail set to true and
                   when that number hits zero then the original callback
                   is executed
                */
                if (typeof callback === "function") {
                    callbackWrapper = function (err, xhr) {
                        var args;

                        self.log("sendStatement - callbackWrapper: " + rsCount);
                        if (rsCount > 1) {
                            rsCount -= 1;
                            callbackResults.push(
                                {
                                    err: err,
                                    xhr: xhr
                                }
                            );
                        }
                        else if (rsCount === 1) {
                            callbackResults.push(
                                {
                                    err: err,
                                    xhr: xhr
                                }
                            );
                            args = [
                                callbackResults,
                                statement
                            ];
                            callback.apply(this, args);
                        }
                        else {
                            self.log("sendStatement - unexpected record store count: " + rsCount);
                        }
                    };
                }

                for (i = 0; i < rsCount; i += 1) {
                    lrs = this.recordStores[i];

                    results.push(
                        lrs.saveStatement(statement, { callback: callbackWrapper })
                    );
                }
            }
            else {
                this.log("[warning] sendStatement: No LRSs added yet (statement not sent)");
                if (typeof callback === "function") {
                    callback.apply(this, [ null, statement ]);
                }
            }

            return {
                statement: statement,
                results: results
            };
        }
function (stmt, callback) {
            this.log("sendStatement");

            // would prefer to use .bind instead of 'self'
            var self = this,
                lrs,
                statement = this.prepareStatement(stmt),
                rsCount = this.recordStores.length,
                i,
                results = [],
                callbackWrapper,
                callbackResults = []
            ;

            if (rsCount > 0) {
                /*
                   if there is a callback that is a function then we need
                   to wrap that function with a function that becomes
                   the new callback that reduces a closure count of the
                   requests that don't have allowFail set to true and
                   when that number hits zero then the original callback
                   is executed
                */
                if (typeof callback === "function") {
                    callbackWrapper = function (err, xhr) {
                        var args;

                        self.log("sendStatement - callbackWrapper: " + rsCount);
                        if (rsCount > 1) {
                            rsCount -= 1;
                            callbackResults.push(
                                {
                                    err: err,
                                    xhr: xhr
                                }
                            );
                        }
                        else if (rsCount === 1) {
                            callbackResults.push(
                                {
                                    err: err,
                                    xhr: xhr
                                }
                            );
                            args = [
                                callbackResults,
                                statement
                            ];
                            callback.apply(this, args);
                        }
                        else {
                            self.log("sendStatement - unexpected record store count: " + rsCount);
                        }
                    };
                }

                for (i = 0; i < rsCount; i += 1) {
                    lrs = this.recordStores[i];

                    results.push(
                        lrs.saveStatement(statement, { callback: callbackWrapper })
                    );
                }
            }
            else {
                this.log("[warning] sendStatement: No LRSs added yet (statement not sent)");
                if (typeof callback === "function") {
                    callback.apply(this, [ null, statement ]);
                }
            }

            return {
                statement: statement,
                results: results
            };
        }
function ( stmt , callback ) { this . log ( "sendStatement" ) ; // would prefer to use .bind instead of 'self' var self = this , lrs , statement = this . prepareStatement ( stmt ) , rsCount = this . recordStores . length , i , results = [ ] , callbackWrapper , callbackResults = [ ] ; if ( rsCount > 0 ) { /*
                   if there is a callback that is a function then we need
                   to wrap that function with a function that becomes
                   the new callback that reduces a closure count of the
                   requests that don't have allowFail set to true and
                   when that number hits zero then the original callback
                   is executed
                */ if ( typeof callback === "function" ) { callbackWrapper = function ( err , xhr ) { var args ; self . log ( "sendStatement - callbackWrapper: " + rsCount ) ; if ( rsCount > 1 ) { rsCount -= 1 ; callbackResults . push ( { err : err , xhr : xhr } ) ; } else if ( rsCount === 1 ) { callbackResults . push ( { err : err , xhr : xhr } ) ; args = [ callbackResults , statement ] ; callback . apply ( this , args ) ; } else { self . log ( "sendStatement - unexpected record store count: " + rsCount ) ; } } ; } for ( i = 0 ; i < rsCount ; i += 1 ) { lrs = this . recordStores [ i ] ; results . push ( lrs . saveStatement ( statement , { callback : callbackWrapper } ) ) ; } } else { this . log ( "[warning] sendStatement: No LRSs added yet (statement not sent)" ) ; if ( typeof callback === "function" ) { callback . apply ( this , [ null , statement ] ) ; } } return { statement : statement , results : results } ; }
Calls saveStatement on each configured LRS, provide callback to make it asynchronous

@method sendStatement
@param {TinCan.Statement|Object} statement Send statement to LRS
@param {Function} [callback] Callback function to execute on completion
Calls saveStatement on each configured LRS provide callback to make it asynchronous