@schukai/monster 3.50.0 → 3.51.1

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.50.0",
3
+ "version": "3.51.1",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -18,7 +18,7 @@ import {
18
18
  ATTRIBUTE_UPDATER_REMOVE,
19
19
  ATTRIBUTE_UPDATER_REPLACE,
20
20
  ATTRIBUTE_UPDATER_SELECT_THIS,
21
- } from "../dom/constants.mjs";
21
+ } from "./constants.mjs";
22
22
 
23
23
  import { Base } from "../types/base.mjs";
24
24
  import { isArray, isInstance, isIterable } from "../types/is.mjs";
@@ -22,7 +22,7 @@ function extractKeys(obj, keyPrefix = "", keySeparator = "-", valueSeparator = "
22
22
 
23
23
  function helper(currentObj, currentKeyPrefix, currentValuePrefix) {
24
24
  for (const key in currentObj) {
25
- if (typeof currentObj[key] === "object" && !Array.isArray(currentObj[key])) {
25
+ if (currentObj[key] !== null && typeof currentObj[key] === "object" && !Array.isArray(currentObj[key])) {
26
26
  const newKeyPrefix = currentKeyPrefix
27
27
  ? currentKeyPrefix + keySeparator + key.toLowerCase()
28
28
  : key.toLowerCase();
@@ -41,3 +41,4 @@ function extractKeys(obj, keyPrefix = "", keySeparator = "-", valueSeparator = "
41
41
  helper(obj, keyPrefix, keyPrefix);
42
42
  return resultMap;
43
43
  }
44
+
@@ -59,10 +59,6 @@ class ProxyObserver extends Base {
59
59
  }
60
60
 
61
61
  /**
62
- * Get the real object
63
- *
64
- * Changes to this object are not noticed by the observers, so you can make a large number of changes and inform the observers later.
65
- *
66
62
  * @returns {object}
67
63
  */
68
64
  getSubject() {
@@ -86,8 +82,10 @@ class ProxyObserver extends Base {
86
82
  }
87
83
 
88
84
  /**
89
- * get the proxied object
85
+ * Get the real object
90
86
  *
87
+ * Changes to this object are not noticed by the observers, so you can make a large number of changes and inform the observers later.
88
+ *
91
89
  * @returns {object}
92
90
  */
93
91
  getRealSubject() {
@@ -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.50.0");
145
+ monsterVersion = new Version("3.51.1");
146
146
 
147
147
  return monsterVersion;
148
148
  }
@@ -0,0 +1,64 @@
1
+ import {expect} from 'chai';
2
+ import {extractKeys} from "../../../../../application/source/dom/util/extract-keys.mjs";
3
+
4
+
5
+ describe('extractKeys', () => {
6
+ it('should extract keys from the given object', () => {
7
+ const obj = {
8
+ firstName: 'John',
9
+ lastName: 'Doe',
10
+ address: {
11
+ street: '123 Main St',
12
+ city: 'New York',
13
+ },
14
+ };
15
+
16
+ const expected = new Map([
17
+ ['firstname', 'firstName'],
18
+ ['lastname', 'lastName'],
19
+ ['address-street', 'address.street'],
20
+ ['address-city', 'address.city'],
21
+ ]);
22
+
23
+ const result = extractKeys(obj);
24
+
25
+ expect(JSON.stringify(Array.from(result))).to.equal(JSON.stringify(Array.from(expected)));
26
+ });
27
+
28
+ it('should use custom key and value separators', () => {
29
+ const obj = {
30
+ firstName: 'John',
31
+ lastName: 'Doe',
32
+ };
33
+
34
+ const expected = new Map([
35
+ ['prefix+firstname', 'prefix+firstName'],
36
+ ['prefix+lastname', 'prefix+lastName'],
37
+ ]);
38
+
39
+ const result = extractKeys(obj, 'prefix', '+', '+');
40
+
41
+ expect(JSON.stringify(Array.from(result))).to.equal(JSON.stringify(Array.from(expected)));
42
+ });
43
+
44
+ it('check if value is null', () => {
45
+ const obj = {
46
+ firstName: 'John',
47
+ lastName: 'Doe',
48
+ address: null,
49
+ };
50
+
51
+ const expected = new Map([
52
+ ['firstname', 'firstName'],
53
+ ['lastname', 'lastName'],
54
+ ['address', 'address'],
55
+
56
+ ]);
57
+
58
+ const result = extractKeys(obj);
59
+
60
+ expect(JSON.stringify(Array.from(result))).to.equal(JSON.stringify(Array.from(expected)));
61
+ });
62
+
63
+ // Add more test cases as needed
64
+ });
@@ -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.50.0")
10
+ monsterVersion = new Version("3.51.1")
11
11
 
12
12
  let m = getMonsterVersion();
13
13