JSPM

  • Created
  • Published
  • Downloads 11395
  • Score
    100M100P100Q138066F
  • License MIT

Shim for Math.sign.

Package Exports

  • math-sign-x

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (math-sign-x) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Travis status Dependency status devDependency status npm version

math-sign-x

Shim for Math.sign.

math-sign-x.sign2016number

This method returns the sign of a number, indicating whether the number is positive, negative or zero. (ES2016)

Kind: static property of math-sign-x
Returns: 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.

Param Type Description
x * A number.

Example

import {sign2016} from 'math-sign-x';

console.log(sign2016(3)); //  1
console.log(sign2016(-3)); // -1
console.log(sign2016('-3')); // -1
console.log(sign2016(0)); //  0
console.log(sign2016(-0)); // -0
console.log(sign2016(NaN)); // NaN
console.log(sign2016('foo')); // NaN
console.log(sign2016()); // NaN

math-sign-xnumber

This method returns the sign of a number, indicating whether the number is positive, negative or zero. (ES2018)

Kind: static property of math-sign-x
Returns: 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.

Param Type Description
x * A number.

Example

import mathSign from 'math-sign-x';

console.log(mathSign(3)); //  1
console.log(mathSign(-3)); // -1
console.log(mathSign('-3')); // -1
console.log(mathSign(0)); //  0
console.log(mathSign(-0)); // -0
console.log(mathSign(NaN)); // NaN
console.log(mathSign('foo')); // NaN
console.log(mathSign()); // NaN