main
Last change
on this file since e48199a was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1008 bytes
|
Line | |
---|
1 | import { bind, curryN } from 'ramda';
|
---|
2 |
|
---|
3 | import isFunction from './isFunction';
|
---|
4 | import ponyfill from './internal/ponyfills/Math.sign';
|
---|
5 |
|
---|
6 | export const signPonyfill = curryN(1, ponyfill);
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Returns the sign of a number, indicating whether the number is positive, negative or zero.
|
---|
10 | *
|
---|
11 | * @func sign
|
---|
12 | * @memberOf RA
|
---|
13 | * @since {@link https://char0n.github.io/ramda-adjunct/2.15.0|v2.15.0}
|
---|
14 | * @category Math
|
---|
15 | * @sig Number | String -> Number
|
---|
16 | * @param {number} number A number
|
---|
17 | * @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
|
---|
18 | * @example
|
---|
19 | *
|
---|
20 | * RA.sign(3); // 1
|
---|
21 | * RA.sign(-3); // -1
|
---|
22 | * RA.sign('-3'); // -1
|
---|
23 | * RA.sign(0); // 0
|
---|
24 | * RA.sign(-0); // -0
|
---|
25 | * RA.sign(NaN); // NaN
|
---|
26 | * RA.sign('foo'); // NaN
|
---|
27 | */
|
---|
28 |
|
---|
29 | const sign = isFunction(Math.sign)
|
---|
30 | ? curryN(1, bind(Math.sign, Math))
|
---|
31 | : signPonyfill;
|
---|
32 |
|
---|
33 | export default sign;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.