@pristine-ts/common 2.0.14 → 2.0.15

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.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Utilities for working with plain objects.
3
+ */
4
+ export declare class ObjectUtil {
5
+ /**
6
+ * Deep-merges `sources` left-to-right into a brand-new object and returns it. This is a
7
+ * dependency-free replacement for `lodash.merge({}, ...sources)`, reproducing the subset
8
+ * of its behaviour the framework relies on when combining a class-level and a method-level
9
+ * route context:
10
+ *
11
+ * - plain objects are merged recursively (a key present on both sides is deep-merged, NOT
12
+ * overwritten — e.g. `@responseHeader` maps from both levels are combined);
13
+ * - arrays are merged by index — element `i` of a later source merges onto element `i` of
14
+ * the earlier one and extra elements are appended (matching lodash, which neither
15
+ * concatenates nor replaces the array wholesale — e.g. `@guard`);
16
+ * - a source value of `undefined` never overwrites an already-present value;
17
+ * - every other value (primitive, function, Date, class instance, ...) from a later source
18
+ * overwrites the earlier one by assignment.
19
+ *
20
+ * None of the `sources` are mutated: plain objects and arrays are cloned into a fresh
21
+ * target as they are merged, so the result shares no references with its inputs.
22
+ */
23
+ static deepMerge(...sources: any[]): any;
24
+ /**
25
+ * Merges the enumerable own properties of `source` into `target` in place. `target` is
26
+ * always an object owned by the caller (never one of the original sources), so mutating it
27
+ * here is safe. Non-object sources (including `undefined`/`null`) are ignored.
28
+ * @private
29
+ */
30
+ private static mergeInto;
31
+ /**
32
+ * Computes the merged value for a single key: recurse into arrays (by index) and plain
33
+ * objects, otherwise take the source value. Always returns a value owned by the target tree
34
+ * (source containers are cloned) so inputs are never aliased.
35
+ * @private
36
+ */
37
+ private static mergeValue;
38
+ /**
39
+ * True only for object literals (`{}`-style or `Object.create(null)`); false for arrays,
40
+ * class instances, Dates, functions, `null` and primitives — i.e. the values `deepMerge`
41
+ * should overwrite rather than recurse into.
42
+ * @private
43
+ */
44
+ private static isPlainObject;
45
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./date.util";
2
2
  export * from "./enum.util";
3
3
  export * from "./metadata.util";
4
+ export * from "./object.util";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pristine-ts/common",
3
- "version": "2.0.14",
3
+ "version": "2.0.15",
4
4
  "description": "",
5
5
  "module": "dist/lib/esm/common.module.js",
6
6
  "main": "dist/lib/cjs/common.module.js",
@@ -63,5 +63,5 @@
63
63
  "src/*.{js,ts}"
64
64
  ]
65
65
  },
66
- "gitHead": "09be6feb8eeb2b0814d070e5005113f58519710b"
66
+ "gitHead": "22ffa953ae37cf2375403614293fed9b1afdf606"
67
67
  }