UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

57 lines (56 loc) 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createIsFinite = void 0; var _factory = require("../../utils/factory.js"); const name = 'isFinite'; const dependencies = ['typed', 'isBounded', 'map']; const createIsFinite = exports.createIsFinite = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => { let { typed, isBounded, map } = _ref; /** * Test whether a value is finite. * * Operates elementwise on Array and Matrix values. To test if all entries * of an Array or Matrix are finite, use isBounded. * * Syntax: * * math.isFinite(x) * * Examples: * * math.isFinite(0) // returns true * math.isFinite(NaN) // returns false * math.isFinite(math.bignumber(Infinity)) // returns false * math.isFinite(math.fraction(1,3)) // returns true * math.isFinite(math.complex('2 - 4i')) // returns true * math.isFinite(-10000000000000000n) // returns true * math.isFinite(undefined) // returns false * math.isFinite(null) // returns false * math.isFinite([0.001, -3n, 0]) // Array [true, true, true] * math.isFinite([2, -Infinity, -3]) // Array [true, false, true] * * See also: * * isBounded isNumeric, isPositive, isNegative, isNaN * * History: * * v15.1 Created * * @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x * Value to be tested * @return {boolean | Array | Matrix} * Whether the value, or its entries, are finite, as appropriate * to its type */ return typed(name, { 'Array | Matrix': A => map(A, isBounded), any: x => isBounded(x) }); });