isNaN.js (2029B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createIsNaN = void 0; 7 8 var _collection = require("../../utils/collection.js"); 9 10 var _factory = require("../../utils/factory.js"); 11 12 var _index = require("../../plain/number/index.js"); 13 14 var name = 'isNaN'; 15 var dependencies = ['typed']; 16 var createIsNaN = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) { 17 var typed = _ref.typed; 18 19 /** 20 * Test whether a value is NaN (not a number). 21 * The function supports types `number`, `BigNumber`, `Fraction`, `Unit` and `Complex`. 22 * 23 * The function is evaluated element-wise in case of Array or Matrix input. 24 * 25 * Syntax: 26 * 27 * math.isNaN(x) 28 * 29 * Examples: 30 * 31 * math.isNaN(3) // returns false 32 * math.isNaN(NaN) // returns true 33 * math.isNaN(0) // returns false 34 * math.isNaN(math.bignumber(NaN)) // returns true 35 * math.isNaN(math.bignumber(0)) // returns false 36 * math.isNaN(math.fraction(-2, 5)) // returns false 37 * math.isNaN('-2') // returns false 38 * math.isNaN([2, 0, -3, NaN]') // returns [false, false, false, true] 39 * 40 * See also: 41 * 42 * isNumeric, isNegative, isPositive, isZero, isInteger 43 * 44 * @param {number | BigNumber | Fraction | Unit | Array | Matrix} x Value to be tested 45 * @return {boolean} Returns true when `x` is NaN. 46 * Throws an error in case of an unknown data type. 47 */ 48 return typed(name, { 49 number: _index.isNaNNumber, 50 BigNumber: function BigNumber(x) { 51 return x.isNaN(); 52 }, 53 Fraction: function Fraction(x) { 54 return false; 55 }, 56 Complex: function Complex(x) { 57 return x.isNaN(); 58 }, 59 Unit: function Unit(x) { 60 return Number.isNaN(x.value); 61 }, 62 'Array | Matrix': function ArrayMatrix(x) { 63 return (0, _collection.deepMap)(x, Number.isNaN); 64 } 65 }); 66 }); 67 exports.createIsNaN = createIsNaN;