@hybridly/utils 0.1.0-alpha.0 → 0.1.0-alpha.2

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/index.cjs CHANGED
@@ -335,8 +335,9 @@ function when(condition, data, _default) {
335
335
  }
336
336
  return data;
337
337
  }
338
- function merge(x, y) {
339
- return baseMerge__default(x, y, { arrayMerge: (_, s) => s });
338
+ function merge(x, y, options = {}) {
339
+ const arrayMerge = typeof options?.arrayMerge === "function" ? options.arrayMerge : options?.overwriteArray !== false ? (_, s) => s : void 0;
340
+ return baseMerge__default(x, y, { arrayMerge });
340
341
  }
341
342
  function removeTrailingSlash(string) {
342
343
  return string.replace(/\/+$/, "");
package/dist/index.d.ts CHANGED
@@ -41,7 +41,11 @@ declare function match<TValue extends string | number = string, TReturnValue = u
41
41
  declare function debounce<F extends (...params: any[]) => ReturnType<F>>(fn: F, delay: number): F;
42
42
  declare function value<T>(value: T | (() => T)): T;
43
43
  declare function when<T, D>(condition: any, data: T, _default?: D): T | D | undefined;
44
- declare function merge<T>(x: Partial<T>, y: Partial<T>): T;
44
+ interface MergeOptions {
45
+ overwriteArray?: boolean;
46
+ arrayMerge?: (target: any[], source: any[]) => any[];
47
+ }
48
+ declare function merge<T>(x: Partial<T>, y: Partial<T>, options?: MergeOptions): T;
45
49
  declare function removeTrailingSlash(string: string): string;
46
50
 
47
51
  declare const debug: {
package/dist/index.mjs CHANGED
@@ -325,8 +325,9 @@ function when(condition, data, _default) {
325
325
  }
326
326
  return data;
327
327
  }
328
- function merge(x, y) {
329
- return baseMerge(x, y, { arrayMerge: (_, s) => s });
328
+ function merge(x, y, options = {}) {
329
+ const arrayMerge = typeof options?.arrayMerge === "function" ? options.arrayMerge : options?.overwriteArray !== false ? (_, s) => s : void 0;
330
+ return baseMerge(x, y, { arrayMerge });
330
331
  }
331
332
  function removeTrailingSlash(string) {
332
333
  return string.replace(/\/+$/, "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridly/utils",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "Utils used in Hybridly packages",
5
5
  "keywords": [
6
6
  "hybridly"