FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mathjs/src/function/utils/hasNumericValue.js at develop · SteveJM/mathjs · GitHub
SteveJM
/
mathjs
Public
forked from
josdejong/mathjs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
mathjs
/
src
/
function
/
utils
/
hasNumericValue.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (42 loc) · 1.55 KB
Breadcrumbs
mathjs
/
src
/
function
/
utils
/
hasNumericValue.js
Copy path
File metadata and controls
44 lines (42 loc) · 1.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import
{
factory
}
from
'../../utils/factory.js'
const
name
=
'hasNumericValue'
const
dependencies
=
[
'typed'
,
'isNumeric'
]
export
const
createHasNumericValue
=
/* #__PURE__ */
factory
(
name
,
dependencies
,
(
{
typed
,
isNumeric
}
)
=>
{
/**
* Test whether a value is an numeric value.
*
* In case of a string, true is returned if the string contains a numeric value.
*
* Syntax:
*
* math.hasNumericValue(x)
*
* Examples:
*
* math.hasNumericValue(2) // returns true
* math.hasNumericValue('2') // returns true
* math.isNumeric('2') // returns false
* math.hasNumericValue(0) // returns true
* math.hasNumericValue(math.bignumber(500)) // returns true
* math.hasNumericValue(math.fraction(4)) // returns true
* math.hasNumericValue(math.complex('2-4i') // returns false
* math.hasNumericValue([2.3, 'foo', false]) // returns [true, false, true]
*
* See also:
*
* isZero, isPositive, isNegative, isInteger, isNumeric
*
*
@param
{
*
} x Value to be tested
*
@return
{
boolean
} Returns true when `x` is a `number`, `BigNumber`,
* `Fraction`, `Boolean`, or a `String` containing number. Returns false for other types.
* Throws an error in case of unknown types.
*/
return
typed
(
name
,
{
string
:
function
(
x
)
{
return
x
.
trim
(
)
.
length
>
0
&&
!
isNaN
(
Number
(
x
)
)
}
,
any
:
function
(
x
)
{
return
isNumeric
(
x
)
}
}
)
}
)
Back
|
FazBrowse Home
|
New Git URL