is-what 4.1.15 → 4.1.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,109 +3,74 @@
3
3
  function getType(payload) {
4
4
  return Object.prototype.toString.call(payload).slice(8, -1);
5
5
  }
6
- function isUndefined(payload) {
7
- return getType(payload) === "Undefined";
6
+
7
+ function isAnyObject(payload) {
8
+ return getType(payload) === "Object";
8
9
  }
9
- function isNull(payload) {
10
- return getType(payload) === "Null";
10
+
11
+ function isArray(payload) {
12
+ return getType(payload) === "Array";
13
+ }
14
+
15
+ function isBlob(payload) {
16
+ return getType(payload) === "Blob";
17
+ }
18
+
19
+ function isBoolean(payload) {
20
+ return getType(payload) === "Boolean";
21
+ }
22
+
23
+ function isDate(payload) {
24
+ return getType(payload) === "Date" && !isNaN(payload);
25
+ }
26
+
27
+ function isEmptyArray(payload) {
28
+ return isArray(payload) && payload.length === 0;
11
29
  }
30
+
12
31
  function isPlainObject(payload) {
13
32
  if (getType(payload) !== "Object")
14
33
  return false;
15
34
  const prototype = Object.getPrototypeOf(payload);
16
35
  return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
17
36
  }
18
- function isObject(payload) {
19
- return isPlainObject(payload);
20
- }
37
+
21
38
  function isEmptyObject(payload) {
22
39
  return isPlainObject(payload) && Object.keys(payload).length === 0;
23
40
  }
24
- function isFullObject(payload) {
25
- return isPlainObject(payload) && Object.keys(payload).length > 0;
26
- }
27
- function isAnyObject(payload) {
28
- return getType(payload) === "Object";
29
- }
30
- function isObjectLike(payload) {
31
- return isAnyObject(payload);
41
+
42
+ function isEmptyString(payload) {
43
+ return payload === "";
32
44
  }
33
- function isFunction(payload) {
34
- return typeof payload === "function";
45
+
46
+ function isError(payload) {
47
+ return getType(payload) === "Error" || payload instanceof Error;
35
48
  }
36
- function isArray(payload) {
37
- return getType(payload) === "Array";
49
+
50
+ function isFile(payload) {
51
+ return getType(payload) === "File";
38
52
  }
53
+
39
54
  function isFullArray(payload) {
40
55
  return isArray(payload) && payload.length > 0;
41
56
  }
42
- function isEmptyArray(payload) {
43
- return isArray(payload) && payload.length === 0;
57
+
58
+ function isFullObject(payload) {
59
+ return isPlainObject(payload) && Object.keys(payload).length > 0;
44
60
  }
61
+
45
62
  function isString(payload) {
46
63
  return getType(payload) === "String";
47
64
  }
65
+
48
66
  function isFullString(payload) {
49
67
  return isString(payload) && payload !== "";
50
68
  }
51
- function isEmptyString(payload) {
52
- return payload === "";
53
- }
54
- function isNumber(payload) {
55
- return getType(payload) === "Number" && !isNaN(payload);
56
- }
57
- function isPositiveNumber(payload) {
58
- return isNumber(payload) && payload > 0;
59
- }
60
- function isNegativeNumber(payload) {
61
- return isNumber(payload) && payload < 0;
62
- }
63
- function isBoolean(payload) {
64
- return getType(payload) === "Boolean";
65
- }
66
- function isRegExp(payload) {
67
- return getType(payload) === "RegExp";
68
- }
69
- function isMap(payload) {
70
- return getType(payload) === "Map";
71
- }
72
- function isWeakMap(payload) {
73
- return getType(payload) === "WeakMap";
74
- }
75
- function isSet(payload) {
76
- return getType(payload) === "Set";
77
- }
78
- function isWeakSet(payload) {
79
- return getType(payload) === "WeakSet";
80
- }
81
- function isSymbol(payload) {
82
- return getType(payload) === "Symbol";
83
- }
84
- function isDate(payload) {
85
- return getType(payload) === "Date" && !isNaN(payload);
86
- }
87
- function isBlob(payload) {
88
- return getType(payload) === "Blob";
89
- }
90
- function isFile(payload) {
91
- return getType(payload) === "File";
92
- }
93
- function isPromise(payload) {
94
- return getType(payload) === "Promise";
95
- }
96
- function isError(payload) {
97
- return getType(payload) === "Error";
98
- }
99
- function isNaNValue(payload) {
100
- return getType(payload) === "Number" && isNaN(payload);
101
- }
102
- function isPrimitive(payload) {
103
- return isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
104
- }
105
- const isNullOrUndefined = isOneOf(isNull, isUndefined);
106
- function isOneOf(a, b, c, d, e) {
107
- return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
69
+
70
+ function isFunction(payload) {
71
+ return typeof payload === "function";
108
72
  }
73
+
109
74
  function isType(payload, type) {
110
75
  if (!(type instanceof Function)) {
111
76
  throw new TypeError("Type must be a function");
@@ -116,6 +81,7 @@ function isType(payload, type) {
116
81
  const name = type.name;
117
82
  return getType(payload) === name || Boolean(payload && payload.constructor === type);
118
83
  }
84
+
119
85
  function isInstanceOf(value, classOrClassName) {
120
86
  if (typeof classOrClassName === "function") {
121
87
  for (let p = value; p; p = Object.getPrototypeOf(p)) {
@@ -134,6 +100,76 @@ function isInstanceOf(value, classOrClassName) {
134
100
  }
135
101
  }
136
102
 
103
+ function isMap(payload) {
104
+ return getType(payload) === "Map";
105
+ }
106
+
107
+ function isNaNValue(payload) {
108
+ return getType(payload) === "Number" && isNaN(payload);
109
+ }
110
+
111
+ function isNumber(payload) {
112
+ return getType(payload) === "Number" && !isNaN(payload);
113
+ }
114
+
115
+ function isNegativeNumber(payload) {
116
+ return isNumber(payload) && payload < 0;
117
+ }
118
+
119
+ function isNull(payload) {
120
+ return getType(payload) === "Null";
121
+ }
122
+
123
+ function isOneOf(a, b, c, d, e) {
124
+ return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
125
+ }
126
+
127
+ function isUndefined(payload) {
128
+ return getType(payload) === "Undefined";
129
+ }
130
+
131
+ const isNullOrUndefined = isOneOf(isNull, isUndefined);
132
+
133
+ function isObject(payload) {
134
+ return isPlainObject(payload);
135
+ }
136
+
137
+ function isObjectLike(payload) {
138
+ return isAnyObject(payload);
139
+ }
140
+
141
+ function isPositiveNumber(payload) {
142
+ return isNumber(payload) && payload > 0;
143
+ }
144
+
145
+ function isSymbol(payload) {
146
+ return getType(payload) === "Symbol";
147
+ }
148
+
149
+ function isPrimitive(payload) {
150
+ return isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
151
+ }
152
+
153
+ function isPromise(payload) {
154
+ return getType(payload) === "Promise";
155
+ }
156
+
157
+ function isRegExp(payload) {
158
+ return getType(payload) === "RegExp";
159
+ }
160
+
161
+ function isSet(payload) {
162
+ return getType(payload) === "Set";
163
+ }
164
+
165
+ function isWeakMap(payload) {
166
+ return getType(payload) === "WeakMap";
167
+ }
168
+
169
+ function isWeakSet(payload) {
170
+ return getType(payload) === "WeakSet";
171
+ }
172
+
137
173
  exports.getType = getType;
138
174
  exports.isAnyObject = isAnyObject;
139
175
  exports.isArray = isArray;