@schukai/monster 3.16.1 → 3.17.0
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -17,6 +17,7 @@ import {
|
|
17
17
|
validateObject,
|
18
18
|
validatePrimitive,
|
19
19
|
validateString,
|
20
|
+
validateBoolean,
|
20
21
|
} from "../types/validate.mjs";
|
21
22
|
import {clone} from "../util/clone.mjs";
|
22
23
|
import {Pathfinder} from "./pathfinder.mjs";
|
@@ -186,6 +187,42 @@ function transform(value) {
|
|
186
187
|
validateString(value);
|
187
188
|
return value.toLowerCase();
|
188
189
|
|
190
|
+
case "isundefined":
|
191
|
+
case "is-undefined":
|
192
|
+
return value === undefined;
|
193
|
+
|
194
|
+
case "isnull":
|
195
|
+
case "is-null":
|
196
|
+
return value === null;
|
197
|
+
|
198
|
+
case "isset":
|
199
|
+
case "is-set":
|
200
|
+
return value !== undefined && value !== null;
|
201
|
+
|
202
|
+
case "isnumber":
|
203
|
+
case "is-number":
|
204
|
+
return isPrimitive(value) && !isNaN(value);
|
205
|
+
|
206
|
+
case "isinteger":
|
207
|
+
case "is-integer":
|
208
|
+
return isPrimitive(value) && !isNaN(value) && value % 1 === 0;
|
209
|
+
|
210
|
+
case "isfloat":
|
211
|
+
case "is-float":
|
212
|
+
return isPrimitive(value) && !isNaN(value) && value % 1 !== 0;
|
213
|
+
|
214
|
+
case "isobject":
|
215
|
+
case "is-object":
|
216
|
+
return isObject(value);
|
217
|
+
|
218
|
+
case "isarray":
|
219
|
+
case "is-array":
|
220
|
+
return Array.isArray(value);
|
221
|
+
|
222
|
+
case "not":
|
223
|
+
validateBoolean(value);
|
224
|
+
return !value;
|
225
|
+
|
189
226
|
case "toupper":
|
190
227
|
case "strtoupper":
|
191
228
|
case "touppercase":
|
@@ -497,7 +534,7 @@ function transform(value) {
|
|
497
534
|
|
498
535
|
throw new Error("type not supported");
|
499
536
|
|
500
|
-
|
537
|
+
|
501
538
|
case "map":
|
502
539
|
map = new Map();
|
503
540
|
while (args.length > 0) {
|
@@ -505,13 +542,13 @@ function transform(value) {
|
|
505
542
|
if (keyValue === undefined) {
|
506
543
|
throw new Error("missing key parameter");
|
507
544
|
}
|
508
|
-
|
545
|
+
|
509
546
|
keyValue = keyValue.split("=");
|
510
547
|
map.set(keyValue[0], keyValue[1]);
|
511
548
|
}
|
512
|
-
|
549
|
+
|
513
550
|
return map.get(value);
|
514
|
-
|
551
|
+
|
515
552
|
case "timestamp":
|
516
553
|
date = new Date(value);
|
517
554
|
timestamp = date.getTime();
|
package/source/types/version.mjs
CHANGED
@@ -24,9 +24,31 @@ describe('Transformer', function () {
|
|
24
24
|
|
25
25
|
});
|
26
26
|
|
27
|
+
|
27
28
|
describe('Transformer.run()', function () {
|
28
29
|
|
29
30
|
[
|
31
|
+
['isundefined', "a", false],
|
32
|
+
['isundefined', null, false],
|
33
|
+
['isundefined', undefined, true],
|
34
|
+
['isnull', "a", false],
|
35
|
+
['isnull', null, true],
|
36
|
+
['isset', null, false],
|
37
|
+
['isset', undefined, false],
|
38
|
+
['isset', "", true],
|
39
|
+
['isnumber', "a", false],
|
40
|
+
['isnumber', 4, true],
|
41
|
+
['isnumber', 4.5, true],
|
42
|
+
['isinteger', 4.5, false],
|
43
|
+
['isinteger', 4, true],
|
44
|
+
['isfloat', 5.6, true],
|
45
|
+
['isfloat', 5, false],
|
46
|
+
['isobject', 4, false],
|
47
|
+
['isobject', {}, true],
|
48
|
+
['isarray', [{}], true],
|
49
|
+
['isarray', "a", false],
|
50
|
+
['not', true, false],
|
51
|
+
['not', false, true],
|
30
52
|
['map:a=4:b=5:c=6', "a", "4"],
|
31
53
|
['date', "2023-02-14", "14.2.2023"],
|
32
54
|
['year', "2023-02-14", 2023],
|
package/test/cases/monster.mjs
CHANGED