declare let _$_: { new (): {}; } & typeof globalThis; declare class $ extends _$_ { } declare namespace $ { export type $ = typeof $$; export class $$ extends $ { static $: $; } namespace $$ { type $$ = $; } export {}; } declare namespace $ { /** * Leave types with specified keys in union type * * // { prop: number; foo: number } * type only_with_prop = $mol_type_filter_keys< { prop: number; foo: number } | { foo: string }, 'prop' > */ type $mol_type_filter_keys = Extract; } declare namespace $ { /** * Access property type by key for union type * * // number * type a_type = $mol_type_access< { a: number } | boolean, 'a' > */ type $mol_type_access = $mol_type_filter_keys extends never ? never : Keys extends keyof $mol_type_filter_keys ? $mol_type_filter_keys[Keys] : never; } declare namespace $ { /** English alphabet in lowercase **/ type $mol_type_alphabet_en_lower = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'j' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'; /** English alphabet in uppercase **/ type $mol_type_alphabet_en_upper = Uppercase<$mol_type_alphabet_en_lower>; /** English alphabet **/ type $mol_type_alphabet_en = $mol_type_alphabet_en_lower | $mol_type_alphabet_en_upper; } declare namespace $ { /** Russian alphabet in lowercase **/ type $mol_type_alphabet_ru_lower = 'а' | 'б' | 'в' | 'г' | 'д' | 'е' | 'ё' | 'ж' | 'з' | 'и' | 'й' | 'к' | 'л' | 'м' | 'н' | 'о' | 'п' | 'р' | 'с' | 'т' | 'у' | 'ф' | 'х' | 'ц' | 'ч' | 'ш' | 'щ' | 'ъ' | 'ы' | 'ь' | 'э' | 'ю' | 'я'; /** Russian alphabet in uppercase **/ type $mol_type_alphabet_ru_upper = Uppercase<$mol_type_alphabet_ru_lower>; /** Russian alphabet **/ type $mol_type_alphabet_ru = $mol_type_alphabet_ru_lower | $mol_type_alphabet_ru_upper; } declare namespace $ { /** * Return `unknown` when `A` and `B` are the same type. `never` otherwise. * * $mol_type_equals< unknown , any > & number // true * $mol_type_equals< never , never > & number // false */ type $mol_type_equals = (() => X extends A ? 1 : 2) extends (() => X extends B ? 1 : 2) ? true : false; } declare namespace $ { /** Returns error type, that don't match to normal value. */ type $mol_type_error = Message & { $mol_type_error: Info; }; } declare namespace $ { /** * Asserts for equality of `Actual` and `Expected` types. */ type $mol_type_assert extends true ? unknown : $mol_type_equals extends true ? never : $mol_type_error<'Assert failed', { actual: Actual; expected: Expected; }>, Expected extends $mol_type_equals extends true ? unknown : $mol_type_equals extends true ? never : $mol_type_error<'Assert failed', { actual: Actual; expected: Expected; }>> = Actual; /** * Asserts for `Actual` type is `never`. * @deprecated Use `$mol_type_assert< A, B >` * * $mol_type_assert_never< $mol_type_equals< 1 , 2 > > */ type $mol_type_assert_never = Actual; } declare namespace $ { /** * Capitalize type keys. * * // { Foo: 1; Bar: 2 } * $mol_type_case_capital_keys< { foo: 1; bar: 2 } > */ type $mol_type_case_capital_keys = { [Key in keyof Type as Capitalize>]: Type[Key]; }; /** * Capitalize type values. * * // { foo: 'Bar' } * $mol_type_case_capital_values< { foo: 'bar' } > */ type $mol_type_case_capital_values = { [Key in keyof Type]: Capitalize>; }; } declare namespace $ { /** * Lowercase type keys. * * // { foo: 'BAR' } * $mol_type_case_lower_keys< { FOO: 'BAR' } > */ type $mol_type_case_lower_keys = { [Key in keyof Type as Lowercase>]: Type[Key]; }; /** * Lowercase type values. * * // { FOO: 'bar' } * $mol_type_case_lower_values< { FOO: 'BAR' } > */ type $mol_type_case_lower_values = { [Key in keyof Type]: Lowercase>; }; } declare namespace $ { /** * Uppercase type keys. * * // { FOO: 'bar' } * $mol_type_case_upper_keys< { foo: 'bar' } > */ type $mol_type_case_upper_keys = { [Key in keyof Type as Uppercase>]: Type[Key]; }; /** * Uppercase type values. * * // { foo: 'BAR' } * $mol_type_case_upper_values< { foo: 'bar' } > */ type $mol_type_case_upper_values = { [Key in keyof Type]: Uppercase>; }; } declare namespace $ { /** * Fails if `Actual` type is not subtype of `Expected`. */ type $mol_type_enforce = Actual; } declare namespace $ { /** * Reqursive converts intersection of records to record of intersections * * // { a : { x : 1 , y : 2 } } * $mol_type_merge< { a : { x : 1 } }&{ a : { y : 2 } } > */ type $mol_type_merge = Intersection extends (...a: any[]) => any ? Intersection : Intersection extends new (...a: any[]) => any ? Intersection : Intersection extends object ? $mol_type_merge_object extends Intersection ? true extends $mol_type_equals<{ [Key in keyof Intersection]: Intersection[Key]; }, Intersection> ? Intersection : { [Key in keyof Intersection]: $mol_type_merge; } : Intersection : Intersection; /** * Flat converts intersection of records to record of intersections * * // { a: 1, b: 2 } * $mol_type_merge< { a: 1 } & { b: 2 } > */ type $mol_type_merge_object = { [Key in keyof Intersection]: Intersection[Key]; }; } declare namespace $ { /** Replaces properties of `Base` record by properties from `Over`. */ type $mol_type_override = Omit & Over; } declare namespace $ { /** * Fields that can be set to undefined makes optional * * type User = $mol_type_partial_undefined<{ name : string , age : number | undefined }> // { name : string , age? : number | undefined } */ type $mol_type_partial_undefined = $mol_type_merge<$mol_type_override, Pick>>; } declare namespace $ { /** * Flat structure key names, leading to non-object types, in tuples. Endpoint specifies structures, whose keys should not be flat. * * // [ 'a', 'd' ] | [ 'a', 'b', 'c' ] * type keys = $mol_type_flat_keys< { a: { b: { c: number }, d: string } } > */ type $mol_type_flat_keys = Type extends object ? Type extends Readonly> | Function | Promise ? [] : Type extends Endpoint ? [] : { [Key in keyof Type]-?: Key extends string ? [ Key, ...$mol_type_flat_keys[Key], Endpoint> ] : never; }[keyof Type] : []; /** * All flat structure key names in tuples. Endpoint specifies structures, whose keys should not be flat. * * // [ 'a' ] | [ 'a', 'b' ] | [ 'a', 'd' ] | [ 'a', 'b', 'c' ] * type all_keys = $mol_type_flat_keys_all< { a: { b: { c: number }, d: string } } > */ type $mol_type_flat_keys_all = Type extends object ? Type extends Readonly> | Promise ? [] : Type extends Endpoint ? [] : { [Key in keyof Type]-?: Key extends string ? [Key] | [ Key, ...$mol_type_flat_keys_all[Key], Endpoint> ] : never; }[keyof Type] : []; } declare namespace $ { /** * Returns `Tuple` without first element. * * $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ] */ type $mol_type_tail = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never; } declare namespace $ { /** * Join strings with `Separator`. * * // 'foo%bar%wee' * $mol_type_string_join< [ 'foo', 'bar', 'wee' ], '%' > */ type $mol_type_string_join, Separator extends string> = Parts['length'] extends 0 ? never : Parts['length'] extends 1 ? Parts[0] : Parts['length'] extends 2 ? `${Extract}${'' extends Parts[1] ? '' : Separator}${Extract}` : $mol_type_string_join<[ $mol_type_string_join<[Parts[0], Parts[1]], Separator>, ...$mol_type_tail<$mol_type_tail> ], Separator>; } declare namespace $ { /** * Split string into parts with separator. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_string_split< 'foo-bar-wee', '-' > */ type $mol_type_string_split = '' extends String ? [] : String extends `${infer Left}${Separator}${infer Right}` ? [ ...('' extends Left ? [] : [Left]), ...$mol_type_string_split ] : [String]; } declare namespace $ { /** * Returns first element of `Tuple`. * * $mol_type_tail<[ 1 , 2 , 3 ]> // 1 */ type $mol_type_head = Tuple['length'] extends 0 ? never : Tuple[0]; } declare namespace $ { /** * Join strings in snake_case. * * // 'foo_bar_wee' * $mol_type_case_snake< [ 'foo', 'bar', 'wee' ] > */ export type $mol_type_case_snake> = $mol_type_string_join; /** * Parse snake_case string into parts. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_case_snake_parse< 'foo_bar_wee' > */ export type $mol_type_case_snake_parse = $mol_type_string_split; /** * Join strings in kebab-case. * * // 'foo-bar-wee' * $mol_type_case_kebab< [ 'foo', 'bar', 'wee' ] > */ export type $mol_type_case_kebab> = $mol_type_string_join; /** * Parse kebab-case string into parts. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_case_kebab_parse< 'foo-bar-wee' > */ export type $mol_type_case_kebab_parse = $mol_type_string_split; /** * Join strings in dot.case. * * // 'foo.bar.wee' * $mol_type_case_dot< [ 'foo', 'bar', 'wee' ] > */ export type $mol_type_case_dot> = $mol_type_string_join; /** * Parse dot.case string into parts. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_case_dot_parse< 'foo.bar.wee' > */ export type $mol_type_case_dot_parse = $mol_type_string_split; /** * Join strings in camelCase. * * // 'fooBarWee' * $mol_type_case_camel< [ 'foo', 'bar', 'wee' ] > */ export type $mol_type_case_camel> = $mol_type_string_join<[ Lowercase<$mol_type_head>, ...Extract<$mol_type_case_capital_values<$mol_type_case_lower_values<$mol_type_tail>>, Array> ], ''>; type camel_temp_separator = '.'; type camel_replace_with_separator = String extends `${infer Left}${infer Right}` ? `${Left extends Capitalize ? camel_temp_separator : ''}${Lowercase}${camel_replace_with_separator}` : String; /** * Parse camelCase string into parts. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_case_camel_parse< 'fooBarWee' > */ export type $mol_type_case_camel_parse = $mol_type_string_split, camel_temp_separator>; /** * Join strings in PascalCase. * * // 'FooBarWee' * $mol_type_case_pascal< [ 'foo', 'bar', 'wee' ] > */ export type $mol_type_case_pascal> = $mol_type_string_join<$mol_type_case_capital_values<$mol_type_case_lower_values>, ''>; /** * Parse PascalCase string into parts. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_case_pascal_parse< 'FooBarWee' > */ export type $mol_type_case_pascal_parse = $mol_type_case_camel_parse; /** * Join strings in Cobra_case. * * // 'Foo_bar_wee' * $mol_type_case_cobra< [ 'foo', 'bar', 'wee' ] > */ export type $mol_type_case_cobra> = $mol_type_string_join<[ Capitalize>>, ...Extract<$mol_type_case_lower_values<$mol_type_tail>, Array> ], '_'>; /** * Parse Cobra_case string into parts. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_case_cobra_parse< 'Foo_bar_wee' > */ export type $mol_type_case_cobra_parse = $mol_type_case_lower_values<$mol_type_string_split>; /** * Join strings in SCREAM_CASE. * * // 'FOO_BAR_WEE' * $mol_type_case_scream< [ 'foo', 'bar', 'wee' ] > */ export type $mol_type_case_scream> = $mol_type_string_join<$mol_type_case_upper_values, '_'>; /** * Parse SCREAM_CASE string into parts. * * // [ 'foo', 'bar', 'wee' ] * $mol_type_case_scream_parse< 'FOO_BAR_WEE' > */ export type $mol_type_case_scream_parse = $mol_type_case_cobra_parse; export {}; } declare namespace $ { /** * Converts union of types to intersection of same types * * $mol_type_intersect< number | string > // number & string */ type $mol_type_intersect = (Union extends any ? (_: Union) => void : never) extends ((_: infer Intersection) => void) ? Intersection : never; } declare namespace $ { /** * Volume structure from flat with dot.case key names. * * // { a: { b: number; c: { d: string } } } * type volume = $mol_type_volume< { 'a.b': number; 'a.c.d': string } > */ type $mol_type_volume = $mol_type_merge<$mol_type_intersect<{ [Key in keyof Type]: Key extends `${infer Left}.${infer Right}` ? { [_ in Left]: $mol_type_volume<{ [_ in Right]: Type[Key]; }>; } : $mol_type_partial_undefined<{ [_ in Key]: Type[Key]; }>; }[keyof Type]>>; } declare namespace $ { /** * Get value type by flat key name. * * // number * type abc_type = $mol_type_volume_value< { a: { b: { c: number }; d: string }, 'a.b.c' } > */ type $mol_type_volume_value = $mol_type_access extends never ? Key extends `${infer Left}.${infer Right}` ? $mol_type_access extends never ? never : $mol_type_volume_value<$mol_type_access, Right> : never : $mol_type_access; } declare namespace $ { /** * Make flat structure from volume. Camel case is used for key names. * * // { fooBarWee: number; fooToo: string } * type flat = $mol_type_flat_camel< { foo: { bar: { wee: number }; too: string } } > */ type $mol_type_flat_camel = $mol_type_partial_undefined<{ [FlatKeys in $mol_type_flat_keys as $mol_type_case_camel]: $mol_type_volume_value>; }>; } declare namespace $ { /** * Returns last element of `Tuple`. * * $mol_type_tail<[ 1 , 2 , 3 ]> // 3 */ type $mol_type_foot = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail['length']]; } declare namespace $ { /** * Overwrite `Tuple` first element. * * // [ 'd', 'b', 'c' ] * $mol_type_head_write< [ 'a', 'b', 'c' ], 'd' > */ type $mol_type_head_write, Over> = [ Over, ...$mol_type_tail ]; } declare namespace $ { /** * Recursive `Readonly`. * * let props : $mol_type_immutable_deep< { foo: number[] } > = { readonly foo: readonly number[] } */ type $mol_type_immutable_deep = { readonly [field in keyof Val]: $mol_type_immutable_deep; }; } declare namespace $ { type Parse = Str extends `${infer Letter extends keyof Digits}${infer Tail}` ? Parse, Digit ]>> : Res; type Check = Parse<`${Extract}`> extends never ? $mol_type_error<'Is not Int'> : number | string; type Digits = { '0': 0; '1': 1; '2': 2; '3': 3; '4': 4; '5': 5; '6': 6; '7': 7; '8': 8; '9': 9; }; type Digit = Up]>; type Int = unknown[]; type Pair = [Int, Int]; type Zero = []; type One = [0]; type Ten = Up<10>; type Down = Value["length"]; type Up = Value extends Down ? Res : Up>; type Next = Plus<[Value, One]>; type Prev = Minus<[Value, One]>; /** Number literal which is sum of two another */ export type $mol_type_int_plus, Right extends Check> = Down, Parse<`${Right}`> ]>>; type Plus = [...Arg[0], ...Arg[1]]; /** Number literal which is subtract of two another */ export type $mol_type_int_minus, Right extends Check> = Down, Parse<`${Right}`> ]>>; type Minus = Arg[0] extends [...Arg[1], ...infer Res] ? Extract : never; /** Number literal which is multiply of two another */ export type $mol_type_int_mult, Right extends Check> = Down, Parse<`${Right}`> ]>>; type Mult = Arg[1] extends Zero ? Res : Mult<[ Arg[0], Prev ], Plus<[Res, Arg[0]]>>; /** Number literal which is power one to another */ export type $mol_type_int_pow, Right extends Check> = Down, Parse<`${Right}`> ]>>; type Pow = Arg[1] extends Zero ? Res : Pow<[ Arg[0], Prev ], Mult<[Res, Arg[0]]>>; /** * Range of number literals from Lo up to Hi * **Slow on large ranges** */ export type $mol_type_int_range, Hi extends Check> = Down, Parse<`${Hi}`> ]>>; type Range = keyof Args[0] extends keyof Args[1] ? Plus<[ Args[0], Parse, symbol | number>> ]> : never; /** Unknown when number literals is ordered */ export type $mol_type_int_ordered, Right extends Check> = keyof Parse<`${Left}`> extends keyof Parse<`${Right}`> ? unknown : never; type Calc = Expr extends `${infer Left}(${infer Inner})${infer Right}` ? Calc<`${Left}${Down>}${Right}`> : Expr extends `${infer Left}..${infer Right}` ? Range<[Calc, Calc]> : Expr extends `${infer Left}+${infer Right}` ? Plus<[Calc, Calc]> : Expr extends `${infer Left}-${infer Right}` ? Minus<[Calc, Calc]> : Expr extends `${infer Left}*${infer Right}` ? Mult<[Calc, Calc]> : Expr extends `${infer Left}^${infer Right}` ? Pow<[Calc, Calc]> : Expr extends `${infer Left} ` ? Calc : Expr extends ` ${infer Right}` ? Calc : Parse; /** Evaluates simple expression */ export type $mol_type_int_calc = Down>; export {}; } declare namespace $ { /** * All keys from union type * * type keys_all = $mol_type_keys_all< { a: number } | { b: string } > // 'a' | 'b' */ type $mol_type_keys_all = Type extends Type ? keyof Type : never; } declare namespace $ { /** * Extracts keys from `Input` which values extends `Upper` and extendable by `Lower`. * * type MathConstants = $mol_type_keys_extract< Math , number > // "E" | "PI" ... */ type $mol_type_keys_extract = { [Field in keyof Input]: unknown extends Input[Field] ? never : Input[Field] extends never ? never : Input[Field] extends Upper ? [ Lower ] extends [Input[Field]] ? Field : never : never; }[keyof Input]; } declare namespace $ { /** * Exclude keys from `Input` which values extends `Upper`. * * type MathConstants = $mol_type_keys_exclude< Math , Function > // "E" | "PI" ... */ type $mol_type_keys_exclude = Exclude>; } declare namespace $ { /** * Recursive `-Readonly`. * * let props : $mol_type_mutable< { readonly foo: number[] } > = { foo: number[] } */ type $mol_type_mutable_deep = { -readonly [field in keyof Val]: $mol_type_mutable_deep; }; } declare namespace $ { /** * Null union with properties or with type itself. * * // { foo: number | null; bar: string | null } * $mol_type_nullable< { foo: number; bar: string } > */ type $mol_type_nullable = Type extends object ? { [Key in keyof Type]: Type[Key] | null; } : Type | null; } declare namespace $ { /** * Omit keys from `Input` which values extends `Upper`. * * type MathConstants = $mol_type_omit< Math , Function > // { E , PI , ... } */ type $mol_type_omit = Pick>; } declare namespace $ { /** * Returns type of function param by index. * * // 888 * $mol_type_param< ( a : 777 , b : 888 )=> 666 , 1 > */ type $mol_type_param = Func extends (...params: infer Params) => any ? Params[Index] : Func extends new (...params: infer Params2) => any ? Params2[Index] : never; } declare namespace $ { /** * Recursive `Partial`. * * let props : $mol_type_partial_deep< HTMLElement > = { style : { display : 'block' } } */ type $mol_type_partial_deep = Val extends object ? Val extends Function ? Val : { [field in keyof Val]?: $mol_type_partial_deep | undefined; } : Val; } declare namespace $ { /** * Picks keys from `Input` which values extends `Upper`. * * type MathConstants = $mol_type_pick< Math , number > // { E , PI , ... } */ type $mol_type_pick = Pick>; } declare namespace $ { /** * Recursive `Required`. * * type req = $mol_type_required_deep< { a?: { b?: number } } > // { a: { b: number } } */ type $mol_type_required_deep = Type extends object ? Type extends Function ? Exclude : { [Key in keyof Type]-?: $mol_type_required_deep; } : Exclude; } declare namespace $ { /** * Returns type of function result or class instance. * * // 777 * $mol_type_result< ()=> 777 > * * // 777 * $mol_type_result< new()=> 777 > */ type $mol_type_result = Func extends (...params: any) => infer Result ? Result : Func extends new (...params: any) => infer Result ? Result : never; } declare namespace $ { /** * Returns reversed tuple. * * $mol_type_reverse< [ 1, 2, 3 ] > // [ 3, 2, 1 ] */ type $mol_type_reverse = { 0: Reversed; 1: $mol_type_reverse<$mol_type_tail, [ $mol_type_head, ...Reversed ]>; }[Tuple['length'] extends 0 ? 0 : 1]; } declare namespace $ { /** Any unary function **/ type $mol_type_unary_func = ((param: any) => any); type $mol_type_unary_class = new (param: any) => any; type $mol_type_unary = $mol_type_unary_func | $mol_type_unary_class; } declare namespace $ { type $mol_type_writable = { -readonly [P in keyof T]: T[P]; }; } export = $; //# sourceMappingURL=node.d.ts.map