itee-validators 5.3.8 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/builds/itee-validators.cjs.js +278 -277
- package/builds/itee-validators.cjs.js.map +1 -1
- package/builds/itee-validators.cjs.min.js +144 -144
- package/builds/itee-validators.esm.js +210 -205
- package/builds/itee-validators.esm.js.map +1 -1
- package/builds/itee-validators.esm.min.js +97 -97
- package/builds/itee-validators.iife.js +210 -205
- package/builds/itee-validators.iife.js.map +1 -1
- package/builds/itee-validators.iife.min.js +115 -115
- package/package.json +4 -2
- package/sources/cores/arrays/isArray.js +4 -4
- package/sources/cores/arrays/isArrayOfArray.js +2 -2
- package/sources/cores/arrays/isArrayOfBoolean.js +2 -2
- package/sources/cores/arrays/isArrayOfFunction.js +2 -2
- package/sources/cores/arrays/isArrayOfMultiElement.js +1 -1
- package/sources/cores/arrays/isArrayOfNull.js +2 -2
- package/sources/cores/arrays/isArrayOfNumber.js +2 -2
- package/sources/cores/arrays/isArrayOfObject.js +2 -2
- package/sources/cores/arrays/isArrayOfSingleElement.js +1 -1
- package/sources/cores/arrays/isArrayOfString.js +3 -3
- package/sources/cores/arrays/isArrayOfUndefined.js +2 -2
- package/sources/cores/arrays/isEmptyArray.js +2 -2
- package/sources/cores/booleans/isBoolean.js +4 -4
- package/sources/cores/booleans/isTrue.js +2 -2
- package/sources/cores/cores.js +91 -91
- package/sources/cores/functions/isFunction.js +2 -2
- package/sources/cores/numbers/isInfinite.js +13 -19
- package/sources/cores/numbers/isMax.js +2 -2
- package/sources/cores/numbers/isMin.js +2 -2
- package/sources/cores/numbers/isNumber.js +15 -15
- package/sources/cores/numbers/isSafeInteger.js +2 -2
- package/sources/cores/numbers/isZero.js +3 -3
- package/sources/cores/objects/isEmptyObject.js +2 -2
- package/sources/cores/objects/isObject.js +2 -2
- package/sources/cores/strings/isBlankString.js +2 -2
- package/sources/cores/strings/isEmptyString.js +2 -2
- package/sources/cores/strings/isString.js +7 -7
- package/sources/cores/symbols/isSymbol.js +2 -2
- package/sources/cores/tests/isTestUnitGenerator.js +10 -10
- package/sources/cores/typed-arrays/isArrayBuffer.js +2 -2
- package/sources/cores/typed-arrays/isBigInt64Array.js +2 -2
- package/sources/cores/typed-arrays/isBigUint64Array.js +2 -2
- package/sources/cores/typed-arrays/isFloat32Array.js +2 -2
- package/sources/cores/typed-arrays/isFloat64Array.js +2 -2
- package/sources/cores/typed-arrays/isInt16Array.js +2 -2
- package/sources/cores/typed-arrays/isInt32Array.js +2 -2
- package/sources/cores/typed-arrays/isInt8Array.js +2 -2
- package/sources/cores/typed-arrays/isUint16Array.js +2 -2
- package/sources/cores/typed-arrays/isUint32Array.js +2 -2
- package/sources/cores/typed-arrays/isUint8Array.js +2 -2
- package/sources/cores/typed-arrays/isUint8ClampedArray.js +2 -2
- package/sources/cores/voids/isDefined.js +2 -2
- package/sources/cores/voids/isEmpty.js +2 -2
- package/sources/cores/voids/isNull.js +3 -3
- package/sources/cores/voids/isUndefined.js +2 -2
- package/sources/dom/isEventTarget.js +2 -2
- package/sources/file-system/block-devices/isBlockDevicePath.js +9 -9
- package/sources/file-system/block-devices/isValidBlockDevicePath.js +2 -2
- package/sources/file-system/character-devices/isCharacterDevicePath.js +9 -9
- package/sources/file-system/character-devices/isValidCharacterDevicePath.js +2 -2
- package/sources/file-system/directories/isDirectoryPath.js +9 -9
- package/sources/file-system/directories/isEmptyDirectory.js +4 -4
- package/sources/file-system/directories/isValidDirectoryPath.js +2 -2
- package/sources/file-system/fifo-pipes/isFIFOPath.js +9 -9
- package/sources/file-system/fifo-pipes/isValidFIFOPath.js +2 -2
- package/sources/file-system/files/isEmptyFile.js +9 -9
- package/sources/file-system/files/isFilePath.js +9 -9
- package/sources/file-system/files/isValidFilePath.js +2 -2
- package/sources/file-system/paths/isValidPath.js +4 -4
- package/sources/file-system/sockets/isSocketPath.js +9 -9
- package/sources/file-system/sockets/isValidSocketPath.js +2 -2
- package/sources/file-system/symbolic-links/isSymbolicLinkPath.js +9 -9
- package/sources/file-system/symbolic-links/isValidSymbolicLinkPath.js +2 -2
- package/sources/itee-validators.js +1 -14
- package/sources/physics/temperatures/isCelsius.js +2 -2
- package/sources/physics/temperatures/isFahrenheit.js +2 -2
- package/sources/physics/temperatures/isKelvin.js +2 -2
- package/sources/physics/temperatures/isTemperature.js +2 -2
|
@@ -26,7 +26,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
26
26
|
* @param data {*} The data to check against the array of numbers
|
|
27
27
|
* @returns {boolean} true if data is not an empty array where all values are numbers, false otherwise
|
|
28
28
|
*/
|
|
29
|
-
export function isArrayOfNumber
|
|
29
|
+
export function isArrayOfNumber( data ) {
|
|
30
30
|
|
|
31
31
|
if ( isNotArray( data ) ) { return false }
|
|
32
32
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -47,7 +47,7 @@ export function isArrayOfNumber ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the array of numbers
|
|
48
48
|
* @returns {boolean} true if data is not an empty array where all values are not numbers, false otherwise
|
|
49
49
|
*/
|
|
50
|
-
export function isNotArrayOfNumber
|
|
50
|
+
export function isNotArrayOfNumber( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotArray( data ) ) { return true }
|
|
53
53
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -26,7 +26,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
26
26
|
* @param data {*} The data to check against the array of object type
|
|
27
27
|
* @returns {boolean} true if data is an array where all values are of object type, false otherwise
|
|
28
28
|
*/
|
|
29
|
-
export function isArrayOfObject
|
|
29
|
+
export function isArrayOfObject( data ) {
|
|
30
30
|
|
|
31
31
|
if ( isNotArray( data ) ) { return false }
|
|
32
32
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -47,7 +47,7 @@ export function isArrayOfObject ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the array of object type
|
|
48
48
|
* @returns {boolean} true if data is not an array where all values are of object type, false otherwise
|
|
49
49
|
*/
|
|
50
|
-
export function isNotArrayOfObject
|
|
50
|
+
export function isNotArrayOfObject( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotArray( data ) ) { return true }
|
|
53
53
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -24,7 +24,7 @@ import { isNotArray } from './isArray'
|
|
|
24
24
|
* @param data {*} The data to check against the single valued array
|
|
25
25
|
* @returns {boolean} true if data is an array with a single value, false otherwise
|
|
26
26
|
*/
|
|
27
|
-
export function isArrayOfSingleElement
|
|
27
|
+
export function isArrayOfSingleElement( data ) {
|
|
28
28
|
|
|
29
29
|
if ( isNotArray( data ) ) { return false }
|
|
30
30
|
|
|
@@ -26,7 +26,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
26
26
|
* @param data {*} The data to check against the array of strings
|
|
27
27
|
* @returns {boolean} true if data is not an empty array where all values are string, false otherwise
|
|
28
28
|
*/
|
|
29
|
-
export function isArrayOfString
|
|
29
|
+
export function isArrayOfString( data ) {
|
|
30
30
|
|
|
31
31
|
if ( isNotArray( data ) ) { return false }
|
|
32
32
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -47,7 +47,7 @@ export function isArrayOfString ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the array of strings
|
|
48
48
|
* @returns {boolean} true if data is not an empty array where all values are not string, false otherwise
|
|
49
49
|
*/
|
|
50
|
-
export function isNotArrayOfString
|
|
50
|
+
export function isNotArrayOfString( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotArray( data ) ) { return true }
|
|
53
53
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -64,7 +64,7 @@ export function isNotArrayOfString ( data ) {
|
|
|
64
64
|
|
|
65
65
|
// #if IS_REMOVE_ON_BUILD
|
|
66
66
|
|
|
67
|
-
export function isArrayOfString_1
|
|
67
|
+
export function isArrayOfString_1( data ) {
|
|
68
68
|
|
|
69
69
|
if ( !Array.isArray( data ) ) {
|
|
70
70
|
return false
|
|
@@ -26,7 +26,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
26
26
|
* @param data {*} The data to check against the array of undefined
|
|
27
27
|
* @returns {boolean} true if data is not an empty array where all values are undefined, false otherwise
|
|
28
28
|
*/
|
|
29
|
-
export function isArrayOfUndefined
|
|
29
|
+
export function isArrayOfUndefined( data ) {
|
|
30
30
|
|
|
31
31
|
if ( isNotArray( data ) ) { return false }
|
|
32
32
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -47,7 +47,7 @@ export function isArrayOfUndefined ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the array of undefined
|
|
48
48
|
* @returns {boolean} true if data is not an empty array where all values are defined, false otherwise
|
|
49
49
|
*/
|
|
50
|
-
export function isNotArrayOfUndefined
|
|
50
|
+
export function isNotArrayOfUndefined( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotArray( data ) ) { return true }
|
|
53
53
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -24,7 +24,7 @@ import { isNotArray } from './isArray'
|
|
|
24
24
|
* @param data {*} The data to check against the empty array
|
|
25
25
|
* @returns {boolean} true if data is an empty array, false otherwise
|
|
26
26
|
*/
|
|
27
|
-
export function isEmptyArray
|
|
27
|
+
export function isEmptyArray( data ) {
|
|
28
28
|
|
|
29
29
|
if ( isNotArray( data ) ) { return false }
|
|
30
30
|
|
|
@@ -38,7 +38,7 @@ export function isEmptyArray ( data ) {
|
|
|
38
38
|
* @param data {*} The data to check against the empty array
|
|
39
39
|
* @returns {boolean} true if data is not an empty array, false otherwise
|
|
40
40
|
*/
|
|
41
|
-
export function isNotEmptyArray
|
|
41
|
+
export function isNotEmptyArray( data ) {
|
|
42
42
|
|
|
43
43
|
if ( isNotArray( data ) ) { return true }
|
|
44
44
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param data {*} The data to check against the booleaness
|
|
23
23
|
* @returns {boolean} true if data is a boolean, false otherwise.
|
|
24
24
|
*/
|
|
25
|
-
export function isBoolean
|
|
25
|
+
export function isBoolean( data ) {
|
|
26
26
|
return ( typeof data === 'boolean' )
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -32,17 +32,17 @@ export function isBoolean ( data ) {
|
|
|
32
32
|
* @param data {*} The data to check against the booleaness
|
|
33
33
|
* @returns {boolean} true if data is not a boolean, false otherwise.
|
|
34
34
|
*/
|
|
35
|
-
export function isNotBoolean
|
|
35
|
+
export function isNotBoolean( data ) {
|
|
36
36
|
return ( typeof data !== 'boolean' )
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// #if IS_REMOVE_ON_BUILD
|
|
40
40
|
|
|
41
|
-
export function isBoolean_alt
|
|
41
|
+
export function isBoolean_alt( data ) {
|
|
42
42
|
return typeof data === 'boolean' || ( typeof data === 'object' && data !== null && typeof data.valueOf() === 'boolean' )
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export function isNotBoolean_negbase
|
|
45
|
+
export function isNotBoolean_negbase( data ) {
|
|
46
46
|
return !isBoolean( data )
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -24,7 +24,7 @@ import { isBoolean } from './isBoolean'
|
|
|
24
24
|
* @param data {*} The data to check against true value
|
|
25
25
|
* @returns {boolean} true if data is a boolean set to true, false otherwise.
|
|
26
26
|
*/
|
|
27
|
-
export function isTrue
|
|
27
|
+
export function isTrue( data ) {
|
|
28
28
|
return ( isBoolean( data ) && ( data === true ) )
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -34,6 +34,6 @@ export function isTrue ( data ) {
|
|
|
34
34
|
* @param data {*} The data to check against false value
|
|
35
35
|
* @returns {boolean} true if data is a boolean set to false, false otherwise.
|
|
36
36
|
*/
|
|
37
|
-
export function isFalse
|
|
37
|
+
export function isFalse( data ) {
|
|
38
38
|
return ( isBoolean( data ) && ( data === false ) )
|
|
39
39
|
}
|
package/sources/cores/cores.js
CHANGED
|
@@ -12,115 +12,115 @@
|
|
|
12
12
|
// Usefull when a simple data structure is used multiple times
|
|
13
13
|
validator.add( 'ColorType', color => {
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const r = color.r
|
|
16
|
+
if ( color.r === undefined || Itee.Validators.isNotNumber( r ) ) {
|
|
17
|
+
return false
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const g = color.g
|
|
21
|
+
if ( color.g === undefined || Itee.Validators.isNotNumber( g ) ) {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const b = color.b
|
|
26
|
+
if ( color.b === undefined || Itee.Validators.isNotNumber( b ) ) {
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
return true
|
|
31
|
+
} )
|
|
32
32
|
|
|
33
33
|
// Using schema composition
|
|
34
34
|
// Usefull for design validation schema faster and based on previous declared validation types
|
|
35
35
|
validator.add( 'Range_0_255', ( value ) => {
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if ( Itee.Validators.isNotNumber( value ) ) {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
return !(value <= 0 || value > 255)
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
} )
|
|
44
44
|
|
|
45
45
|
validator.add( 'ColorSchema', {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
r: {
|
|
47
|
+
required: true,
|
|
48
|
+
type: 'Range_0_255'
|
|
49
|
+
},
|
|
50
|
+
g: {
|
|
51
|
+
required: true,
|
|
52
|
+
type: 'Range_0_255'
|
|
53
|
+
},
|
|
54
|
+
b: {
|
|
55
|
+
required: true,
|
|
56
|
+
type: 'Range_0_255'
|
|
57
|
+
}
|
|
58
|
+
} )
|
|
59
59
|
|
|
60
60
|
validator.add( 'ColorStructure', {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
61
|
+
color_from_type: {
|
|
62
|
+
type: 'ColorType'
|
|
63
|
+
},
|
|
64
|
+
col_from_schema: {
|
|
65
|
+
type: 'ColorSchema'
|
|
66
|
+
},
|
|
67
|
+
col_from_fn: {
|
|
68
|
+
// Inner function
|
|
69
|
+
// Usefull for specific validation requirement that cannot match other previous validation schema or type
|
|
70
|
+
fn: function ColorValidator ( color ) {
|
|
71
|
+
|
|
72
|
+
const r = color.r
|
|
73
|
+
if ( color.r === undefined || Itee.Validators.isNotNumber( r ) ) {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const g = color.g
|
|
78
|
+
if ( color.g === undefined || Itee.Validators.isNotNumber( g ) ) {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const b = color.b
|
|
83
|
+
if ( color.b === undefined || Itee.Validators.isNotNumber( b ) ) {
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} )
|
|
91
91
|
|
|
92
92
|
// The data to validate
|
|
93
93
|
const colorStruct = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
color_from_type: {
|
|
95
|
+
r: 0,
|
|
96
|
+
g: 1,
|
|
97
|
+
b: 2
|
|
98
|
+
},
|
|
99
|
+
col_from_schema: {
|
|
100
|
+
r: 10,
|
|
101
|
+
g: 20,
|
|
102
|
+
b: 30
|
|
103
|
+
},
|
|
104
|
+
col_from_fn: {
|
|
105
|
+
r: 0,
|
|
106
|
+
g: 127,
|
|
107
|
+
b: 255
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
110
|
|
|
111
111
|
// Execute
|
|
112
112
|
|
|
113
113
|
try {
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
if ( validator.check( colorStruct, 'ColorStructure' ) ) {
|
|
116
|
+
alert( 'ColorStructure is valid !' )
|
|
117
|
+
} else {
|
|
118
|
+
alert( validator.errors )
|
|
119
|
+
}
|
|
120
120
|
|
|
121
|
-
} catch ( err ) {
|
|
122
|
-
|
|
123
|
-
}
|
|
121
|
+
} catch ( err ) {
|
|
122
|
+
alert( err )
|
|
123
|
+
}
|
|
124
124
|
*
|
|
125
125
|
*/
|
|
126
126
|
|
|
@@ -151,7 +151,7 @@ import {
|
|
|
151
151
|
|
|
152
152
|
class Validator {
|
|
153
153
|
|
|
154
|
-
constructor
|
|
154
|
+
constructor() {
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* The validators store, by default it contains validators for Boolean, Number, Integer, Float, Array, String, Object, Symbol and Function
|
|
@@ -185,7 +185,7 @@ class Validator {
|
|
|
185
185
|
* @param type {string} - A string that represent the type of data to validate
|
|
186
186
|
* @param validator {(function|object)} - A function or validation schema that represent the type of data to validate
|
|
187
187
|
*/
|
|
188
|
-
add
|
|
188
|
+
add( type, validator ) {
|
|
189
189
|
|
|
190
190
|
if ( isNotString( type ) ) { throw new TypeError( `Validator: Expect type to be a string` ) }
|
|
191
191
|
if ( isNotFunction( validator ) && isNotObject( validator ) ) { throw new TypeError( `Validator: Expect validator to be an object or a function` ) }
|
|
@@ -200,7 +200,7 @@ class Validator {
|
|
|
200
200
|
*
|
|
201
201
|
* @param type {string} - The type to remove
|
|
202
202
|
*/
|
|
203
|
-
remove
|
|
203
|
+
remove( type ) {
|
|
204
204
|
|
|
205
205
|
delete this.validators[ type ]
|
|
206
206
|
|
|
@@ -211,7 +211,7 @@ class Validator {
|
|
|
211
211
|
*
|
|
212
212
|
* @return {Array.<string>} - The list of registered type
|
|
213
213
|
*/
|
|
214
|
-
getAvalaibleTypes
|
|
214
|
+
getAvalaibleTypes() {
|
|
215
215
|
|
|
216
216
|
const availablesTypes = []
|
|
217
217
|
|
|
@@ -231,7 +231,7 @@ class Validator {
|
|
|
231
231
|
* @param breakOnError {boolean} - Return on first validation error ( true by default )
|
|
232
232
|
* @return {boolean} - Return true is the data is validated, false otherwise
|
|
233
233
|
*/
|
|
234
|
-
check
|
|
234
|
+
check( data, type, breakOnError = true ) {
|
|
235
235
|
|
|
236
236
|
const validator = this.validators[ type ]
|
|
237
237
|
if ( isNotDefined( validator ) ) {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param data {*} The data to check against the functionality
|
|
23
23
|
* @returns {boolean} true if data is a function, false otherwise.
|
|
24
24
|
*/
|
|
25
|
-
export function isFunction
|
|
25
|
+
export function isFunction( data ) {
|
|
26
26
|
return ( typeof data === 'function' )
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -32,6 +32,6 @@ export function isFunction ( data ) {
|
|
|
32
32
|
* @param data {*} The data to check against the functionality
|
|
33
33
|
* @returns {boolean} true if data is not a function, false otherwise.
|
|
34
34
|
*/
|
|
35
|
-
export function isNotFunction
|
|
35
|
+
export function isNotFunction( data ) {
|
|
36
36
|
return ( typeof data !== 'function' )
|
|
37
37
|
}
|
|
@@ -16,22 +16,6 @@
|
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { isNotNumber } from './isNumber'
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Check if the given data is an infinite number
|
|
23
|
-
*
|
|
24
|
-
* @param data {*} The data to check against the infinite state
|
|
25
|
-
* @returns {boolean} true if data is infinite, false otherwise
|
|
26
|
-
*/
|
|
27
|
-
export function isInfinite ( data ) {
|
|
28
|
-
|
|
29
|
-
// Todo: is required to check notnumber ?
|
|
30
|
-
if ( isNotNumber( data ) ) { return false }
|
|
31
|
-
if ( Number.isNaN( data ) ) { return false }
|
|
32
|
-
|
|
33
|
-
return !Number.isFinite( data )
|
|
34
|
-
}
|
|
35
19
|
|
|
36
20
|
/**
|
|
37
21
|
* Check if the given data is an infinite negative number
|
|
@@ -39,7 +23,7 @@ export function isInfinite ( data ) {
|
|
|
39
23
|
* @param data {*} The data to check against the negative infinite state
|
|
40
24
|
* @returns {boolean} true if data is negative infinite, false otherwise
|
|
41
25
|
*/
|
|
42
|
-
export function isInfiniteNegative
|
|
26
|
+
export function isInfiniteNegative( data ) {
|
|
43
27
|
return ( data === Number.NEGATIVE_INFINITY )
|
|
44
28
|
}
|
|
45
29
|
|
|
@@ -49,16 +33,26 @@ export function isInfiniteNegative ( data ) {
|
|
|
49
33
|
* @param data {*} The data to check against the positive infinite state
|
|
50
34
|
* @returns {boolean} true if data is positive infinite, false otherwise
|
|
51
35
|
*/
|
|
52
|
-
export function isInfinitePositive
|
|
36
|
+
export function isInfinitePositive( data ) {
|
|
53
37
|
return ( data === Number.POSITIVE_INFINITY )
|
|
54
38
|
}
|
|
55
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Check if the given data is an infinite number
|
|
42
|
+
*
|
|
43
|
+
* @param data {*} The data to check against the infinite state
|
|
44
|
+
* @returns {boolean} true if data is infinite, false otherwise
|
|
45
|
+
*/
|
|
46
|
+
export function isInfinite( data ) {
|
|
47
|
+
return isInfiniteNegative( data ) || isInfinitePositive( data )
|
|
48
|
+
}
|
|
49
|
+
|
|
56
50
|
/**
|
|
57
51
|
* Check if the given data is a finite number
|
|
58
52
|
*
|
|
59
53
|
* @param data {*} The data to check against the finite state
|
|
60
54
|
* @returns {boolean} true if data is finite, false otherwise
|
|
61
55
|
*/
|
|
62
|
-
export function isFinite
|
|
56
|
+
export function isFinite( data ) {
|
|
63
57
|
return Number.isFinite( data )
|
|
64
58
|
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param data {*} The data to check against the positive maximum state
|
|
23
23
|
* @returns {boolean} true if data is positive maximum, false otherwise
|
|
24
24
|
*/
|
|
25
|
-
export function isMaxPositive
|
|
25
|
+
export function isMaxPositive( data ) {
|
|
26
26
|
return ( data === Number.MAX_VALUE )
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -32,6 +32,6 @@ export function isMaxPositive ( data ) {
|
|
|
32
32
|
* @param data {*} The data to check against the maximum infinite state
|
|
33
33
|
* @returns {boolean} true if data is negative maximum, false otherwise
|
|
34
34
|
*/
|
|
35
|
-
export function isMaxNegative
|
|
35
|
+
export function isMaxNegative( data ) {
|
|
36
36
|
return ( data === -Number.MAX_VALUE )
|
|
37
37
|
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param data {*} The data to check against the positive minimum state
|
|
23
23
|
* @returns {boolean} true if data is positive minimum, false otherwise
|
|
24
24
|
*/
|
|
25
|
-
export function isMinPositive
|
|
25
|
+
export function isMinPositive( data ) {
|
|
26
26
|
return ( data === Number.MIN_VALUE )
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -32,6 +32,6 @@ export function isMinPositive ( data ) {
|
|
|
32
32
|
* @param data {*} The data to check against the minimum infinite state
|
|
33
33
|
* @returns {boolean} true if data is negative minimum, false otherwise
|
|
34
34
|
*/
|
|
35
|
-
export function isMinNegative
|
|
35
|
+
export function isMinNegative( data ) {
|
|
36
36
|
return ( data === -Number.MIN_VALUE )
|
|
37
37
|
}
|
|
@@ -33,7 +33,7 @@ import { isZeroPositive } from './isZero'
|
|
|
33
33
|
* @param data {*} The data to check against the maximum safe integer state
|
|
34
34
|
* @returns {boolean} true if data is a number, false otherwise.
|
|
35
35
|
*/
|
|
36
|
-
export function isNumber
|
|
36
|
+
export function isNumber( data ) {
|
|
37
37
|
|
|
38
38
|
if ( isNotDefined( data ) ) { return false }
|
|
39
39
|
|
|
@@ -47,7 +47,7 @@ export function isNumber ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the positivity
|
|
48
48
|
* @returns {boolean} true if data is a positive number, false otherwise.
|
|
49
49
|
*/
|
|
50
|
-
export function isNumberPositive
|
|
50
|
+
export function isNumberPositive( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotNumber( data ) ) { return false }
|
|
53
53
|
|
|
@@ -62,7 +62,7 @@ export function isNumberPositive ( data ) {
|
|
|
62
62
|
* @param data {*} The data to check against the negativity
|
|
63
63
|
* @returns {boolean} true if data is a negative number, false otherwise.
|
|
64
64
|
*/
|
|
65
|
-
export function isNumberNegative
|
|
65
|
+
export function isNumberNegative( data ) {
|
|
66
66
|
return ( isNumber( data ) && data < 0 )
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -72,7 +72,7 @@ export function isNumberNegative ( data ) {
|
|
|
72
72
|
* @param data {*} The data to check against the number type
|
|
73
73
|
* @returns {boolean} true if data is not of type number or not a number, false otherwise.
|
|
74
74
|
*/
|
|
75
|
-
export function isNotNumber
|
|
75
|
+
export function isNotNumber( data ) {
|
|
76
76
|
return !( isNumber( data ) )
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -82,7 +82,7 @@ export function isNotNumber ( data ) {
|
|
|
82
82
|
* @param data {*} The data to check against the integer state
|
|
83
83
|
* @returns {boolean} true if data is an integer, false otherwise
|
|
84
84
|
*/
|
|
85
|
-
export function isInteger
|
|
85
|
+
export function isInteger( data ) {
|
|
86
86
|
return Number.isInteger( data )
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -92,7 +92,7 @@ export function isInteger ( data ) {
|
|
|
92
92
|
* @param data {*} The data to check against the floating point
|
|
93
93
|
* @returns {boolean} true if data is a float, false otherwise
|
|
94
94
|
*/
|
|
95
|
-
export function isFloat
|
|
95
|
+
export function isFloat( data ) {
|
|
96
96
|
|
|
97
97
|
if ( isNotNumber( data ) ) { return false }
|
|
98
98
|
if ( Number.isNaN( data ) ) { return false }
|
|
@@ -108,46 +108,46 @@ export function isFloat ( data ) {
|
|
|
108
108
|
* @param data {*} The data to check against the NaN state
|
|
109
109
|
* @returns {boolean} true if data is not a number, false otherwise.
|
|
110
110
|
*/
|
|
111
|
-
export function isNaN
|
|
111
|
+
export function isNaN( data ) {
|
|
112
112
|
return Number.isNaN( data )
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
// #if IS_REMOVE_ON_BUILD
|
|
117
117
|
|
|
118
|
-
export function isNumber_0
|
|
118
|
+
export function isNumber_0( data ) {
|
|
119
119
|
return ( typeof data === 'number' && !Number.isNaN( data ) )
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export function isNumber_1
|
|
122
|
+
export function isNumber_1( data ) {
|
|
123
123
|
return ( Number( data ) === data )
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
///
|
|
127
127
|
|
|
128
|
-
export function isInteger_0
|
|
128
|
+
export function isInteger_0( data ) {
|
|
129
129
|
return ( data === 0 && ( 1 / data ) === Number.POSITIVE_INFINITY )
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
export function isInteger_1
|
|
132
|
+
export function isInteger_1( data ) {
|
|
133
133
|
return data % 1 === 0
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
export function isInteger_2
|
|
136
|
+
export function isInteger_2( n ) {
|
|
137
137
|
return n === +n && n === ( n | 0 )
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
export function isInteger_3
|
|
140
|
+
export function isInteger_3( nVal ) {
|
|
141
141
|
return typeof nVal === 'number' && isFinite( nVal ) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor( nVal ) === nVal
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
///
|
|
145
145
|
|
|
146
|
-
export function isFloat_1
|
|
146
|
+
export function isFloat_1( n ) {
|
|
147
147
|
return n === +n && n !== ( n | 0 )
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
export function isFloat_2
|
|
150
|
+
export function isFloat_2( x ) {
|
|
151
151
|
return !!( x % 1 )
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param data {*} The data to check against the maximum safe integer state
|
|
23
23
|
* @returns {boolean} true if data is a maximum safe integer, false otherwise
|
|
24
24
|
*/
|
|
25
|
-
export function isMaxSafeInteger
|
|
25
|
+
export function isMaxSafeInteger( data ) {
|
|
26
26
|
return ( data === Number.MAX_SAFE_INTEGER )
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ export function isMaxSafeInteger ( data ) {
|
|
|
34
34
|
* @param data {*} The data to check against the minimum safe integer state
|
|
35
35
|
* @returns {boolean} true if data is a minimum safe integer, false otherwise
|
|
36
36
|
*/
|
|
37
|
-
export function isMinSafeInteger
|
|
37
|
+
export function isMinSafeInteger( data ) {
|
|
38
38
|
return ( data === Number.MIN_SAFE_INTEGER )
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @param data {*} The data to check against the zero value
|
|
25
25
|
* @returns {boolean} true if data is zero, false otherwise
|
|
26
26
|
*/
|
|
27
|
-
export function isZero
|
|
27
|
+
export function isZero( data ) {
|
|
28
28
|
//Todo protect truthy values
|
|
29
29
|
return ( data === 0 )
|
|
30
30
|
}
|
|
@@ -35,7 +35,7 @@ export function isZero ( data ) {
|
|
|
35
35
|
* @param data {*} The data to check against the positive zero value
|
|
36
36
|
* @returns {boolean} true if data is a positive zero, false otherwise
|
|
37
37
|
*/
|
|
38
|
-
export function isZeroPositive
|
|
38
|
+
export function isZeroPositive( data ) {
|
|
39
39
|
return ( data === 0 && ( 1 / data ) === Number.POSITIVE_INFINITY )
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -45,6 +45,6 @@ export function isZeroPositive ( data ) {
|
|
|
45
45
|
* @param data {*} The data to check against the negative zero value
|
|
46
46
|
* @returns {boolean} true if data is a negative zero, false otherwise
|
|
47
47
|
*/
|
|
48
|
-
export function isZeroNegative
|
|
48
|
+
export function isZeroNegative( data ) {
|
|
49
49
|
return ( data === 0 && ( 1 / data ) === Number.NEGATIVE_INFINITY )
|
|
50
50
|
}
|