ramda-adjunct
Version:
Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
41 lines (33 loc) • 1.3 kB
JavaScript
;
exports.__esModule = true;
exports["default"] = exports.truncPolyfill = void 0;
var _ramda = require("ramda");
var _curry = _interopRequireDefault(require("ramda/src/internal/_curry1"));
var _Math = _interopRequireDefault(require("./internal/polyfills/Math.trunc"));
var _isFunction = _interopRequireDefault(require("./isFunction"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var truncPolyfill = (0, _curry["default"])(_Math["default"]);
/**
* Returns the integer part of a number by removing any fractional digits.
*
* @func trunc
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/2.15.0|v2.15.0}
* @category Math
* @sig Number | String -> Number
* @param {number|string} number The number to trunc
* @return {number} The integer part of the given number
* @example
*
* RA.trunc(13.37); //=> 13
* RA.trunc(42.84); //=> 42
* RA.trunc(0.123); //=> 0
* RA.trunc(-0.123); //=> -0
* RA.trunc('-1.123'); //=> -1
* RA.trunc(NaN); //=> NaN
* RA.trunc('foo'); //=> NaN
*/
exports.truncPolyfill = truncPolyfill;
var trunc = (0, _isFunction["default"])(Math.trunc) ? (0, _curry["default"])((0, _ramda.bind)(Math.trunc, Math)) : truncPolyfill;
var _default = trunc;
exports["default"] = _default;