@percy/config 1.0.5 → 1.0.6

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.
@@ -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
@@ -24,11 +24,16 @@ 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 => {
28
- var _options3, _schemas$shift;
27
+ return merge([object, (_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.overrides], (path, value) => {
28
+ var _options3, _schemas$shift, _options4, _options4$skip;
29
29
 
30
30
  let schemas = getSchema((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.schema, path.map(camelcase));
31
- let skip = ((_schemas$shift = schemas.shift()) === null || _schemas$shift === void 0 ? void 0 : _schemas$shift.normalize) === false;
31
+ let skip = ((_schemas$shift = schemas.shift()) === null || _schemas$shift === void 0 ? void 0 : _schemas$shift.normalize) === false || ((_options4 = options) === null || _options4 === void 0 ? void 0 : (_options4$skip = _options4.skip) === null || _options4$skip === void 0 ? void 0 : _options4$skip.call(_options4, path, value)); // skip normalizing paths of class instances
32
+
33
+ if (!skip && typeof value === 'object' && value !== null && value !== void 0 && value.constructor) {
34
+ skip = Object.getPrototypeOf(value) !== Object.prototype;
35
+ }
36
+
32
37
  path = path.map((k, i) => {
33
38
  var _schemas$i;
34
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/config",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "test:types": "tsd"
35
35
  },
36
36
  "dependencies": {
37
- "@percy/logger": "1.0.5",
37
+ "@percy/logger": "1.0.6",
38
38
  "ajv": "^8.6.2",
39
39
  "cosmiconfig": "^7.0.0",
40
40
  "yaml": "^1.10.0"
@@ -42,5 +42,5 @@
42
42
  "devDependencies": {
43
43
  "json-schema-typed": "^7.0.3"
44
44
  },
45
- "gitHead": "7cf12904abb316ab7348332e68c8c0ef68d78097"
45
+ "gitHead": "f883f713ac513635245301622392870ba4018706"
46
46
  }