1 | import { deepMap } from '../../utils/collection.js';
|
2 | import { factory } from '../../utils/factory.js';
|
3 | var name = 'isNumeric';
|
4 | var dependencies = ['typed'];
|
5 | export var createIsNumeric = /* #__PURE__ */factory(name, dependencies, (_ref) => {
|
6 | var {
|
7 | typed
|
8 | } = _ref;
|
9 |
|
10 | /**
|
11 | * Test whether a value is an numeric value.
|
12 | *
|
13 | * The function is evaluated element-wise in case of Array or Matrix input.
|
14 | *
|
15 | * Syntax:
|
16 | *
|
17 | * math.isNumeric(x)
|
18 | *
|
19 | * Examples:
|
20 | *
|
21 | * math.isNumeric(2) // returns true
|
22 | * math.isNumeric('2') // returns false
|
23 | * math.hasNumericValue('2') // returns true
|
24 | * math.isNumeric(0) // returns true
|
25 | * math.isNumeric(math.bignumber(500)) // returns true
|
26 | * math.isNumeric(math.fraction(4)) // returns true
|
27 | * math.isNumeric(math.complex('2-4i') // returns false
|
28 | * math.isNumeric([2.3, 'foo', false]) // returns [true, false, true]
|
29 | *
|
30 | * See also:
|
31 | *
|
32 | * isZero, isPositive, isNegative, isInteger, hasNumericValue
|
33 | *
|
34 | * @param {*} x Value to be tested
|
35 | * @return {boolean} Returns true when `x` is a `number`, `BigNumber`,
|
36 | * `Fraction`, or `boolean`. Returns false for other types.
|
37 | * Throws an error in case of unknown types.
|
38 | */
|
39 | return typed(name, {
|
40 | 'number | BigNumber | Fraction | boolean': function numberBigNumberFractionBoolean() {
|
41 | return true;
|
42 | },
|
43 | 'Complex | Unit | string | null | undefined | Node': function ComplexUnitStringNullUndefinedNode() {
|
44 | return false;
|
45 | },
|
46 | 'Array | Matrix': function ArrayMatrix(x) {
|
47 | return deepMap(x, this);
|
48 | }
|
49 | });
|
50 | }); |
\ | No newline at end of file |