@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schukai/monster",
3
- "version": "3.16.1",
3
+ "version": "3.17.0",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -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();
@@ -142,7 +142,7 @@ function getMonsterVersion() {
142
142
  }
143
143
 
144
144
  /** don't touch, replaced by make with package.json version */
145
- monsterVersion = new Version("3.16.1");
145
+ monsterVersion = new Version("3.17.0");
146
146
 
147
147
  return monsterVersion;
148
148
  }
@@ -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],
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version("3.16.1")
10
+ monsterVersion = new Version("3.17.0")
11
11
 
12
12
  let m = getMonsterVersion();
13
13