jsfunx 1.2.4 → 1.3.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/jsfunx.cjs +19 -21
- package/jsfunx.mjs +19 -21
- package/package.json +1 -1
package/jsfunx.cjs
CHANGED
|
@@ -282,6 +282,21 @@ const T = new Proxy(
|
|
|
282
282
|
}
|
|
283
283
|
);
|
|
284
284
|
|
|
285
|
+
/** @type {Set<string | null | undefined>} */
|
|
286
|
+
|
|
287
|
+
const setOfTypes = new Set([
|
|
288
|
+
bi,
|
|
289
|
+
bool,
|
|
290
|
+
fn,
|
|
291
|
+
null,
|
|
292
|
+
num,
|
|
293
|
+
obj,
|
|
294
|
+
str,
|
|
295
|
+
sym,
|
|
296
|
+
undef,
|
|
297
|
+
undefined,
|
|
298
|
+
]);
|
|
299
|
+
|
|
285
300
|
/**
|
|
286
301
|
* Compares a value or a list of values against a given type (or list of types),
|
|
287
302
|
* similar to using `typeof x === y`, but in a more flexible and readable way.
|
|
@@ -298,23 +313,6 @@ const T = new Proxy(
|
|
|
298
313
|
*/
|
|
299
314
|
|
|
300
315
|
function checkType(data, dataType, logic, match, strict) {
|
|
301
|
-
/** @type {Set<string | null | undefined>} */
|
|
302
|
-
|
|
303
|
-
const setOfTypes = new Set([
|
|
304
|
-
and,
|
|
305
|
-
bi,
|
|
306
|
-
bool,
|
|
307
|
-
fn,
|
|
308
|
-
null,
|
|
309
|
-
num,
|
|
310
|
-
obj,
|
|
311
|
-
or,
|
|
312
|
-
str,
|
|
313
|
-
sym,
|
|
314
|
-
undef,
|
|
315
|
-
undefined,
|
|
316
|
-
]);
|
|
317
|
-
|
|
318
316
|
if (!(dataType instanceof Array)) {
|
|
319
317
|
if (!setOfTypes.has(dataType))
|
|
320
318
|
throw new TypeError(`type '${String(dataType)}' undefined !`);
|
|
@@ -761,9 +759,9 @@ function checkType(data, dataType, logic, match, strict) {
|
|
|
761
759
|
}
|
|
762
760
|
|
|
763
761
|
if (data.length !== dataType.length) {
|
|
764
|
-
if (strict)
|
|
762
|
+
if (!$(strict))
|
|
765
763
|
throw new TypeError(
|
|
766
|
-
"length of
|
|
764
|
+
"the length of the dataTypes array must match the number of data items"
|
|
767
765
|
);
|
|
768
766
|
|
|
769
767
|
/** @type {number} */
|
|
@@ -1294,9 +1292,9 @@ function isinstancesof(objs, type, logic, match, strict) {
|
|
|
1294
1292
|
}
|
|
1295
1293
|
|
|
1296
1294
|
if (objs.length !== type.length) {
|
|
1297
|
-
if (strict)
|
|
1295
|
+
if (!$(strict))
|
|
1298
1296
|
throw new TypeError(
|
|
1299
|
-
"length of constructor functions array must match the number of objects"
|
|
1297
|
+
"the length of the constructor functions array must match the number of objects"
|
|
1300
1298
|
);
|
|
1301
1299
|
|
|
1302
1300
|
/** @type {number} */
|
package/jsfunx.mjs
CHANGED
|
@@ -286,6 +286,21 @@ export const T = new Proxy(
|
|
|
286
286
|
}
|
|
287
287
|
);
|
|
288
288
|
|
|
289
|
+
/** @type {Set<string | null | undefined>} */
|
|
290
|
+
|
|
291
|
+
const setOfTypes = new Set([
|
|
292
|
+
bi,
|
|
293
|
+
bool,
|
|
294
|
+
fn,
|
|
295
|
+
null,
|
|
296
|
+
num,
|
|
297
|
+
obj,
|
|
298
|
+
str,
|
|
299
|
+
sym,
|
|
300
|
+
undef,
|
|
301
|
+
undefined,
|
|
302
|
+
]);
|
|
303
|
+
|
|
289
304
|
/**
|
|
290
305
|
* Compares a value or a list of values against a given type (or list of types),
|
|
291
306
|
* similar to using `typeof x === y`, but in a more flexible and readable way.
|
|
@@ -302,23 +317,6 @@ export const T = new Proxy(
|
|
|
302
317
|
*/
|
|
303
318
|
|
|
304
319
|
function checkType(data, dataType, logic, match, strict) {
|
|
305
|
-
/** @type {Set<string | null | undefined>} */
|
|
306
|
-
|
|
307
|
-
const setOfTypes = new Set([
|
|
308
|
-
and,
|
|
309
|
-
bi,
|
|
310
|
-
bool,
|
|
311
|
-
fn,
|
|
312
|
-
null,
|
|
313
|
-
num,
|
|
314
|
-
obj,
|
|
315
|
-
or,
|
|
316
|
-
str,
|
|
317
|
-
sym,
|
|
318
|
-
undef,
|
|
319
|
-
undefined,
|
|
320
|
-
]);
|
|
321
|
-
|
|
322
320
|
if (!(dataType instanceof Array)) {
|
|
323
321
|
if (!setOfTypes.has(dataType))
|
|
324
322
|
throw new TypeError(`type '${String(dataType)}' undefined !`);
|
|
@@ -765,9 +763,9 @@ function checkType(data, dataType, logic, match, strict) {
|
|
|
765
763
|
}
|
|
766
764
|
|
|
767
765
|
if (data.length !== dataType.length) {
|
|
768
|
-
if (strict)
|
|
766
|
+
if (!$(strict))
|
|
769
767
|
throw new TypeError(
|
|
770
|
-
"length of
|
|
768
|
+
"the length of the dataTypes array must match the number of data items"
|
|
771
769
|
);
|
|
772
770
|
|
|
773
771
|
/** @type {number} */
|
|
@@ -1298,9 +1296,9 @@ function isinstancesof(objs, type, logic, match, strict) {
|
|
|
1298
1296
|
}
|
|
1299
1297
|
|
|
1300
1298
|
if (objs.length !== type.length) {
|
|
1301
|
-
if (strict)
|
|
1299
|
+
if (!$(strict))
|
|
1302
1300
|
throw new TypeError(
|
|
1303
|
-
"length of constructor functions array must match the number of objects"
|
|
1301
|
+
"the length of the constructor functions array must match the number of objects"
|
|
1304
1302
|
);
|
|
1305
1303
|
|
|
1306
1304
|
/** @type {number} */
|