1 | type Input = Record<string | number | symbol, any>;
|
2 | type IgnoredInput = boolean | number | null | any[] | Record<never, any> | undefined;
|
3 | type Merger = <T extends Input, K extends keyof T>(object: T, key: keyof T, value: T[K], namespace: string) => any;
|
4 | type nullish = null | undefined | void;
|
5 | type MergeObjects<Destination extends Input, Defaults extends Input> = Destination extends Defaults ? Destination : Omit<Destination, keyof Destination & keyof Defaults> & Omit<Defaults, keyof Destination & keyof Defaults> & {
|
6 | -readonly [Key in keyof Destination & keyof Defaults]: Destination[Key] extends nullish ? Defaults[Key] extends nullish ? nullish : Defaults[Key] : Defaults[Key] extends nullish ? Destination[Key] : Merge<Destination[Key], Defaults[Key]>;
|
7 | };
|
8 | type Defu<S extends Input, D extends Array<Input | IgnoredInput>> = D extends [infer F, ...infer Rest] ? F extends Input ? Rest extends Array<Input | IgnoredInput> ? Defu<MergeObjects<S, F>, Rest> : MergeObjects<S, F> : F extends IgnoredInput ? Rest extends Array<Input | IgnoredInput> ? Defu<S, Rest> : S : S : S;
|
9 | type DefuFn = <Source extends Input, Defaults extends Array<Input | IgnoredInput>>(source: Source, ...defaults: Defaults) => Defu<Source, Defaults>;
|
10 | interface DefuInstance {
|
11 | <Source extends Input, Defaults extends Array<Input | IgnoredInput>>(source: Source | IgnoredInput, ...defaults: Defaults): Defu<Source, Defaults>;
|
12 | fn: DefuFn;
|
13 | arrayFn: DefuFn;
|
14 | extend(merger?: Merger): DefuFn;
|
15 | }
|
16 | type MergeArrays<Destination, Source> = Destination extends Array<infer DestinationType> ? Source extends Array<infer SourceType> ? Array<DestinationType | SourceType> : Source | Array<DestinationType> : Source | Destination;
|
17 | type Merge<Destination extends Input, Defaults extends Input> = Destination extends nullish ? Defaults extends nullish ? nullish : Defaults : Defaults extends nullish ? Destination : Destination extends Array<any> ? Defaults extends Array<any> ? MergeArrays<Destination, Defaults> : Destination | Defaults : Destination extends Function ? Destination | Defaults : Destination extends RegExp ? Destination | Defaults : Destination extends Promise<any> ? Destination | Defaults : Defaults extends Function ? Destination | Defaults : Defaults extends RegExp ? Destination | Defaults : Defaults extends Promise<any> ? Destination | Defaults : Destination extends Input ? Defaults extends Input ? MergeObjects<Destination, Defaults> : Destination | Defaults : Destination | Defaults;
|
18 |
|
19 | declare function createDefu(merger?: Merger): DefuFn;
|
20 | declare const defu: DefuInstance;
|
21 |
|
22 | declare const defuFn: DefuFn;
|
23 | declare const defuArrayFn: DefuFn;
|
24 |
|
25 | export { type Defu, createDefu, defu as default, defu, defuArrayFn, defuFn };
|