raspberryGPIOhtmlserver/node_modules/component-bind/index.js
node_modules/component-bind/index.jsRaw
1/**
2 * Slice reference.
3 */
4
5var 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
16module.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};