MCPcopy
hub / github.com/autoNumeric/autoNumeric / isNegative

Method isNegative

src/AutoNumericHelper.js:500–518  ·  view source on GitHub ↗

* Return `true` if the given number is negative, or if the given string contains a negative sign : * - everywhere in the string (by default), or * - on the first character only if the `checkEverywhere` parameter is set to `false`. * * Note: `-0` is not a negative number since it'

(numberOrNumericString, negativeSignCharacter = '-', checkEverywhere = true)

Source from the content-addressed store, hash-verified

498 * @returns {boolean}
499 */
500 static isNegative(numberOrNumericString, negativeSignCharacter = '-', checkEverywhere = true) {
501 if (numberOrNumericString === negativeSignCharacter) {
502 return true;
503 }
504
505 if (numberOrNumericString === '') {
506 return false;
507 }
508
509 if (AutoNumericHelper.isNumber(numberOrNumericString)) {
510 return numberOrNumericString < 0;
511 }
512
513 if (checkEverywhere) {
514 return this.contains(numberOrNumericString, negativeSignCharacter);
515 }
516
517 return this.isNegativeStrict(numberOrNumericString, negativeSignCharacter);
518 }
519
520 /**
521 * Return `true` if the given string contains a negative sign on the first character (on the far left).

Callers 12

selectNumberMethod · 0.80
validateMethod · 0.80
unformatMethod · 0.80
_toLocaleMethod · 0.80
_addGroupSeparatorsMethod · 0.80
_normalizePartsMethod · 0.80
_formatValueMethod · 0.80

Calls 3

containsMethod · 0.95
isNegativeStrictMethod · 0.95
isNumberMethod · 0.80

Tested by

no test coverage detected