Judgment.js
1.62 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import _ from 'lodash'
export const isEmptyValue = function(o) {
return [undefined, null].includes(o)
}
export const isNotEmptyValue = function(o) {
return !isEmptyValue(o)
}
export const isArray = function(o) {
return Array.isArray(o)
}
export const isNotArray = function(o) {
return !isArray(o)
}
export const isEmptyArray = function(o) {
return isArray(o) && o.length === 0
}
export const isNotEmptyArray = function(o) {
return !isEmptyArray(o)
}
export const isObject = function(o) {
return Object.prototype.toString.call(o) === '[object Object]'
}
export const isNotObject = function(o) {
return !isObject(o)
}
export const isEmptyObject = function(o) {
return isObject(o) && Object.keys(o).length === 0
}
export const isNotEmptyObject = function(o) {
return !isEmptyObject(o)
}
export const isDate = function(o) {
return Object.prototype.toString.call(o) === '[object Date]'
}
export const isNotDate = function(o) {
return !isDate(o)
}
export const isEqual = (value, other) => {
return _.isEqual(value, other)
}
export const isNotEqual = (value, other) => {
return !isEqual(value, other)
}
export const isOneOfTheseValues = function(value, expectedValueList) {
for (let expectedValue of expectedValueList)
{
if (isEqual(value, expectedValue))
{
return true
}
}
return false
}
export const isNoneOfTheseValues = function(value, unexpectedValueList) {
for (let unexpectedValue of unexpectedValueList)
{
if (isEqual(value, unexpectedValue))
{
return false
}
}
return true
}