main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
836 bytes
|
Line | |
---|
1 | import _curry2 from "./internal/_curry2.js";
|
---|
2 | import _dispatchable from "./internal/_dispatchable.js";
|
---|
3 | import _xtap from "./internal/_xtap.js";
|
---|
4 | /**
|
---|
5 | * Runs the given function with the supplied object, then returns the object.
|
---|
6 | *
|
---|
7 | * Acts as a transducer if a transformer is given as second parameter.
|
---|
8 | *
|
---|
9 | * @func
|
---|
10 | * @memberOf R
|
---|
11 | * @since v0.1.0
|
---|
12 | * @category Function
|
---|
13 | * @sig (a -> *) -> a -> a
|
---|
14 | * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away.
|
---|
15 | * @param {*} x
|
---|
16 | * @return {*} `x`.
|
---|
17 | * @example
|
---|
18 | *
|
---|
19 | * const sayX = x => console.log('x is ' + x);
|
---|
20 | * R.tap(sayX, 100); //=> 100
|
---|
21 | * // logs 'x is 100'
|
---|
22 | * @symb R.tap(f, a) = (f(a), a)
|
---|
23 | */
|
---|
24 |
|
---|
25 | var tap =
|
---|
26 | /*#__PURE__*/
|
---|
27 | _curry2(
|
---|
28 | /*#__PURE__*/
|
---|
29 | _dispatchable([], _xtap, function tap(fn, x) {
|
---|
30 | fn(x);
|
---|
31 | return x;
|
---|
32 | }));
|
---|
33 |
|
---|
34 | export default tap; |
---|
Note:
See
TracBrowser
for help on using the repository browser.