twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

index.js (474B)


      1 /**
      2  * Slice reference.
      3  */
      4 
      5 var slice = [].slice;
      6 
      7 /**
      8  * Bind `obj` to `fn`.
      9  *
     10  * @param {Object} obj
     11  * @param {Function|String} fn or string
     12  * @return {Function}
     13  * @api public
     14  */
     15 
     16 module.exports = function(obj, fn){
     17   if ('string' == typeof fn) fn = obj[fn];
     18   if ('function' != typeof fn) throw new Error('bind() requires a function');
     19   var args = slice.call(arguments, 2);
     20   return function(){
     21     return fn.apply(obj, args.concat(slice.call(arguments)));
     22   }
     23 };