lib/vendor/sugar.js
function(num) {
      var fn = this, counter = 0, storedArguments = [];
      if(!isNumber(num)) {
        num = 1;
      } else if(num === 0) {
        fn.call();
        return fn;
      }
      return function() {
        var ret;
        storedArguments.push(multiArgs(arguments));
        counter++;
        if(counter == num) {
          ret = fn.call(this, storedArguments);
          counter = 0;
          storedArguments = [];
          return ret;
        }
      }
    }
function(num) {
      var fn = this, counter = 0, storedArguments = [];
      if(!isNumber(num)) {
        num = 1;
      } else if(num === 0) {
        fn.call();
        return fn;
      }
      return function() {
        var ret;
        storedArguments.push(multiArgs(arguments));
        counter++;
        if(counter == num) {
          ret = fn.call(this, storedArguments);
          counter = 0;
          storedArguments = [];
          return ret;
        }
      }
    }
function ( num ) { var fn = this , counter = 0 , storedArguments = [ ] ; if ( ! isNumber ( num ) ) { num = 1 ; } else if ( num === 0 ) { fn . call ( ) ; return fn ; } return function ( ) { var ret ; storedArguments . push ( multiArgs ( arguments ) ) ; counter ++ ; if ( counter == num ) { ret = fn . call ( this , storedArguments ) ; counter = 0 ; storedArguments = [ ] ; return ret ; } } }
*
@method after([num] = 1)
@returns Function
@short Creates a function that will execute after [num] calls.
@extra %after% is useful for running a final callback after a series of asynchronous operations, when the order in which the operations will complete is unknown.
@example

var fn = (function() {
// Will be executed once only
}).after(3); fn(); fn(); fn();

*
* @method after ( [ num ] = 1 ) @returns Function @short Creates a function that will execute after [ num ] calls . @extra %after% is useful for running a final callback after a series of asynchronous operations when the order in which the operations will complete is unknown . @example