source: node_modules/ramda-adjunct/es/sign.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: 996 bytes
Line 
1import { bind, curryN } from 'ramda';
2import isFunction from './isFunction';
3import ponyfill from './internal/ponyfills/Math.sign';
4export var signPonyfill = curryN(1, ponyfill);
5
6/**
7 * Returns the sign of a number, indicating whether the number is positive, negative or zero.
8 *
9 * @func sign
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} number A number
15 * @return {number} A number representing the sign of the given argument. If the argument is a positive number, negative number, positive zero or negative zero, the function will return 1, -1, 0 or -0 respectively. Otherwise, NaN is returned
16 * @example
17 *
18 * RA.sign(3); // 1
19 * RA.sign(-3); // -1
20 * RA.sign('-3'); // -1
21 * RA.sign(0); // 0
22 * RA.sign(-0); // -0
23 * RA.sign(NaN); // NaN
24 * RA.sign('foo'); // NaN
25 */
26
27var sign = isFunction(Math.sign) ? curryN(1, bind(Math.sign, Math)) : signPonyfill;
28export default sign;
Note: See TracBrowser for help on using the repository browser.