is-kit 1.0.2 → 1.0.4
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/README.md +1 -1
- package/dist/index.js +14 -11
- package/dist/index.mjs +14 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# is-kit
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<img src="https://raw.githubusercontent.com/nyaomaru/is-kit/main/docs/public/
|
|
4
|
+
<img src="https://raw.githubusercontent.com/nyaomaru/is-kit/main/docs/public/iskit_image.png" width="600px" align="center" alt="is-kit logo" />
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
package/dist/index.js
CHANGED
|
@@ -144,7 +144,7 @@ var isObject = define(
|
|
|
144
144
|
var isPlainObject = define((value) => {
|
|
145
145
|
if (!isObject(value)) return false;
|
|
146
146
|
const proto = Object.getPrototypeOf(value);
|
|
147
|
-
return proto ===
|
|
147
|
+
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
148
148
|
});
|
|
149
149
|
var isArray = define(Array.isArray);
|
|
150
150
|
var isDate = define(
|
|
@@ -159,15 +159,18 @@ var isMap = define(
|
|
|
159
159
|
var isSet = define(
|
|
160
160
|
(value) => getTag(value) === "[object Set]"
|
|
161
161
|
);
|
|
162
|
-
var isPromiseLike = define(
|
|
163
|
-
(value)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
)
|
|
162
|
+
var isPromiseLike = define((value) => {
|
|
163
|
+
if (!isObject(value) && !isFunction(value)) return false;
|
|
164
|
+
return typeof value.then === "function";
|
|
165
|
+
});
|
|
166
|
+
var isIterable = define((value) => {
|
|
167
|
+
if (!isObject(value) && !isFunction(value)) return false;
|
|
168
|
+
return typeof value[Symbol.iterator] === "function";
|
|
169
|
+
});
|
|
170
|
+
var isAsyncIterable = define((value) => {
|
|
171
|
+
if (!isObject(value) && !isFunction(value)) return false;
|
|
172
|
+
return typeof value[Symbol.asyncIterator] === "function";
|
|
173
|
+
});
|
|
171
174
|
var isArrayBuffer = define(
|
|
172
175
|
(value) => getTag(value) === "[object ArrayBuffer]"
|
|
173
176
|
);
|
|
@@ -272,8 +275,8 @@ function struct(schema, options) {
|
|
|
272
275
|
if (!isPlainObject(input)) return false;
|
|
273
276
|
const obj = input;
|
|
274
277
|
for (const key of Object.keys(schema)) {
|
|
275
|
-
const guard = schema[key];
|
|
276
278
|
if (!(key in obj)) return false;
|
|
279
|
+
const guard = schema[key];
|
|
277
280
|
if (!guard(obj[key])) return false;
|
|
278
281
|
}
|
|
279
282
|
if (options?.exact) {
|
package/dist/index.mjs
CHANGED
|
@@ -69,7 +69,7 @@ var isObject = define(
|
|
|
69
69
|
var isPlainObject = define((value) => {
|
|
70
70
|
if (!isObject(value)) return false;
|
|
71
71
|
const proto = Object.getPrototypeOf(value);
|
|
72
|
-
return proto ===
|
|
72
|
+
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
73
73
|
});
|
|
74
74
|
var isArray = define(Array.isArray);
|
|
75
75
|
var isDate = define(
|
|
@@ -84,15 +84,18 @@ var isMap = define(
|
|
|
84
84
|
var isSet = define(
|
|
85
85
|
(value) => getTag(value) === "[object Set]"
|
|
86
86
|
);
|
|
87
|
-
var isPromiseLike = define(
|
|
88
|
-
(value)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
87
|
+
var isPromiseLike = define((value) => {
|
|
88
|
+
if (!isObject(value) && !isFunction(value)) return false;
|
|
89
|
+
return typeof value.then === "function";
|
|
90
|
+
});
|
|
91
|
+
var isIterable = define((value) => {
|
|
92
|
+
if (!isObject(value) && !isFunction(value)) return false;
|
|
93
|
+
return typeof value[Symbol.iterator] === "function";
|
|
94
|
+
});
|
|
95
|
+
var isAsyncIterable = define((value) => {
|
|
96
|
+
if (!isObject(value) && !isFunction(value)) return false;
|
|
97
|
+
return typeof value[Symbol.asyncIterator] === "function";
|
|
98
|
+
});
|
|
96
99
|
var isArrayBuffer = define(
|
|
97
100
|
(value) => getTag(value) === "[object ArrayBuffer]"
|
|
98
101
|
);
|
|
@@ -197,8 +200,8 @@ function struct(schema, options) {
|
|
|
197
200
|
if (!isPlainObject(input)) return false;
|
|
198
201
|
const obj = input;
|
|
199
202
|
for (const key of Object.keys(schema)) {
|
|
200
|
-
const guard = schema[key];
|
|
201
203
|
if (!(key in obj)) return false;
|
|
204
|
+
const guard = schema[key];
|
|
202
205
|
if (!guard(obj[key])) return false;
|
|
203
206
|
}
|
|
204
207
|
if (options?.exact) {
|