declare let _$_: { new (): {}; } & typeof globalThis; declare class $ extends _$_ { } declare namespace $ { export type $ = typeof $$; export class $$ extends $ { static $: $; } namespace $$ { type $$ = $; } export {}; } declare namespace $ { type $mol_data_value = (val: Input) => Output; } declare namespace $ { function $mol_data_setup(value: Value, config: Config): Value & { config: Config; Value: ReturnType; }; } declare namespace $ { function $mol_fail(error: any): never; } declare namespace $ { function $mol_func_name(this: $, func: Function): string; function $mol_func_name_from(target: Target, source: Function): Target; } declare namespace $ { class $mol_error_mix extends AggregateError { readonly cause: Cause; name: string; constructor(message: string, cause?: Cause, ...errors: readonly Error[]); static [Symbol.toPrimitive](): string; static toString(): string; static make(...params: ConstructorParameters): $mol_error_mix<{}>; } } declare namespace $ { class $mol_data_error extends $mol_error_mix { } } declare namespace $ { function $mol_fail_hidden(error: any): never; } declare namespace $ { /** * Checks for array of given runtype and returns expected type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_array_demo */ function $mol_data_array(sub: Sub): ((val: readonly Parameters[0][]) => readonly ReturnType[]) & { config: Sub; Value: readonly ReturnType[]; }; } declare namespace $ { /** * Checks for boolean and returns boolean type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_boolean_demo */ let $mol_data_boolean: (val: boolean) => boolean; } declare namespace $ { let $mol_compare_deep_cache: WeakMap>; /** * Deeply compares two values. Returns true if equal. * Define `Symbol.toPrimitive` to customize. */ function $mol_compare_deep(left: Value, right: Value): boolean; } declare namespace $ { /** * Checks for equality to given value and returns expected type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_const_demo */ function $mol_data_const(ref: Val): ((val: Val) => Val) & { config: Val; Value: Val; }; } declare namespace $ { /** * Checks for string and returns string type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_string_demo */ let $mol_data_string: (val: string) => string; } declare namespace $ { /** * Checks for matching to given regular expression. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_pattern_demo */ function $mol_data_pattern(pattern: RegExp): ((val: string) => string) & { config: RegExp; Value: string; }; } declare namespace $ { /** * Checks for E-Mail and returns string type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_email_demo */ let $mol_data_email: ((val: string) => string) & { config: RegExp; Value: string; }; } declare namespace $ { /** * Checks for value of given enum and returns expected type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_enum_demo */ function $mol_data_enum>(name: string, dict: Dict): ((value: Dict[keyof Dict]) => Dict[keyof Dict]) & { config: { name: string; dict: Dict; }; Value: Dict[keyof Dict]; }; } declare namespace $ { /** * Checks for instance of given class and returns narrowed type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_instance_demo */ function $mol_data_instance any>(Instance: Instance): ((val: InstanceType) => InstanceType) & { config: Instance; Value: InstanceType; }; } declare namespace $ { /** * Checks for number and returns number type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_number_demo */ let $mol_data_number: (val: number) => number; } declare namespace $ { /** * Checks for integer and returns number type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_integer_demo */ function $mol_data_integer(val: number): number; } declare namespace $ { /** * Checks for include inside given range of values and returns expected type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_range_demo */ function $mol_data_range(from: Value, to: Value): ((val: Value) => Value) & { config: Value[]; Value: Value; }; } declare namespace $ { type $mol_data_tagged_type = Value & { [Key in Tag]: Value; }; type $mol_data_tagged_parser = { Value: Output; } & ((val: $mol_data_tagged_type) => Output); /** * Checks for given runtype and returns tagged version of returned type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_tagged_demo */ export function $mol_data_tagged>(config: Config): { [Type in keyof Config]: $mol_data_tagged_parser[0], $mol_data_tagged_type, Type>>; }; export {}; } declare namespace $ { /** * Checks for null or passing given runtype. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_nullable_demo */ function $mol_data_nullable(sub: Sub): ((val: Parameters[0] | null) => ReturnType | null) & { config: Sub; Value: ReturnType | null; }; } declare namespace $ { /** * Checks for undefined or passing given runtype. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_optional_demo */ function $mol_data_optional ReturnType)>(sub: Sub, fallback?: Fallback): ((val: Parameters[0] | undefined) => ReturnType | (Fallback extends undefined ? undefined : ReturnType any>>)) & { config: { sub: Sub; fallback: Fallback | undefined; }; Value: ReturnType | (Fallback extends undefined ? undefined : ReturnType any>>); }; } 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 $ { /** * 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 $ { /** * Checks for record of given fields with by its runtypes and returns expected type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_record_demo */ function $mol_data_record>(sub: Sub): ((val: $mol_type_merge<$mol_type_override[0]; }>, Pick<{ [key in keyof Sub]: Parameters[0]; }, { [Field in keyof { [key in keyof Sub]: Parameters[0]; }]: undefined extends { [key in keyof Sub]: Parameters[0]; }[Field] ? never : Field; }[keyof Sub]>>>) => Readonly<$mol_type_merge<$mol_type_override; }>, Pick<{ [key_1 in keyof Sub]: ReturnType; }, { [Field_1 in keyof { [key_1 in keyof Sub]: ReturnType; }]: undefined extends { [key_1 in keyof Sub]: ReturnType; }[Field_1] ? never : Field_1; }[keyof Sub]>>>>) & { config: Sub; Value: Readonly<$mol_type_merge<$mol_type_override; }>, Pick<{ [key in keyof Sub]: ReturnType; }, { [Field in keyof { [key in keyof Sub]: ReturnType; }]: undefined extends { [key in keyof Sub]: ReturnType; }[Field] ? never : Field; }[keyof Sub]>>>>; }; } declare namespace $ { /** * Checks for dictionary which maps strings to given runtype and returns expected type. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_dict_demo */ function $mol_data_dict(sub: Sub): ((val: Readonly>>) => Readonly>>) & { config: Sub; Value: Readonly>>; }; } declare namespace $ { /** * Checks for some of given runtype or throws error. * @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_variant_demo */ function $mol_data_variant(...sub: Sub): ((val: Parameters[0]) => ReturnType) & { config: Sub; Value: ReturnType; }; } 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 $ { /** * 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 $ { /** * 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 $ { function $mol_func_is_class(func: Func): func is Func & (new (...args: any[]) => any); } 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 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 $ { type Guard_value = $mol_type_param ? $mol_type_tail[Index] : any, 0>; type Guard = { [Index in keyof Funcs]: (Funcs[Index] extends $mol_type_unary_func ? (input: $mol_type_param) => Guard_value : new (input: $mol_type_param) => Guard_value); }; /** * Combines list of unary functions/classes to one function. * * const reparse = $mol_data_pipe( JSON.stringify , JSON.parse ) **/ export function $mol_data_pipe(...funcs: Funcs & Guard): ((this: any, input: $mol_type_param) => $mol_type_result<$mol_type_foot>) & { config: { funcs: Funcs & Guard; }; Value: $mol_type_result<$mol_type_foot>; }; export {}; } export = $; //# sourceMappingURL=node.d.ts.map