From b43508dab754cbc3dfe980428f9bdb5369bbfd7b Mon Sep 17 00:00:00 2001 From: mesqueeb Date: Tue, 15 Nov 2022 11:26:28 +0900 Subject: [PATCH] chore: build --- dist/index.cjs | 28 +++++++++++++++++++++++++--- dist/index.es.js | 28 +++++++++++++++++++++++++--- dist/types/merge.d.ts | 10 +++++----- dist/types/typeUtils/List.d.ts | 9 +++++++++ 4 files changed, 64 insertions(+), 11 deletions(-) diff --git a/dist/index.cjs b/dist/index.cjs index 2530bef..68471fe 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -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 +// type TestT = Merge // type A1 = { arr: string[] } // type A2 = { arr: number[] } // type A3 = { arr: boolean[] } -// type Test = Merge +// type TestA = Merge +// interface I1 { +// date: Timestamp +// } +// interface I2 { +// date: Timestamp +// } +// const _a: I2 = { date: '' } as unknown as I2 +// type TestI = Merge +// // ReturnType<(typeof merge)> +// const a = merge(_a, [_a]) +// interface Arguments extends Record { +// 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; diff --git a/dist/index.es.js b/dist/index.es.js index 41615e5..c2f2351 100644 --- a/dist/index.es.js +++ b/dist/index.es.js @@ -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 +// type TestT = Merge // type A1 = { arr: string[] } // type A2 = { arr: number[] } // type A3 = { arr: boolean[] } -// type Test = Merge +// type TestA = Merge +// interface I1 { +// date: Timestamp +// } +// interface I2 { +// date: Timestamp +// } +// const _a: I2 = { date: '' } as unknown as I2 +// type TestI = Merge +// // ReturnType<(typeof merge)> +// const a = merge(_a, [_a]) +// interface Arguments extends Record { +// 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 }; diff --git a/dist/types/merge.d.ts b/dist/types/merge.d.ts index 2b0d0a6..0b96bf9 100644 --- a/dist/types/merge.d.ts +++ b/dist/types/merge.d.ts @@ -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, Ts extends List>> = PrettyPrint>; +export declare type Merge = T extends Record ? Ts extends Record[] ? PrettyPrint> : Pop : Pop; /** * 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, Tn extends Record[]>(object: T, ...otherObjects: Tn): Merge; -export declare function mergeAndCompare, Tn extends Record[]>(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge; -export declare function mergeAndConcat, Tn extends Record[]>(object: T, ...otherObjects: Tn): Merge; +export declare function merge(object: T, ...otherObjects: Tn): Merge; +export declare function mergeAndCompare(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge; +export declare function mergeAndConcat(object: T, ...otherObjects: Tn): Merge; diff --git a/dist/types/typeUtils/List.d.ts b/dist/types/typeUtils/List.d.ts index cf9f4db..76f2c9c 100644 --- a/dist/types/typeUtils/List.d.ts +++ b/dist/types/typeUtils/List.d.ts @@ -18,3 +18,12 @@ export declare type List = readonly T[]; * ``` */ export declare type Length = L['length']; +/** + * Return the last item out of a [[List]] + * @param L + * @returns [[List]] + * @example + * ```ts + * ``` + */ +export declare type Pop = L extends readonly [] ? L : L extends readonly [...any, infer Last] ? Last : L;