@waiting/shared-types
Advanced tools
Comparing version 4.8.1 to 5.0.0
@@ -6,2 +6,15 @@ # Change Log | ||
# [5.0.0](https://github.com/waitingsong/shared-types/compare/v4.8.1...v5.0.0) (2020-07-17) | ||
### Features | ||
* **types:** add type isInLiteralTuple ([6d23af5](https://github.com/waitingsong/shared-types/commit/6d23af5ea482c8f469a90a659d12ed2eccc4ad4a)) | ||
* **types:** breaking change params of PickDuplicateKeys<> to array ([8e084ea](https://github.com/waitingsong/shared-types/commit/8e084ea3ef519cfd4806d3ac8752405a8a23f7cb)) | ||
* **types:** rename type JoinTableUnique to JoinTableDistinct ([678b9c5](https://github.com/waitingsong/shared-types/commit/678b9c5bbe4d718c259cbf46db2ee7372424c797)) | ||
## [4.8.1](https://github.com/waitingsong/shared-types/compare/v4.8.0...v4.8.1) (2020-07-16) | ||
@@ -8,0 +21,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 4.8.0 | ||
* @version 4.8.1 | ||
* @author waiting | ||
@@ -8,0 +8,0 @@ * @license MIT |
import { OverwriteNeverToUnknown, FormatIntersect } from '../common'; | ||
import { TupleTail, TupleHead } from '../tuple'; | ||
import { UnionToIntersection } from '../union2tuple'; | ||
@@ -100,5 +101,19 @@ /** | ||
*/ | ||
export declare type JoinTableUnique<L extends TableModel, R extends TableModel, KeyExcludeOptional extends keyof L | keyof R | void = void> = JoinTable<L, R, KeyExcludeOptional | (keyof L & keyof R)>; | ||
export declare type PickDuplicateKeys<L extends TableModel, R extends TableModel> = (keyof L & keyof R); | ||
export declare type JoinTableDistinct<L extends TableModel, R extends TableModel, KeyExcludeOptional extends keyof L | keyof R | void = void> = JoinTable<L, R, KeyExcludeOptional | (keyof L & keyof R)>; | ||
/** | ||
* @example ```ts | ||
* // Expect: "2" | "3" | ||
* PickDuplicateKeys<['1' | '2' | '3', '2' | '3' | '4']> | ||
* | ||
* // Expect: () => void | ||
* SetIntersection<string | number | (() => void), Function> | ||
* ``` | ||
*/ | ||
export declare type PickDuplicateKeys<T extends unknown[]> = _PickDupKeys<T>; | ||
declare type _PickDupKeys<T1 extends unknown[], T2 = never, Result = never> = { | ||
2: Result; | ||
1: T2; | ||
0: _PickDupKeys<TupleTail<T1>, TupleHead<T1> | T2, Extract<TupleHead<T1>, T2> | Result>; | ||
}[T1 extends [] ? 2 : 0]; | ||
/** | ||
* Generate TableAlias model from TableModel and DictAliasCols, | ||
@@ -105,0 +120,0 @@ * keys from input of AcUser. |
import { FormatIntersect } from '../common'; | ||
import { UnionToIntersection } from '../union2tuple'; | ||
import { AliasColumn, FlateJointTable, JoinTableUnique, PickDuplicateKeys, TableAliasCols, TableModel, TableModelFromDictAlias } from './common'; | ||
import { AliasColumn, FlateJointTable, JoinTableDistinct, PickDuplicateKeys, TableAliasCols, TableModel, TableModelFromDictAlias } from './common'; | ||
/** | ||
@@ -25,6 +25,6 @@ * Join two tables model, duplicate keys replaced by elements of AliasCols | ||
*/ | ||
export declare type JoinTableWithAlias<L extends TableModel, AL extends TableAliasCols<L>, R extends TableModel, AR extends TableAliasCols<R>> = FormatIntersect<JoinTableUnique<L, R> & A4<L, AL, R, AR>>; | ||
export declare type JoinTableWithAlias<L extends TableModel, AL extends TableAliasCols<L>, R extends TableModel, AR extends TableAliasCols<R>> = FormatIntersect<JoinTableDistinct<L, R> & A4<L, AL, R, AR>>; | ||
declare type A4<L extends TableModel, AL extends TableAliasCols<L>, R extends TableModel, AR extends TableAliasCols<R>> = GenTableModelByAliasCols<PickDictColsByDupKeysFromTablesModel<L, AL, R, AR>, A3<L, AL, R, AR>>; | ||
declare type A3<L extends TableModel, AL extends TableAliasCols<L>, R extends TableModel, AR extends TableAliasCols<R>> = TableModelFromDictAlias<L, AL> & TableModelFromDictAlias<R, AR>; | ||
export declare type PickDictColsByDupKeysFromTablesModel<L extends TableModel, AL extends TableAliasCols, R extends TableModel, AR extends TableAliasCols> = UnionToIntersection<FlateJointTable<A1<AL, AR, PickDuplicateKeys<L, R>>>>; | ||
export declare type PickDictColsByDupKeysFromTablesModel<L extends TableModel, AL extends TableAliasCols, R extends TableModel, AR extends TableAliasCols> = UnionToIntersection<FlateJointTable<A1<AL, AR, PickDuplicateKeys<[keyof L, keyof R]>>>>; | ||
declare type A1<AL extends TableAliasCols, AR extends TableAliasCols, Keys> = PickAliasColsByKey<AL, AR, Keys>; | ||
@@ -31,0 +31,0 @@ /** |
@@ -24,1 +24,10 @@ /** Get the first element */ | ||
}; | ||
/** | ||
* Whether literal type is in Tuple contains literal, | ||
* | ||
* @example ```ts | ||
* type Foo = isInType<['ab', 'cd'], 'ab'> | ||
* ``` | ||
* @returns boolean | ||
*/ | ||
export declare type isInLiteralTuple<T extends (string | number | symbol)[], K extends string | number | symbol> = Extract<T[number], K> extends never ? false : true; |
{ | ||
"name": "@waiting/shared-types", | ||
"author": "waiting", | ||
"version": "4.8.1", | ||
"version": "5.0.0", | ||
"description": "shared typescript types", | ||
@@ -74,3 +74,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "33da5b7e0db14133ea8204fd99a377f54d22d10a" | ||
"gitHead": "9b8e2c2d56dad827221119860e703dcd6d75f482" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32091
27
619