@naturalcycles/js-lib 14.170.0 → 14.172.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/dist/error/error.model.d.ts +8 -5
- package/dist/error/error.util.d.ts +16 -0
- package/dist/error/error.util.js +51 -2
- package/dist/http/fetcher.d.ts +8 -0
- package/dist/http/fetcher.js +13 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist-esm/error/error.util.js +50 -2
- package/dist-esm/http/fetcher.js +38 -26
- package/dist-esm/index.js +1 -2
- package/package.json +2 -2
- package/src/error/error.model.ts +9 -8
- package/src/error/error.util.ts +68 -2
- package/src/http/fetcher.ts +16 -3
- package/src/index.ts +1 -2
- package/dist/vendor/is.d.ts +0 -226
- package/dist/vendor/is.js +0 -460
- package/dist-esm/vendor/is.js +0 -457
- package/src/vendor/is.ts +0 -833
package/dist-esm/vendor/is.js
DELETED
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
/// <reference lib="es2018"/>
|
|
2
|
-
/// <reference lib="dom"/>
|
|
3
|
-
/// <reference types="node"/>
|
|
4
|
-
const typedArrayTypeNames = [
|
|
5
|
-
'Int8Array',
|
|
6
|
-
'Uint8Array',
|
|
7
|
-
'Uint8ClampedArray',
|
|
8
|
-
'Int16Array',
|
|
9
|
-
'Uint16Array',
|
|
10
|
-
'Int32Array',
|
|
11
|
-
'Uint32Array',
|
|
12
|
-
'Float32Array',
|
|
13
|
-
'Float64Array',
|
|
14
|
-
'BigInt64Array',
|
|
15
|
-
'BigUint64Array',
|
|
16
|
-
];
|
|
17
|
-
function isTypedArrayName(name) {
|
|
18
|
-
return typedArrayTypeNames.includes(name);
|
|
19
|
-
}
|
|
20
|
-
const objectTypeNames = [
|
|
21
|
-
'Function',
|
|
22
|
-
'Generator',
|
|
23
|
-
'AsyncGenerator',
|
|
24
|
-
'GeneratorFunction',
|
|
25
|
-
'AsyncGeneratorFunction',
|
|
26
|
-
'AsyncFunction',
|
|
27
|
-
'Observable',
|
|
28
|
-
'Array',
|
|
29
|
-
'Buffer',
|
|
30
|
-
'Object',
|
|
31
|
-
'RegExp',
|
|
32
|
-
'Date',
|
|
33
|
-
'Error',
|
|
34
|
-
'Map',
|
|
35
|
-
'Set',
|
|
36
|
-
'WeakMap',
|
|
37
|
-
'WeakSet',
|
|
38
|
-
'ArrayBuffer',
|
|
39
|
-
'SharedArrayBuffer',
|
|
40
|
-
'DataView',
|
|
41
|
-
'Promise',
|
|
42
|
-
'URL',
|
|
43
|
-
'FormData',
|
|
44
|
-
'URLSearchParams',
|
|
45
|
-
'HTMLElement',
|
|
46
|
-
...typedArrayTypeNames,
|
|
47
|
-
];
|
|
48
|
-
function isObjectTypeName(name) {
|
|
49
|
-
return objectTypeNames.includes(name);
|
|
50
|
-
}
|
|
51
|
-
const primitiveTypeNames = [
|
|
52
|
-
'null',
|
|
53
|
-
'undefined',
|
|
54
|
-
'string',
|
|
55
|
-
'number',
|
|
56
|
-
'bigint',
|
|
57
|
-
'boolean',
|
|
58
|
-
'symbol',
|
|
59
|
-
];
|
|
60
|
-
function isPrimitiveTypeName(name) {
|
|
61
|
-
return primitiveTypeNames.includes(name);
|
|
62
|
-
}
|
|
63
|
-
function isOfType(type) {
|
|
64
|
-
return (value) => typeof value === type;
|
|
65
|
-
}
|
|
66
|
-
const { toString } = Object.prototype;
|
|
67
|
-
const getObjectType = (value) => {
|
|
68
|
-
const objectTypeName = toString.call(value).slice(8, -1);
|
|
69
|
-
if (/HTML\w+Element/.test(objectTypeName) && is.domElement(value)) {
|
|
70
|
-
return 'HTMLElement';
|
|
71
|
-
}
|
|
72
|
-
if (isObjectTypeName(objectTypeName)) {
|
|
73
|
-
return objectTypeName;
|
|
74
|
-
}
|
|
75
|
-
return undefined;
|
|
76
|
-
};
|
|
77
|
-
const isObjectOfType = (type) => (value) => getObjectType(value) === type;
|
|
78
|
-
export function is(value) {
|
|
79
|
-
if (value === null) {
|
|
80
|
-
return 'null';
|
|
81
|
-
}
|
|
82
|
-
switch (typeof value) {
|
|
83
|
-
case 'undefined':
|
|
84
|
-
return 'undefined';
|
|
85
|
-
case 'string':
|
|
86
|
-
return 'string';
|
|
87
|
-
case 'number':
|
|
88
|
-
return 'number';
|
|
89
|
-
case 'boolean':
|
|
90
|
-
return 'boolean';
|
|
91
|
-
case 'function':
|
|
92
|
-
return 'Function';
|
|
93
|
-
case 'bigint':
|
|
94
|
-
return 'bigint';
|
|
95
|
-
case 'symbol':
|
|
96
|
-
return 'symbol';
|
|
97
|
-
default:
|
|
98
|
-
}
|
|
99
|
-
if (is.observable(value)) {
|
|
100
|
-
return 'Observable';
|
|
101
|
-
}
|
|
102
|
-
if (is.array(value)) {
|
|
103
|
-
return 'Array';
|
|
104
|
-
}
|
|
105
|
-
if (is.buffer(value)) {
|
|
106
|
-
return 'Buffer';
|
|
107
|
-
}
|
|
108
|
-
const tagType = getObjectType(value);
|
|
109
|
-
if (tagType) {
|
|
110
|
-
return tagType;
|
|
111
|
-
}
|
|
112
|
-
if (value instanceof String ||
|
|
113
|
-
value instanceof Boolean ||
|
|
114
|
-
value instanceof Number) {
|
|
115
|
-
throw new TypeError("Please don't use object wrappers for primitive types");
|
|
116
|
-
}
|
|
117
|
-
return 'Object';
|
|
118
|
-
}
|
|
119
|
-
is.undefined = isOfType('undefined');
|
|
120
|
-
is.string = isOfType('string');
|
|
121
|
-
const isNumberType = isOfType('number');
|
|
122
|
-
is.number = (value) => isNumberType(value) && !is.nan(value);
|
|
123
|
-
is.bigint = isOfType('bigint');
|
|
124
|
-
is.function_ = isOfType('function');
|
|
125
|
-
is.null_ = (value) => value === null;
|
|
126
|
-
is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
|
|
127
|
-
is.boolean = (value) => value === true || value === false;
|
|
128
|
-
is.symbol = isOfType('symbol');
|
|
129
|
-
is.numericString = (value) => is.string(value) && !is.emptyStringOrWhitespace(value) && !Number.isNaN(Number(value));
|
|
130
|
-
is.array = (value, assertion) => {
|
|
131
|
-
if (!Array.isArray(value)) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
if (!is.function_(assertion)) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
return value.every(assertion);
|
|
138
|
-
};
|
|
139
|
-
is.buffer = (value) => { var _a, _b, _c; return (_c = (_b = (_a = value === null || value === void 0 ? void 0 : value.constructor) === null || _a === void 0 ? void 0 : _a.isBuffer) === null || _b === void 0 ? void 0 : _b.call(_a, value)) !== null && _c !== void 0 ? _c : false; };
|
|
140
|
-
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
|
|
141
|
-
is.object = (value) => !is.null_(value) && (typeof value === 'object' || is.function_(value));
|
|
142
|
-
is.iterable = (value) => is.function_(value === null || value === void 0 ? void 0 : value[Symbol.iterator]);
|
|
143
|
-
is.asyncIterable = (value) => is.function_(value === null || value === void 0 ? void 0 : value[Symbol.asyncIterator]);
|
|
144
|
-
is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw);
|
|
145
|
-
is.asyncGenerator = (value) => is.asyncIterable(value) && is.function_(value.next) && is.function_(value.throw);
|
|
146
|
-
is.nativePromise = (value) => isObjectOfType('Promise')(value);
|
|
147
|
-
const hasPromiseAPI = (value) => is.function_(value === null || value === void 0 ? void 0 : value.then) && is.function_(value === null || value === void 0 ? void 0 : value.catch);
|
|
148
|
-
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
|
|
149
|
-
is.generatorFunction = isObjectOfType('GeneratorFunction');
|
|
150
|
-
is.asyncGeneratorFunction = (value) => getObjectType(value) === 'AsyncGeneratorFunction';
|
|
151
|
-
is.asyncFunction = (value) => getObjectType(value) === 'AsyncFunction';
|
|
152
|
-
is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
|
|
153
|
-
is.regExp = isObjectOfType('RegExp');
|
|
154
|
-
is.date = isObjectOfType('Date');
|
|
155
|
-
is.error = isObjectOfType('Error');
|
|
156
|
-
is.map = (value) => isObjectOfType('Map')(value);
|
|
157
|
-
is.set = (value) => isObjectOfType('Set')(value);
|
|
158
|
-
is.weakMap = (value) => isObjectOfType('WeakMap')(value);
|
|
159
|
-
is.weakSet = (value) => isObjectOfType('WeakSet')(value);
|
|
160
|
-
is.int8Array = isObjectOfType('Int8Array');
|
|
161
|
-
is.uint8Array = isObjectOfType('Uint8Array');
|
|
162
|
-
is.uint8ClampedArray = isObjectOfType('Uint8ClampedArray');
|
|
163
|
-
is.int16Array = isObjectOfType('Int16Array');
|
|
164
|
-
is.uint16Array = isObjectOfType('Uint16Array');
|
|
165
|
-
is.int32Array = isObjectOfType('Int32Array');
|
|
166
|
-
is.uint32Array = isObjectOfType('Uint32Array');
|
|
167
|
-
is.float32Array = isObjectOfType('Float32Array');
|
|
168
|
-
is.float64Array = isObjectOfType('Float64Array');
|
|
169
|
-
is.bigInt64Array = isObjectOfType('BigInt64Array');
|
|
170
|
-
is.bigUint64Array = isObjectOfType('BigUint64Array');
|
|
171
|
-
is.arrayBuffer = isObjectOfType('ArrayBuffer');
|
|
172
|
-
is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer');
|
|
173
|
-
is.dataView = isObjectOfType('DataView');
|
|
174
|
-
is.directInstanceOf = (instance, class_) => Object.getPrototypeOf(instance) === class_.prototype;
|
|
175
|
-
is.urlInstance = (value) => isObjectOfType('URL')(value);
|
|
176
|
-
is.urlString = (value) => {
|
|
177
|
-
if (!is.string(value)) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
new URL(value);
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
catch (_a) {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
// TODO: Use the `not` operator with a type guard here when it's available.
|
|
189
|
-
// Example: `is.truthy = (value: unknown): value is (not false | not 0 | not '' | not undefined | not null) => Boolean(value);`
|
|
190
|
-
is.truthy = (value) => Boolean(value);
|
|
191
|
-
// Example: `is.falsy = (value: unknown): value is (not true | 0 | '' | undefined | null) => Boolean(value);`
|
|
192
|
-
is.falsy = (value) => !value;
|
|
193
|
-
is.nan = (value) => Number.isNaN(value);
|
|
194
|
-
is.primitive = (value) => is.null_(value) || isPrimitiveTypeName(typeof value);
|
|
195
|
-
is.integer = (value) => Number.isInteger(value);
|
|
196
|
-
is.safeInteger = (value) => Number.isSafeInteger(value);
|
|
197
|
-
is.plainObject = (value) => {
|
|
198
|
-
// From: https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
|
199
|
-
if (toString.call(value) !== '[object Object]') {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
const prototype = Object.getPrototypeOf(value);
|
|
203
|
-
return prototype === null || prototype === Object.getPrototypeOf({});
|
|
204
|
-
};
|
|
205
|
-
is.typedArray = (value) => isTypedArrayName(getObjectType(value));
|
|
206
|
-
const isValidLength = (value) => is.safeInteger(value) && value >= 0;
|
|
207
|
-
is.arrayLike = (value) => !is.nullOrUndefined(value) &&
|
|
208
|
-
!is.function_(value) &&
|
|
209
|
-
isValidLength(value.length);
|
|
210
|
-
is.inRange = (value, range) => {
|
|
211
|
-
if (is.number(range)) {
|
|
212
|
-
return value >= Math.min(0, range) && value <= Math.max(range, 0);
|
|
213
|
-
}
|
|
214
|
-
if (is.array(range) && range.length === 2) {
|
|
215
|
-
return value >= Math.min(...range) && value <= Math.max(...range);
|
|
216
|
-
}
|
|
217
|
-
throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
|
|
218
|
-
};
|
|
219
|
-
const NODE_TYPE_ELEMENT = 1;
|
|
220
|
-
const DOM_PROPERTIES_TO_CHECK = [
|
|
221
|
-
'innerHTML',
|
|
222
|
-
'ownerDocument',
|
|
223
|
-
'style',
|
|
224
|
-
'attributes',
|
|
225
|
-
'nodeValue',
|
|
226
|
-
];
|
|
227
|
-
is.domElement = (value) => {
|
|
228
|
-
return (is.object(value) &&
|
|
229
|
-
value.nodeType === NODE_TYPE_ELEMENT &&
|
|
230
|
-
is.string(value.nodeName) &&
|
|
231
|
-
!is.plainObject(value) &&
|
|
232
|
-
DOM_PROPERTIES_TO_CHECK.every(property => property in value));
|
|
233
|
-
};
|
|
234
|
-
is.observable = (value) => {
|
|
235
|
-
var _a, _b, _c, _d;
|
|
236
|
-
if (!value) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
if (value === ((_b = (_a = value)[Symbol.observable]) === null || _b === void 0 ? void 0 : _b.call(_a))) {
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
if (value === ((_d = (_c = value)['@@observable']) === null || _d === void 0 ? void 0 : _d.call(_c))) {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
return false;
|
|
246
|
-
};
|
|
247
|
-
is.nodeStream = (value) => is.object(value) && is.function_(value.pipe) && !is.observable(value);
|
|
248
|
-
is.infinite = (value) => value === Infinity || value === -Infinity;
|
|
249
|
-
const isAbsoluteMod2 = (remainder) => (value) => is.integer(value) && Math.abs(value % 2) === remainder;
|
|
250
|
-
is.evenInteger = isAbsoluteMod2(0);
|
|
251
|
-
is.oddInteger = isAbsoluteMod2(1);
|
|
252
|
-
is.emptyArray = (value) => is.array(value) && value.length === 0;
|
|
253
|
-
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
|
|
254
|
-
is.emptyString = (value) => is.string(value) && value.length === 0;
|
|
255
|
-
// TODO: Use `not ''` when the `not` operator is available.
|
|
256
|
-
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
|
257
|
-
const isWhiteSpaceString = (value) => is.string(value) && !/\S/.test(value);
|
|
258
|
-
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
|
|
259
|
-
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
|
|
260
|
-
// TODO: Use `not` operator here to remove `Map` and `Set` from type guard:
|
|
261
|
-
// - https://github.com/Microsoft/TypeScript/pull/29317
|
|
262
|
-
is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0;
|
|
263
|
-
is.emptySet = (value) => is.set(value) && value.size === 0;
|
|
264
|
-
is.nonEmptySet = (value) => is.set(value) && value.size > 0;
|
|
265
|
-
is.emptyMap = (value) => is.map(value) && value.size === 0;
|
|
266
|
-
is.nonEmptyMap = (value) => is.map(value) && value.size > 0;
|
|
267
|
-
// `PropertyKey` is any value that can be used as an object key (string, number, or symbol)
|
|
268
|
-
is.propertyKey = (value) => is.any([is.string, is.number, is.symbol], value);
|
|
269
|
-
is.formData = (value) => isObjectOfType('FormData')(value);
|
|
270
|
-
is.urlSearchParams = (value) => isObjectOfType('URLSearchParams')(value);
|
|
271
|
-
const predicateOnArray = (method, predicate, values) => {
|
|
272
|
-
if (!is.function_(predicate)) {
|
|
273
|
-
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
|
|
274
|
-
}
|
|
275
|
-
if (values.length === 0) {
|
|
276
|
-
throw new TypeError('Invalid number of values');
|
|
277
|
-
}
|
|
278
|
-
return method.call(values, predicate);
|
|
279
|
-
};
|
|
280
|
-
is.any = (predicate, ...values) => {
|
|
281
|
-
const predicates = is.array(predicate) ? predicate : [predicate];
|
|
282
|
-
return predicates.some(singlePredicate => predicateOnArray(Array.prototype.some, singlePredicate, values));
|
|
283
|
-
};
|
|
284
|
-
is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values);
|
|
285
|
-
const assertType = (condition, description, value, options = {}) => {
|
|
286
|
-
if (!condition) {
|
|
287
|
-
const { multipleValues } = options;
|
|
288
|
-
const valuesMessage = multipleValues
|
|
289
|
-
? `received values of types ${[
|
|
290
|
-
...new Set(value.map(singleValue => `\`${is(singleValue)}\``)),
|
|
291
|
-
].join(', ')}`
|
|
292
|
-
: `received value of type \`${is(value)}\``;
|
|
293
|
-
throw new TypeError(`Expected value which is \`${description}\`, ${valuesMessage}.`);
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
export var AssertionTypeDescription;
|
|
297
|
-
(function (AssertionTypeDescription) {
|
|
298
|
-
AssertionTypeDescription["class_"] = "Class";
|
|
299
|
-
AssertionTypeDescription["numericString"] = "string with a number";
|
|
300
|
-
AssertionTypeDescription["nullOrUndefined"] = "null or undefined";
|
|
301
|
-
AssertionTypeDescription["iterable"] = "Iterable";
|
|
302
|
-
AssertionTypeDescription["asyncIterable"] = "AsyncIterable";
|
|
303
|
-
AssertionTypeDescription["nativePromise"] = "native Promise";
|
|
304
|
-
AssertionTypeDescription["urlString"] = "string with a URL";
|
|
305
|
-
AssertionTypeDescription["truthy"] = "truthy";
|
|
306
|
-
AssertionTypeDescription["falsy"] = "falsy";
|
|
307
|
-
AssertionTypeDescription["nan"] = "NaN";
|
|
308
|
-
AssertionTypeDescription["primitive"] = "primitive";
|
|
309
|
-
AssertionTypeDescription["integer"] = "integer";
|
|
310
|
-
AssertionTypeDescription["safeInteger"] = "integer";
|
|
311
|
-
AssertionTypeDescription["plainObject"] = "plain object";
|
|
312
|
-
AssertionTypeDescription["arrayLike"] = "array-like";
|
|
313
|
-
AssertionTypeDescription["typedArray"] = "TypedArray";
|
|
314
|
-
AssertionTypeDescription["domElement"] = "HTMLElement";
|
|
315
|
-
AssertionTypeDescription["nodeStream"] = "Node.js Stream";
|
|
316
|
-
AssertionTypeDescription["infinite"] = "infinite number";
|
|
317
|
-
AssertionTypeDescription["emptyArray"] = "empty array";
|
|
318
|
-
AssertionTypeDescription["nonEmptyArray"] = "non-empty array";
|
|
319
|
-
AssertionTypeDescription["emptyString"] = "empty string";
|
|
320
|
-
AssertionTypeDescription["nonEmptyString"] = "non-empty string";
|
|
321
|
-
AssertionTypeDescription["emptyStringOrWhitespace"] = "empty string or whitespace";
|
|
322
|
-
AssertionTypeDescription["emptyObject"] = "empty object";
|
|
323
|
-
AssertionTypeDescription["nonEmptyObject"] = "non-empty object";
|
|
324
|
-
AssertionTypeDescription["emptySet"] = "empty set";
|
|
325
|
-
AssertionTypeDescription["nonEmptySet"] = "non-empty set";
|
|
326
|
-
AssertionTypeDescription["emptyMap"] = "empty map";
|
|
327
|
-
AssertionTypeDescription["nonEmptyMap"] = "non-empty map";
|
|
328
|
-
AssertionTypeDescription["evenInteger"] = "even integer";
|
|
329
|
-
AssertionTypeDescription["oddInteger"] = "odd integer";
|
|
330
|
-
AssertionTypeDescription["directInstanceOf"] = "T";
|
|
331
|
-
AssertionTypeDescription["inRange"] = "in range";
|
|
332
|
-
AssertionTypeDescription["any"] = "predicate returns truthy for any value";
|
|
333
|
-
AssertionTypeDescription["all"] = "predicate returns truthy for all values";
|
|
334
|
-
})(AssertionTypeDescription || (AssertionTypeDescription = {}));
|
|
335
|
-
export const assert = {
|
|
336
|
-
// Unknowns.
|
|
337
|
-
undefined: (value) => assertType(is.undefined(value), 'undefined', value),
|
|
338
|
-
string: (value) => assertType(is.string(value), 'string', value),
|
|
339
|
-
number: (value) => assertType(is.number(value), 'number', value),
|
|
340
|
-
bigint: (value) => assertType(is.bigint(value), 'bigint', value),
|
|
341
|
-
function_: (value) => assertType(is.function_(value), 'Function', value),
|
|
342
|
-
null_: (value) => assertType(is.null_(value), 'null', value),
|
|
343
|
-
class_: (value) => assertType(is.class_(value), AssertionTypeDescription.class_, value),
|
|
344
|
-
boolean: (value) => assertType(is.boolean(value), 'boolean', value),
|
|
345
|
-
symbol: (value) => assertType(is.symbol(value), 'symbol', value),
|
|
346
|
-
numericString: (value) => assertType(is.numericString(value), AssertionTypeDescription.numericString, value),
|
|
347
|
-
array: (value, assertion) => {
|
|
348
|
-
const assert = assertType;
|
|
349
|
-
assert(is.array(value), 'Array', value);
|
|
350
|
-
if (assertion) {
|
|
351
|
-
value.forEach(assertion);
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
buffer: (value) => assertType(is.buffer(value), 'Buffer', value),
|
|
355
|
-
nullOrUndefined: (value) => assertType(is.nullOrUndefined(value), AssertionTypeDescription.nullOrUndefined, value),
|
|
356
|
-
object: (value) => assertType(is.object(value), 'Object', value),
|
|
357
|
-
iterable: (value) => assertType(is.iterable(value), AssertionTypeDescription.iterable, value),
|
|
358
|
-
asyncIterable: (value) => assertType(is.asyncIterable(value), AssertionTypeDescription.asyncIterable, value),
|
|
359
|
-
generator: (value) => assertType(is.generator(value), 'Generator', value),
|
|
360
|
-
asyncGenerator: (value) => assertType(is.asyncGenerator(value), 'AsyncGenerator', value),
|
|
361
|
-
nativePromise: (value) => assertType(is.nativePromise(value), AssertionTypeDescription.nativePromise, value),
|
|
362
|
-
promise: (value) => assertType(is.promise(value), 'Promise', value),
|
|
363
|
-
generatorFunction: (value) => assertType(is.generatorFunction(value), 'GeneratorFunction', value),
|
|
364
|
-
asyncGeneratorFunction: (value) => assertType(is.asyncGeneratorFunction(value), 'AsyncGeneratorFunction', value),
|
|
365
|
-
asyncFunction: (value) => assertType(is.asyncFunction(value), 'AsyncFunction', value),
|
|
366
|
-
boundFunction: (value) => assertType(is.boundFunction(value), 'Function', value),
|
|
367
|
-
regExp: (value) => assertType(is.regExp(value), 'RegExp', value),
|
|
368
|
-
date: (value) => assertType(is.date(value), 'Date', value),
|
|
369
|
-
error: (value) => assertType(is.error(value), 'Error', value),
|
|
370
|
-
map: (value) => assertType(is.map(value), 'Map', value),
|
|
371
|
-
set: (value) => assertType(is.set(value), 'Set', value),
|
|
372
|
-
weakMap: (value) => assertType(is.weakMap(value), 'WeakMap', value),
|
|
373
|
-
weakSet: (value) => assertType(is.weakSet(value), 'WeakSet', value),
|
|
374
|
-
int8Array: (value) => assertType(is.int8Array(value), 'Int8Array', value),
|
|
375
|
-
uint8Array: (value) => assertType(is.uint8Array(value), 'Uint8Array', value),
|
|
376
|
-
uint8ClampedArray: (value) => assertType(is.uint8ClampedArray(value), 'Uint8ClampedArray', value),
|
|
377
|
-
int16Array: (value) => assertType(is.int16Array(value), 'Int16Array', value),
|
|
378
|
-
uint16Array: (value) => assertType(is.uint16Array(value), 'Uint16Array', value),
|
|
379
|
-
int32Array: (value) => assertType(is.int32Array(value), 'Int32Array', value),
|
|
380
|
-
uint32Array: (value) => assertType(is.uint32Array(value), 'Uint32Array', value),
|
|
381
|
-
float32Array: (value) => assertType(is.float32Array(value), 'Float32Array', value),
|
|
382
|
-
float64Array: (value) => assertType(is.float64Array(value), 'Float64Array', value),
|
|
383
|
-
bigInt64Array: (value) => assertType(is.bigInt64Array(value), 'BigInt64Array', value),
|
|
384
|
-
bigUint64Array: (value) => assertType(is.bigUint64Array(value), 'BigUint64Array', value),
|
|
385
|
-
arrayBuffer: (value) => assertType(is.arrayBuffer(value), 'ArrayBuffer', value),
|
|
386
|
-
sharedArrayBuffer: (value) => assertType(is.sharedArrayBuffer(value), 'SharedArrayBuffer', value),
|
|
387
|
-
dataView: (value) => assertType(is.dataView(value), 'DataView', value),
|
|
388
|
-
urlInstance: (value) => assertType(is.urlInstance(value), 'URL', value),
|
|
389
|
-
urlString: (value) => assertType(is.urlString(value), AssertionTypeDescription.urlString, value),
|
|
390
|
-
truthy: (value) => assertType(is.truthy(value), AssertionTypeDescription.truthy, value),
|
|
391
|
-
falsy: (value) => assertType(is.falsy(value), AssertionTypeDescription.falsy, value),
|
|
392
|
-
nan: (value) => assertType(is.nan(value), AssertionTypeDescription.nan, value),
|
|
393
|
-
primitive: (value) => assertType(is.primitive(value), AssertionTypeDescription.primitive, value),
|
|
394
|
-
integer: (value) => assertType(is.integer(value), AssertionTypeDescription.integer, value),
|
|
395
|
-
safeInteger: (value) => assertType(is.safeInteger(value), AssertionTypeDescription.safeInteger, value),
|
|
396
|
-
plainObject: (value) => assertType(is.plainObject(value), AssertionTypeDescription.plainObject, value),
|
|
397
|
-
typedArray: (value) => assertType(is.typedArray(value), AssertionTypeDescription.typedArray, value),
|
|
398
|
-
arrayLike: (value) => assertType(is.arrayLike(value), AssertionTypeDescription.arrayLike, value),
|
|
399
|
-
domElement: (value) => assertType(is.domElement(value), AssertionTypeDescription.domElement, value),
|
|
400
|
-
observable: (value) => assertType(is.observable(value), 'Observable', value),
|
|
401
|
-
nodeStream: (value) => assertType(is.nodeStream(value), AssertionTypeDescription.nodeStream, value),
|
|
402
|
-
infinite: (value) => assertType(is.infinite(value), AssertionTypeDescription.infinite, value),
|
|
403
|
-
emptyArray: (value) => assertType(is.emptyArray(value), AssertionTypeDescription.emptyArray, value),
|
|
404
|
-
nonEmptyArray: (value) => assertType(is.nonEmptyArray(value), AssertionTypeDescription.nonEmptyArray, value),
|
|
405
|
-
emptyString: (value) => assertType(is.emptyString(value), AssertionTypeDescription.emptyString, value),
|
|
406
|
-
nonEmptyString: (value) => assertType(is.nonEmptyString(value), AssertionTypeDescription.nonEmptyString, value),
|
|
407
|
-
emptyStringOrWhitespace: (value) => assertType(is.emptyStringOrWhitespace(value), AssertionTypeDescription.emptyStringOrWhitespace, value),
|
|
408
|
-
emptyObject: (value) => assertType(is.emptyObject(value), AssertionTypeDescription.emptyObject, value),
|
|
409
|
-
nonEmptyObject: (value) => assertType(is.nonEmptyObject(value), AssertionTypeDescription.nonEmptyObject, value),
|
|
410
|
-
emptySet: (value) => assertType(is.emptySet(value), AssertionTypeDescription.emptySet, value),
|
|
411
|
-
nonEmptySet: (value) => assertType(is.nonEmptySet(value), AssertionTypeDescription.nonEmptySet, value),
|
|
412
|
-
emptyMap: (value) => assertType(is.emptyMap(value), AssertionTypeDescription.emptyMap, value),
|
|
413
|
-
nonEmptyMap: (value) => assertType(is.nonEmptyMap(value), AssertionTypeDescription.nonEmptyMap, value),
|
|
414
|
-
propertyKey: (value) => assertType(is.propertyKey(value), 'PropertyKey', value),
|
|
415
|
-
formData: (value) => assertType(is.formData(value), 'FormData', value),
|
|
416
|
-
urlSearchParams: (value) => assertType(is.urlSearchParams(value), 'URLSearchParams', value),
|
|
417
|
-
// Numbers.
|
|
418
|
-
evenInteger: (value) => assertType(is.evenInteger(value), AssertionTypeDescription.evenInteger, value),
|
|
419
|
-
oddInteger: (value) => assertType(is.oddInteger(value), AssertionTypeDescription.oddInteger, value),
|
|
420
|
-
// Two arguments.
|
|
421
|
-
directInstanceOf: (instance, class_) => assertType(is.directInstanceOf(instance, class_), AssertionTypeDescription.directInstanceOf, instance),
|
|
422
|
-
inRange: (value, range) => assertType(is.inRange(value, range), AssertionTypeDescription.inRange, value),
|
|
423
|
-
// Variadic functions.
|
|
424
|
-
any: (predicate, ...values) => {
|
|
425
|
-
return assertType(is.any(predicate, ...values), AssertionTypeDescription.any, values, {
|
|
426
|
-
multipleValues: true,
|
|
427
|
-
});
|
|
428
|
-
},
|
|
429
|
-
all: (predicate, ...values) => assertType(is.all(predicate, ...values), AssertionTypeDescription.all, values, {
|
|
430
|
-
multipleValues: true,
|
|
431
|
-
}),
|
|
432
|
-
};
|
|
433
|
-
// Some few keywords are reserved, but we'll populate them for Node.js users
|
|
434
|
-
// See https://github.com/Microsoft/TypeScript/issues/2536
|
|
435
|
-
Object.defineProperties(is, {
|
|
436
|
-
class: {
|
|
437
|
-
value: is.class_,
|
|
438
|
-
},
|
|
439
|
-
function: {
|
|
440
|
-
value: is.function_,
|
|
441
|
-
},
|
|
442
|
-
null: {
|
|
443
|
-
value: is.null_,
|
|
444
|
-
},
|
|
445
|
-
});
|
|
446
|
-
Object.defineProperties(assert, {
|
|
447
|
-
class: {
|
|
448
|
-
value: assert.class_,
|
|
449
|
-
},
|
|
450
|
-
function: {
|
|
451
|
-
value: assert.function_,
|
|
452
|
-
},
|
|
453
|
-
null: {
|
|
454
|
-
value: assert.null_,
|
|
455
|
-
},
|
|
456
|
-
});
|
|
457
|
-
// export {Class, TypedArray, ObservableLike, Primitive} from './types';
|