UNPKG

crocks

Version:

A collection of well known Algebraic Datatypes for your utter enjoyment.

22 lines (16 loc) 538 B
/** @license ISC License (c) copyright 2017 original and current authors */ /** @author Ian Hofmann-Hicks (evil) */ var curry = require('../core/curry') var compose = require('../core/compose') var isFunction = require('../core/isFunction') var constant = function (x) { return function () { return x; }; } // tap : (a -> b) -> a -> a function tap(fn, x) { if(!isFunction(fn)) { throw new TypeError( 'tap: Function required for first argument' ) } return compose(constant(x), fn)(x) } module.exports = curry(tap)