@percy/config 1.0.5 → 1.0.8
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/dist/utils/merge.js +4 -2
- package/dist/utils/normalize.js +14 -7
- package/package.json +4 -4
package/dist/utils/merge.js
CHANGED
|
@@ -86,15 +86,17 @@ export function map(object, from, to, transform = v => v) {
|
|
|
86
86
|
}, object)));
|
|
87
87
|
} // Steps through an object's properties calling the function with the path and value of each
|
|
88
88
|
|
|
89
|
-
function walk(object, fn, path = []) {
|
|
89
|
+
function walk(object, fn, path = [], visited = new Set()) {
|
|
90
90
|
if (path.length && fn([...path], object) === false) return;
|
|
91
|
+
if (visited.has(object)) return;
|
|
92
|
+
visited.add(object);
|
|
91
93
|
|
|
92
94
|
if (object != null && typeof object === 'object') {
|
|
93
95
|
let isArrayObject = isArray(object);
|
|
94
96
|
|
|
95
97
|
for (let [key, value] of entries(object)) {
|
|
96
98
|
if (isArrayObject) key = parseInt(key, 10);
|
|
97
|
-
walk(value, fn, [...path, key]);
|
|
99
|
+
walk(value, fn, [...path, key], new Set(visited));
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
} // Recursively mutate and filter empty values from arrays and objects
|
package/dist/utils/normalize.js
CHANGED
|
@@ -24,19 +24,26 @@ export function normalize(object, options) {
|
|
|
24
24
|
schema: options
|
|
25
25
|
};
|
|
26
26
|
let keycase = (_options = options) !== null && _options !== void 0 && _options.kebab ? kebabcase : camelcase;
|
|
27
|
-
return merge([object, (_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.overrides], path => {
|
|
27
|
+
return merge([object, (_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.overrides], (path, value) => {
|
|
28
28
|
var _options3, _schemas$shift;
|
|
29
29
|
|
|
30
30
|
let schemas = getSchema((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.schema, path.map(camelcase));
|
|
31
31
|
let skip = ((_schemas$shift = schemas.shift()) === null || _schemas$shift === void 0 ? void 0 : _schemas$shift.normalize) === false;
|
|
32
|
-
|
|
33
|
-
var _schemas$i;
|
|
32
|
+
let mapped = []; // skip normalizing paths of class instances
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
if (!skip && typeof value === 'object' && value !== null && value !== void 0 && value.constructor) {
|
|
35
|
+
skip = Object.getPrototypeOf(value) !== Object.prototype;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (let [i, k] of path.entries()) {
|
|
39
|
+
var _options4, _options4$skip, _schemas$i;
|
|
40
|
+
|
|
41
|
+
skip || (skip = (_options4 = options) === null || _options4 === void 0 ? void 0 : (_options4$skip = _options4.skip) === null || _options4$skip === void 0 ? void 0 : _options4$skip.call(_options4, mapped.concat(k)));
|
|
42
|
+
mapped.push(skip ? k : keycase(k));
|
|
36
43
|
skip || (skip = ((_schemas$i = schemas[i]) === null || _schemas$i === void 0 ? void 0 : _schemas$i.normalize) === false);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return [
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return [mapped];
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
export default normalize;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"test:types": "tsd"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@percy/logger": "1.0.
|
|
37
|
+
"@percy/logger": "1.0.8",
|
|
38
38
|
"ajv": "^8.6.2",
|
|
39
39
|
"cosmiconfig": "^7.0.0",
|
|
40
|
-
"yaml": "^
|
|
40
|
+
"yaml": "^2.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"json-schema-typed": "^7.0.3"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "86c0b8916ed78205d3044f29b0384a25a5a93214"
|
|
46
46
|
}
|