Skip to content

Commit

Permalink
chore: build
Browse files Browse the repository at this point in the history
  • Loading branch information
mesqueeb committed Nov 15, 2022
1 parent deab7a1 commit b43508d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 11 deletions.
28 changes: 25 additions & 3 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,36 @@ function mergeAndConcat(object, ...otherObjects) {
return mergeRecursively(result, newComer, concatArrays);
}, object);
}
// import { Timestamp } from 'firebase/firestore'
// import { Timestamp } from '../test/Timestamp'
// type T1 = { date: Timestamp }
// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }]
// type Test = Merge<T1, T2>
// type TestT = Merge<T1, T2>
// type A1 = { arr: string[] }
// type A2 = { arr: number[] }
// type A3 = { arr: boolean[] }
// type Test = Merge<A1, [A2, A3]>
// type TestA = Merge<A1, [A2, A3]>
// interface I1 {
// date: Timestamp
// }
// interface I2 {
// date: Timestamp
// }
// const _a: I2 = { date: '' } as unknown as I2
// type TestI = Merge<I1, [I2]>
// // ReturnType<(typeof merge)<I1, I2>>
// const a = merge(_a, [_a])
// interface Arguments extends Record<string | number | symbol, unknown> {
// key: string;
// }
// const aa1: Arguments = { key: "value1" }
// const aa2: Arguments = { key: "value2" }
// const aa = merge(a1, a2);
// interface Barguments {
// key: string
// }
// const ba1: Barguments = { key: 'value1' }
// const ba2: Barguments = { key: 'value2' }
// const ba = merge(ba1, ba2)

exports.concatArrays = concatArrays;
exports.merge = merge;
Expand Down
28 changes: 25 additions & 3 deletions dist/index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,35 @@ function mergeAndConcat(object, ...otherObjects) {
return mergeRecursively(result, newComer, concatArrays);
}, object);
}
// import { Timestamp } from 'firebase/firestore'
// import { Timestamp } from '../test/Timestamp'
// type T1 = { date: Timestamp }
// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }]
// type Test = Merge<T1, T2>
// type TestT = Merge<T1, T2>
// type A1 = { arr: string[] }
// type A2 = { arr: number[] }
// type A3 = { arr: boolean[] }
// type Test = Merge<A1, [A2, A3]>
// type TestA = Merge<A1, [A2, A3]>
// interface I1 {
// date: Timestamp
// }
// interface I2 {
// date: Timestamp
// }
// const _a: I2 = { date: '' } as unknown as I2
// type TestI = Merge<I1, [I2]>
// // ReturnType<(typeof merge)<I1, I2>>
// const a = merge(_a, [_a])
// interface Arguments extends Record<string | number | symbol, unknown> {
// key: string;
// }
// const aa1: Arguments = { key: "value1" }
// const aa2: Arguments = { key: "value2" }
// const aa = merge(a1, a2);
// interface Barguments {
// key: string
// }
// const ba1: Barguments = { key: 'value1' }
// const ba2: Barguments = { key: 'value2' }
// const ba = merge(ba1, ba2)

export { concatArrays, merge, mergeAndCompare, mergeAndConcat };
10 changes: 5 additions & 5 deletions dist/types/merge.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { Assign } from './typeUtils/Assign';
import type { List } from './typeUtils/List';
import type { Pop } from './typeUtils/List';
import type { PrettyPrint } from './typeUtils/PrettyPrint';
/**
* The return type of `merge()`. It reflects the type that is returned by JavaScript.
*
* This TS Utility can be used as standalone as well
*/
export declare type Merge<T extends Record<string | number | symbol, unknown>, Ts extends List<Record<string | number | symbol, unknown>>> = PrettyPrint<Assign<T, Ts>>;
export declare type Merge<T, Ts extends unknown[]> = T extends Record<string | number | symbol, unknown> ? Ts extends Record<string | number | symbol, unknown>[] ? PrettyPrint<Assign<T, Ts>> : Pop<Ts> : Pop<Ts>;
/**
* Merge anything recursively.
* Objects get merged, special objects (classes etc.) are re-assigned "as is".
* Basic types overwrite objects or other basic types.
*/
export declare function merge<T extends Record<string | number | symbol, unknown>, Tn extends Record<string | number | symbol, unknown>[]>(object: T, ...otherObjects: Tn): Merge<T, Tn>;
export declare function mergeAndCompare<T extends Record<string | number | symbol, unknown>, Tn extends Record<string | number | symbol, unknown>[]>(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge<T, Tn>;
export declare function mergeAndConcat<T extends Record<string | number | symbol, unknown>, Tn extends Record<string | number | symbol, unknown>[]>(object: T, ...otherObjects: Tn): Merge<T, Tn>;
export declare function merge<T, Tn extends unknown[]>(object: T, ...otherObjects: Tn): Merge<T, Tn>;
export declare function mergeAndCompare<T, Tn extends unknown[]>(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge<T, Tn>;
export declare function mergeAndConcat<T, Tn extends unknown[]>(object: T, ...otherObjects: Tn): Merge<T, Tn>;
9 changes: 9 additions & 0 deletions dist/types/typeUtils/List.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ export declare type List<T = any> = readonly T[];
* ```
*/
export declare type Length<L extends List> = L['length'];
/**
* Return the last item out of a [[List]]
* @param L
* @returns [[List]]
* @example
* ```ts
* ```
*/
export declare type Pop<L extends List> = L extends readonly [] ? L : L extends readonly [...any, infer Last] ? Last : L;

0 comments on commit b43508d

Please sign in to comment.