simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

isNumeric.js (1918B)


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