simplytyped
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -1,5 +0,5 @@ | ||
import { DeepReadonly, TaggedObject } from '../types/objects'; | ||
export declare function isKeyOf<T extends object>(obj: T, k: string): k is keyof T; | ||
import { DeepReadonly, TaggedObject, StringKeys } from '../types/objects'; | ||
export declare function isKeyOf<T extends object>(obj: T, k: string): k is StringKeys<T>; | ||
export declare function objectKeys<T extends object>(obj: T): (keyof T)[]; | ||
export declare function Readonly<T extends object>(obj: T): DeepReadonly<T>; | ||
export declare const taggedObject: <T extends Record<string, object>, K extends string>(obj: T, key: K) => TaggedObject<T, K>; |
{ | ||
"name": "simplytyped", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "yet another Typescript type library for advanced types", | ||
@@ -40,3 +40,3 @@ "main": "index", | ||
"husky": "^0.15.0-rc.13", | ||
"ts-node": "^5.0.1", | ||
"ts-node": "^6.0.0", | ||
"tslint": "^5.8.0" | ||
@@ -43,0 +43,0 @@ }, |
import { True, False } from './conditionals'; | ||
import { StringEqual } from './strings'; | ||
import { Vector } from './tuples'; | ||
export declare type IsZero<T extends number> = (Vector<False> & [True, False])[T]; | ||
export declare type IsOne<T extends number> = (Vector<False> & [False, True, False])[T]; | ||
export declare type IsZero<T extends number> = T extends 0 ? True : False; | ||
export declare type IsOne<T extends number> = T extends 1 ? True : False; | ||
export declare type NumberToString<N extends number> = Numbers[N]; | ||
@@ -11,9 +9,9 @@ export declare type Numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63']; | ||
export declare type Add<A extends number, B extends number> = { | ||
1: A; | ||
0: Add<Next<A>, Prev<B>>; | ||
'1': A; | ||
'0': Add<Next<A>, Prev<B>>; | ||
}[IsZero<B>]; | ||
export declare type Sub<A extends number, B extends number> = { | ||
1: A; | ||
0: Sub<Prev<A>, Prev<B>>; | ||
'1': A; | ||
'0': Sub<Prev<A>, Prev<B>>; | ||
}[IsZero<B>]; | ||
export declare type NumberEqual<A extends number, B extends number> = StringEqual<NumberToString<A>, NumberToString<B>>; | ||
export declare type NumberEqual<A extends number, B extends number> = A extends B ? B extends A ? True : False : False; |
@@ -11,2 +11,3 @@ import { Diff, UnionContains } from './strings'; | ||
export declare type GetKey<T, K extends string> = K extends Keys<T> ? T[K] : never; | ||
export declare type StringKeys<T> = Exclude<Keys<T>, number | symbol>; | ||
export declare type Keys<T> = keyof T; | ||
@@ -13,0 +14,0 @@ export declare type PureKeys<T> = Record<Keys<T>, Keys<T>>[Keys<T>]; |
import { False, True, And, Or, Not } from './conditionals'; | ||
import { UnionContains } from './strings'; | ||
import { Keys } from './objects'; | ||
@@ -12,3 +11,3 @@ import { AnyFunc } from './functions'; | ||
export declare type FunctionPrototypeKeys = Keys<Function>; | ||
export declare type IsNever<S extends string> = UnionContains<UnionContains<S, S>, False>; | ||
export declare type IsNever<S extends string> = Not<(Record<S, True> & Record<string, False>)[S]>; | ||
export declare type IsType<T, X> = X extends T ? True : False; | ||
@@ -15,0 +14,0 @@ export declare type IsArray<T> = T extends any[] ? True : False; |
import { True, False, And } from './conditionals'; | ||
import { IsNever } from './predicates'; | ||
export declare type Diff<T extends string, U extends string> = Exclude<T, U>; | ||
export declare type Diff<T, U> = Exclude<T, U>; | ||
export declare type DropString<T extends string, U extends T> = Diff<T, U>; | ||
export declare type StringEqual<T extends string, U extends string> = And<IsNever<Diff<T, U>>, IsNever<Diff<U, T>>>; | ||
export declare type UnionContains<T extends string, U extends string> = (Record<T, True> & Record<string, False>)[U]; | ||
export declare type UnionContains<T, U> = U extends T ? True : False; |
26735
208