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
|
Line | |
---|
1 | import _arity from "./internal/_arity.js";
|
---|
2 | import _curry2 from "./internal/_curry2.js";
|
---|
3 | /**
|
---|
4 | * Creates a function that is bound to a context.
|
---|
5 | * Note: `R.bind` does not provide the additional argument-binding capabilities of
|
---|
6 | * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
|
---|
7 | *
|
---|
8 | * @func
|
---|
9 | * @memberOf R
|
---|
10 | * @since v0.6.0
|
---|
11 | * @category Function
|
---|
12 | * @category Object
|
---|
13 | * @sig (* -> *) -> {*} -> (* -> *)
|
---|
14 | * @param {Function} fn The function to bind to context
|
---|
15 | * @param {Object} thisObj The context to bind `fn` to
|
---|
16 | * @return {Function} A function that will execute in the context of `thisObj`.
|
---|
17 | * @see R.partial
|
---|
18 | * @example
|
---|
19 | *
|
---|
20 | * const log = R.bind(console.log, console);
|
---|
21 | * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
|
---|
22 | * // logs {a: 2}
|
---|
23 | * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
|
---|
24 | */
|
---|
25 |
|
---|
26 | var bind =
|
---|
27 | /*#__PURE__*/
|
---|
28 | _curry2(function bind(fn, thisObj) {
|
---|
29 | return _arity(fn.length, function () {
|
---|
30 | return fn.apply(thisObj, arguments);
|
---|
31 | });
|
---|
32 | });
|
---|
33 |
|
---|
34 | export default bind; |
---|
Note:
See
TracBrowser
for help on using the repository browser.