ramda
Version:
A practical functional library for JavaScript programmers.
28 lines • 882 B
JavaScript
var _curry2 = /*#__PURE__*/require("./internal/_curry2.js");
var _dispatchable = /*#__PURE__*/require("./internal/_dispatchable.js");
var _xtap = /*#__PURE__*/require("./internal/_xtap.js");
/**
* Runs the given function with the supplied object, then returns the object.
*
* Acts as a transducer if a transformer is given as second parameter.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig (a -> *) -> a -> a
* @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away.
* @param {*} x
* @return {*} `x`.
* @example
*
* const sayX = x => console.log('x is ' + x);
* R.tap(sayX, 100); //=> 100
* // logs 'x is 100'
* @symb R.tap(f, a) = (f(a), a)
*/
var tap = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xtap, function tap(fn, x) {
fn(x);
return x;
}));
module.exports = tap;