@schukai/monster 3.51.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
@@ -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
|
+
|
package/source/types/version.mjs
CHANGED
@@ -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
|
+
});
|
package/test/cases/monster.mjs
CHANGED