main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | var _arity =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_arity.js");
|
---|
| 4 |
|
---|
| 5 | var _curry2 =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./internal/_curry2.js");
|
---|
| 8 | /**
|
---|
| 9 | * Creates a function that is bound to a context.
|
---|
| 10 | * Note: `R.bind` does not provide the additional argument-binding capabilities of
|
---|
| 11 | * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
|
---|
| 12 | *
|
---|
| 13 | * @func
|
---|
| 14 | * @memberOf R
|
---|
| 15 | * @since v0.6.0
|
---|
| 16 | * @category Function
|
---|
| 17 | * @category Object
|
---|
| 18 | * @sig (* -> *) -> {*} -> (* -> *)
|
---|
| 19 | * @param {Function} fn The function to bind to context
|
---|
| 20 | * @param {Object} thisObj The context to bind `fn` to
|
---|
| 21 | * @return {Function} A function that will execute in the context of `thisObj`.
|
---|
| 22 | * @see R.partial
|
---|
| 23 | * @example
|
---|
| 24 | *
|
---|
| 25 | * const log = R.bind(console.log, console);
|
---|
| 26 | * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
|
---|
| 27 | * // logs {a: 2}
|
---|
| 28 | * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | var bind =
|
---|
| 33 | /*#__PURE__*/
|
---|
| 34 | _curry2(function bind(fn, thisObj) {
|
---|
| 35 | return _arity(fn.length, function () {
|
---|
| 36 | return fn.apply(thisObj, arguments);
|
---|
| 37 | });
|
---|
| 38 | });
|
---|
| 39 |
|
---|
| 40 | module.exports = bind; |
---|
Note:
See
TracBrowser
for help on using the repository browser.