@graphql-tools/utils 11.0.1 → 11.1.0

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/cjs/mergeDeep.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeDeep = mergeDeep;
4
4
  const helpers_js_1 = require("./helpers.js");
5
- function mergeDeep(sources, respectPrototype = false, respectArrays = false, respectArrayLength = false) {
5
+ function mergeDeep(sources, respectPrototype = false, respectArrays = false, respectArrayLength = false, respectNonEnumerableSymbols = false) {
6
6
  if (sources.length === 0) {
7
7
  return;
8
8
  }
@@ -27,7 +27,7 @@ function mergeDeep(sources, respectPrototype = false, respectArrays = false, res
27
27
  return false;
28
28
  });
29
29
  if (respectArrayLength && areArraysInTheSameLength) {
30
- return new Array(expectedLength).fill(null).map((_, index) => mergeDeep(sources.map(source => source[index]), respectPrototype, respectArrays, respectArrayLength));
30
+ return new Array(expectedLength).fill(null).map((_, index) => mergeDeep(sources.map(source => source[index]), respectPrototype, respectArrays, respectArrayLength, respectNonEnumerableSymbols));
31
31
  }
32
32
  if (allArrays) {
33
33
  return sources.flat(1);
@@ -65,12 +65,20 @@ function mergeDeep(sources, respectPrototype = false, respectArrays = false, res
65
65
  output = {};
66
66
  }
67
67
  if (key in output) {
68
- output[key] = mergeDeep([output[key], source[key]], respectPrototype, respectArrays, respectArrayLength);
68
+ output[key] = mergeDeep([output[key], source[key]], respectPrototype, respectArrays, respectArrayLength, respectNonEnumerableSymbols);
69
69
  }
70
70
  else {
71
71
  output[key] = source[key];
72
72
  }
73
73
  }
74
+ if (respectNonEnumerableSymbols && output != null) {
75
+ for (const sym of Object.getOwnPropertySymbols(source)) {
76
+ const descriptor = Object.getOwnPropertyDescriptor(source, sym);
77
+ if (!descriptor.enumerable) {
78
+ Object.defineProperty(output, sym, descriptor);
79
+ }
80
+ }
81
+ }
74
82
  }
75
83
  else if (Array.isArray(source)) {
76
84
  if (!Array.isArray(output)) {
package/esm/mergeDeep.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isSome } from './helpers.js';
2
- export function mergeDeep(sources, respectPrototype = false, respectArrays = false, respectArrayLength = false) {
2
+ export function mergeDeep(sources, respectPrototype = false, respectArrays = false, respectArrayLength = false, respectNonEnumerableSymbols = false) {
3
3
  if (sources.length === 0) {
4
4
  return;
5
5
  }
@@ -24,7 +24,7 @@ export function mergeDeep(sources, respectPrototype = false, respectArrays = fal
24
24
  return false;
25
25
  });
26
26
  if (respectArrayLength && areArraysInTheSameLength) {
27
- return new Array(expectedLength).fill(null).map((_, index) => mergeDeep(sources.map(source => source[index]), respectPrototype, respectArrays, respectArrayLength));
27
+ return new Array(expectedLength).fill(null).map((_, index) => mergeDeep(sources.map(source => source[index]), respectPrototype, respectArrays, respectArrayLength, respectNonEnumerableSymbols));
28
28
  }
29
29
  if (allArrays) {
30
30
  return sources.flat(1);
@@ -62,12 +62,20 @@ export function mergeDeep(sources, respectPrototype = false, respectArrays = fal
62
62
  output = {};
63
63
  }
64
64
  if (key in output) {
65
- output[key] = mergeDeep([output[key], source[key]], respectPrototype, respectArrays, respectArrayLength);
65
+ output[key] = mergeDeep([output[key], source[key]], respectPrototype, respectArrays, respectArrayLength, respectNonEnumerableSymbols);
66
66
  }
67
67
  else {
68
68
  output[key] = source[key];
69
69
  }
70
70
  }
71
+ if (respectNonEnumerableSymbols && output != null) {
72
+ for (const sym of Object.getOwnPropertySymbols(source)) {
73
+ const descriptor = Object.getOwnPropertyDescriptor(source, sym);
74
+ if (!descriptor.enumerable) {
75
+ Object.defineProperty(output, sym, descriptor);
76
+ }
77
+ }
78
+ }
71
79
  }
72
80
  else if (Array.isArray(source)) {
73
81
  if (!Array.isArray(output)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "11.0.1",
3
+ "version": "11.1.0",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -5,5 +5,5 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
5
5
  type UnboxIntersection<T> = T extends {
6
6
  0: infer U;
7
7
  } ? U : never;
8
- export declare function mergeDeep<S extends any[]>(sources: S, respectPrototype?: boolean, respectArrays?: boolean, respectArrayLength?: boolean): UnboxIntersection<UnionToIntersection<BoxedTupleTypes<S>>> & any;
8
+ export declare function mergeDeep<S extends any[]>(sources: S, respectPrototype?: boolean, respectArrays?: boolean, respectArrayLength?: boolean, respectNonEnumerableSymbols?: boolean): UnboxIntersection<UnionToIntersection<BoxedTupleTypes<S>>> & any;
9
9
  export {};
@@ -5,5 +5,5 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
5
5
  type UnboxIntersection<T> = T extends {
6
6
  0: infer U;
7
7
  } ? U : never;
8
- export declare function mergeDeep<S extends any[]>(sources: S, respectPrototype?: boolean, respectArrays?: boolean, respectArrayLength?: boolean): UnboxIntersection<UnionToIntersection<BoxedTupleTypes<S>>> & any;
8
+ export declare function mergeDeep<S extends any[]>(sources: S, respectPrototype?: boolean, respectArrays?: boolean, respectArrayLength?: boolean, respectNonEnumerableSymbols?: boolean): UnboxIntersection<UnionToIntersection<BoxedTupleTypes<S>>> & any;
9
9
  export {};