is-kit 1.7.1 → 1.7.3
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.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +23 -15
- package/dist/index.mjs +23 -15
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -345,12 +345,13 @@ declare const isNull: Predicate<null>;
|
|
|
345
345
|
*/
|
|
346
346
|
declare const isPrimitive: Guard<string | number | bigint | boolean | symbol | null | undefined>;
|
|
347
347
|
|
|
348
|
+
type AnyFunction = (...args: never[]) => unknown;
|
|
348
349
|
/**
|
|
349
350
|
* Checks whether a value is a function.
|
|
350
351
|
*
|
|
351
|
-
* @returns Predicate narrowing to
|
|
352
|
+
* @returns Predicate narrowing to a callable value.
|
|
352
353
|
*/
|
|
353
|
-
declare const isFunction: Predicate<
|
|
354
|
+
declare const isFunction: Predicate<AnyFunction>;
|
|
354
355
|
/**
|
|
355
356
|
* Checks for non-null objects (including arrays, dates, etc.).
|
|
356
357
|
*
|
|
@@ -452,13 +453,13 @@ declare const isError: Predicate<Error>;
|
|
|
452
453
|
*
|
|
453
454
|
* @returns Predicate narrowing to `URL` when supported; otherwise always false.
|
|
454
455
|
*/
|
|
455
|
-
declare const isURL:
|
|
456
|
+
declare const isURL: Guard<URL>;
|
|
456
457
|
/**
|
|
457
458
|
* Checks whether a value is a `Blob` (in environments with Blob available).
|
|
458
459
|
*
|
|
459
460
|
* @returns Predicate narrowing to `Blob` when supported; otherwise always false.
|
|
460
461
|
*/
|
|
461
|
-
declare const isBlob:
|
|
462
|
+
declare const isBlob: Guard<Blob>;
|
|
462
463
|
/**
|
|
463
464
|
* Creates a guard that checks whether a value is an instance of `constructor`.
|
|
464
465
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -345,12 +345,13 @@ declare const isNull: Predicate<null>;
|
|
|
345
345
|
*/
|
|
346
346
|
declare const isPrimitive: Guard<string | number | bigint | boolean | symbol | null | undefined>;
|
|
347
347
|
|
|
348
|
+
type AnyFunction = (...args: never[]) => unknown;
|
|
348
349
|
/**
|
|
349
350
|
* Checks whether a value is a function.
|
|
350
351
|
*
|
|
351
|
-
* @returns Predicate narrowing to
|
|
352
|
+
* @returns Predicate narrowing to a callable value.
|
|
352
353
|
*/
|
|
353
|
-
declare const isFunction: Predicate<
|
|
354
|
+
declare const isFunction: Predicate<AnyFunction>;
|
|
354
355
|
/**
|
|
355
356
|
* Checks for non-null objects (including arrays, dates, etc.).
|
|
356
357
|
*
|
|
@@ -452,13 +453,13 @@ declare const isError: Predicate<Error>;
|
|
|
452
453
|
*
|
|
453
454
|
* @returns Predicate narrowing to `URL` when supported; otherwise always false.
|
|
454
455
|
*/
|
|
455
|
-
declare const isURL:
|
|
456
|
+
declare const isURL: Guard<URL>;
|
|
456
457
|
/**
|
|
457
458
|
* Checks whether a value is a `Blob` (in environments with Blob available).
|
|
458
459
|
*
|
|
459
460
|
* @returns Predicate narrowing to `Blob` when supported; otherwise always false.
|
|
460
461
|
*/
|
|
461
|
-
declare const isBlob:
|
|
462
|
+
declare const isBlob: Guard<Blob>;
|
|
462
463
|
/**
|
|
463
464
|
* Creates a guard that checks whether a value is an instance of `constructor`.
|
|
464
465
|
*
|
package/dist/index.js
CHANGED
|
@@ -123,12 +123,19 @@ var OBJECT_TAG_ERROR = "[object Error]";
|
|
|
123
123
|
var getTag = (value) => objectToString.call(value);
|
|
124
124
|
|
|
125
125
|
// src/core/object.ts
|
|
126
|
+
var defineOptionalInstanceGuard = (constructor) => constructor === void 0 ? define(() => false) : define(
|
|
127
|
+
(value) => typeof constructor === "function" && value instanceof constructor
|
|
128
|
+
);
|
|
126
129
|
var isFunction = define(
|
|
127
130
|
(value) => typeof value === "function"
|
|
128
131
|
);
|
|
129
132
|
var isObject = define(
|
|
130
133
|
(value) => typeof value === "object" && value !== null
|
|
131
134
|
);
|
|
135
|
+
var readObjectProperty = (value, key) => {
|
|
136
|
+
if (!isObject(value) && !isFunction(value)) return void 0;
|
|
137
|
+
return value[key];
|
|
138
|
+
};
|
|
132
139
|
var isPlainObject = define((value) => {
|
|
133
140
|
if (!isObject(value)) return false;
|
|
134
141
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -153,18 +160,15 @@ var isWeakMap = define(
|
|
|
153
160
|
var isWeakSet = define(
|
|
154
161
|
(value) => getTag(value) === OBJECT_TAG_WEAK_SET
|
|
155
162
|
);
|
|
156
|
-
var isPromiseLike = define(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (!isObject(value) && !isFunction(value)) return false;
|
|
166
|
-
return isFunction(value[Symbol.asyncIterator]);
|
|
167
|
-
});
|
|
163
|
+
var isPromiseLike = define(
|
|
164
|
+
(value) => isFunction(readObjectProperty(value, "then"))
|
|
165
|
+
);
|
|
166
|
+
var isIterable = define(
|
|
167
|
+
(value) => isFunction(readObjectProperty(value, Symbol.iterator))
|
|
168
|
+
);
|
|
169
|
+
var isAsyncIterable = define(
|
|
170
|
+
(value) => isFunction(readObjectProperty(value, Symbol.asyncIterator))
|
|
171
|
+
);
|
|
168
172
|
var isArrayBuffer = define(
|
|
169
173
|
(value) => getTag(value) === OBJECT_TAG_ARRAY_BUFFER
|
|
170
174
|
);
|
|
@@ -177,8 +181,12 @@ var isTypedArray = define(
|
|
|
177
181
|
var isError = define(
|
|
178
182
|
(value) => value instanceof Error || getTag(value) === OBJECT_TAG_ERROR
|
|
179
183
|
);
|
|
180
|
-
var isURL =
|
|
181
|
-
|
|
184
|
+
var isURL = defineOptionalInstanceGuard(
|
|
185
|
+
typeof URL === "undefined" ? void 0 : URL
|
|
186
|
+
);
|
|
187
|
+
var isBlob = defineOptionalInstanceGuard(
|
|
188
|
+
typeof Blob === "undefined" ? void 0 : Blob
|
|
189
|
+
);
|
|
182
190
|
var isInstanceOf = (constructor) => define((value) => value instanceof constructor);
|
|
183
191
|
|
|
184
192
|
// src/core/equals.ts
|
|
@@ -445,7 +453,7 @@ function setOf(valueGuard) {
|
|
|
445
453
|
var isOptionalSchemaField = define(
|
|
446
454
|
// WHY: Optional fields are represented as a small tagged object so `struct`
|
|
447
455
|
// can distinguish schema metadata from plain predicate functions up front.
|
|
448
|
-
(field) => isObject(field) && field.optional === true &&
|
|
456
|
+
(field) => isObject(field) && field.optional === true && isFunction(field.guard)
|
|
449
457
|
);
|
|
450
458
|
var hasRequiredKeys = (obj, entries) => (
|
|
451
459
|
// WHY: Required fields must be own properties; inherited values should not
|
package/dist/index.mjs
CHANGED
|
@@ -24,12 +24,19 @@ var OBJECT_TAG_ERROR = "[object Error]";
|
|
|
24
24
|
var getTag = (value) => objectToString.call(value);
|
|
25
25
|
|
|
26
26
|
// src/core/object.ts
|
|
27
|
+
var defineOptionalInstanceGuard = (constructor) => constructor === void 0 ? define(() => false) : define(
|
|
28
|
+
(value) => typeof constructor === "function" && value instanceof constructor
|
|
29
|
+
);
|
|
27
30
|
var isFunction = define(
|
|
28
31
|
(value) => typeof value === "function"
|
|
29
32
|
);
|
|
30
33
|
var isObject = define(
|
|
31
34
|
(value) => typeof value === "object" && value !== null
|
|
32
35
|
);
|
|
36
|
+
var readObjectProperty = (value, key) => {
|
|
37
|
+
if (!isObject(value) && !isFunction(value)) return void 0;
|
|
38
|
+
return value[key];
|
|
39
|
+
};
|
|
33
40
|
var isPlainObject = define((value) => {
|
|
34
41
|
if (!isObject(value)) return false;
|
|
35
42
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -54,18 +61,15 @@ var isWeakMap = define(
|
|
|
54
61
|
var isWeakSet = define(
|
|
55
62
|
(value) => getTag(value) === OBJECT_TAG_WEAK_SET
|
|
56
63
|
);
|
|
57
|
-
var isPromiseLike = define(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (!isObject(value) && !isFunction(value)) return false;
|
|
67
|
-
return isFunction(value[Symbol.asyncIterator]);
|
|
68
|
-
});
|
|
64
|
+
var isPromiseLike = define(
|
|
65
|
+
(value) => isFunction(readObjectProperty(value, "then"))
|
|
66
|
+
);
|
|
67
|
+
var isIterable = define(
|
|
68
|
+
(value) => isFunction(readObjectProperty(value, Symbol.iterator))
|
|
69
|
+
);
|
|
70
|
+
var isAsyncIterable = define(
|
|
71
|
+
(value) => isFunction(readObjectProperty(value, Symbol.asyncIterator))
|
|
72
|
+
);
|
|
69
73
|
var isArrayBuffer = define(
|
|
70
74
|
(value) => getTag(value) === OBJECT_TAG_ARRAY_BUFFER
|
|
71
75
|
);
|
|
@@ -78,8 +82,12 @@ var isTypedArray = define(
|
|
|
78
82
|
var isError = define(
|
|
79
83
|
(value) => value instanceof Error || getTag(value) === OBJECT_TAG_ERROR
|
|
80
84
|
);
|
|
81
|
-
var isURL =
|
|
82
|
-
|
|
85
|
+
var isURL = defineOptionalInstanceGuard(
|
|
86
|
+
typeof URL === "undefined" ? void 0 : URL
|
|
87
|
+
);
|
|
88
|
+
var isBlob = defineOptionalInstanceGuard(
|
|
89
|
+
typeof Blob === "undefined" ? void 0 : Blob
|
|
90
|
+
);
|
|
83
91
|
var isInstanceOf = (constructor) => define((value) => value instanceof constructor);
|
|
84
92
|
|
|
85
93
|
// src/core/equals.ts
|
|
@@ -346,7 +354,7 @@ function setOf(valueGuard) {
|
|
|
346
354
|
var isOptionalSchemaField = define(
|
|
347
355
|
// WHY: Optional fields are represented as a small tagged object so `struct`
|
|
348
356
|
// can distinguish schema metadata from plain predicate functions up front.
|
|
349
|
-
(field) => isObject(field) && field.optional === true &&
|
|
357
|
+
(field) => isObject(field) && field.optional === true && isFunction(field.guard)
|
|
350
358
|
);
|
|
351
359
|
var hasRequiredKeys = (obj, entries) => (
|
|
352
360
|
// WHY: Required fields must be own properties; inherited values should not
|