source: node_modules/ramda-adjunct/es/trunc.js

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: 858 bytes
Line 
1import { bind, curryN } from 'ramda';
2import ponyfill from './internal/ponyfills/Math.trunc';
3import isFunction from './isFunction';
4export var truncPonyfill = curryN(1, ponyfill);
5
6/**
7 * Returns the integer part of a number by removing any fractional digits.
8 *
9 * @func trunc
10 * @memberOf RA
11 * @since {@link https://char0n.github.io/ramda-adjunct/2.15.0|v2.15.0}
12 * @category Math
13 * @sig Number | String -> Number
14 * @param {number|string} number The number to trunc
15 * @return {number} The integer part of the given number
16 * @example
17 *
18 * RA.trunc(13.37); //=> 13
19 * RA.trunc(42.84); //=> 42
20 * RA.trunc(0.123); //=> 0
21 * RA.trunc(-0.123); //=> -0
22 * RA.trunc('-1.123'); //=> -1
23 * RA.trunc(NaN); //=> NaN
24 * RA.trunc('foo'); //=> NaN
25 */
26
27var trunc = isFunction(Math.trunc) ? curryN(1, bind(Math.trunc, Math)) : truncPonyfill;
28export default trunc;
Note: See TracBrowser for help on using the repository browser.