Skip to content

Commit

Permalink
Merge branch 'production' into rewrite-types
Browse files Browse the repository at this point in the history
  • Loading branch information
mesqueeb authored Nov 14, 2022
2 parents cb75224 + 69573f7 commit 72c1228
Show file tree
Hide file tree
Showing 4 changed files with 1,225 additions and 1,059 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ However, **there is a really easy solution**. We can just copy the merge result
See below how we integrate 'copy-anything':

```js
import copy from 'copy-anything'
import { copy } from 'copy-anything'

const original = { airport: { status: 'dep. 🛫' } }
const extraInfo = { airport: { location: 'Brussels' } }
Expand Down
10 changes: 7 additions & 3 deletions dist/types/merge.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { O } from 'ts-toolbelt';
declare type ExpandDeep<T> = T extends Record<string | number | symbol, unknown> ? {
[K in keyof T]: ExpandDeep<T[K]>;
} : T extends Array<infer E> ? Array<ExpandDeep<E>> : T;
/**
* Merge anything recursively.
* Objects get merged, special objects (classes etc.) are re-assigned "as is".
* Basic types overwrite objects or other basic types.
* @param object
* @param otherObjects
*/
export declare function merge<T extends Record<string, any>, Tn extends Record<string, any>[]>(object: T, ...otherObjects: Tn): O.Assign<T, Tn, 'deep'>;
export declare function mergeAndCompare<T extends Record<string, any>, Tn extends Record<string, any>[]>(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): O.Assign<T, Tn, 'deep'>;
export declare function mergeAndConcat<T extends Record<string, any>, Tn extends Record<string, any>[]>(object: T, ...otherObjects: Tn): O.Assign<T, Tn, 'deep'>;
export declare function merge<T extends Record<string, any>, Tn extends Record<string, any>[]>(object: T, ...otherObjects: Tn): ExpandDeep<O.Assign<T, Tn, 'deep'>>;
export declare function mergeAndCompare<T extends Record<string, any>, Tn extends Record<string, any>[]>(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): ExpandDeep<O.Assign<T, Tn, 'deep'>>;
export declare function mergeAndConcat<T extends Record<string, any>, Tn extends Record<string, any>[]>(object: T, ...otherObjects: Tn): ExpandDeep<O.Assign<T, Tn, 'deep'>>;
export {};
Loading

0 comments on commit 72c1228

Please sign in to comment.