프로젝트

일반

사용자정보

통계
| 개정판:

root / HServer / 00.Server / 00.Program / node_modules / component-bind / index.js

이력 | 보기 | 이력해설 | 다운로드 (474 Bytes)

1 39 HKM
/**
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
};