UNPKG

rambdax

Version:

Extended version of Rambda - a lightweight, faster alternative to Ramda

1,188 lines (1,022 loc) 111 kB
export type RambdaTypes = "Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "NaN" | "Function" | "Undefined" | "Async" | "Promise" | "Symbol" | "Set" | "Error" | "Map" | "WeakMap" | "Generator" | "GeneratorFunction" | "BigInt" | "ArrayBuffer" | "Date" export type NonEmptyArray<T> = [T, ...T[]]; export type ReadonlyNonEmptyArray<T> = readonly [T, ...T[]]; type LastArrayElement<ValueType extends readonly unknown[]> = ValueType extends readonly [infer ElementType] ? ElementType : ValueType extends readonly [infer _, ...infer Tail] ? LastArrayElement<Tail> : ValueType extends ReadonlyArray<infer ElementType> ? ElementType : never; type FirstArrayElement<ValueType extends readonly unknown[]> = ValueType extends readonly [infer ElementType] ? ElementType : ValueType extends readonly [...infer Head, infer _] ? FirstArrayElement<Head> : ValueType extends ReadonlyArray<infer ElementType> ? ElementType : never; export function reduceStopper<T>(input: T) : T export type IndexedIterator<T, U> = (x: T, i: number) => U; export type Iterator<T, U> = (x: T) => U; export type ObjectIterator<T, U> = (x: T, prop: string, inputObj: Dictionary<T>) => U; type Ord = number | string | boolean | Date; type Ordering = -1 | 0 | 1; type Path = string | (number | string)[]; export type RamdaPath = (number | string)[]; export type Predicate<T> = (x: T) => boolean; export type IndexedPredicate<T> = (x: T, i: number) => boolean; export type ObjectPredicate<T> = (x: T, prop: string, inputObj: Dictionary<T>) => boolean; type CondPair<T extends any[], R> = [(...val: T) => boolean, (...val: T) => R] type Prop<T, P extends keyof never> = P extends keyof Exclude<T, undefined> ? T extends undefined ? undefined : T[Extract<P, keyof T>] : undefined; type ValueOfRecord<R> = R extends Record<any, infer T> ? T : never; interface KeyValuePair<K, V> extends Array<K | V> { 0: K; 1: V; } export type Functor<A> = { map: <B>(fn: (a: A) => B) => Functor<B>; [key: string]: any }; export type Lens<S, A> = (functorFactory: (a: A) => Functor<A>) => (s: S) => Functor<S>; export type ObjPred<T = unknown> = (value: any, key: unknown extends T ? string : keyof T) => boolean; type Arity1Fn = (x: any) => any; type Arity2Fn = (x: any, y: any) => any; type Pred = (...x: any[]) => boolean; export interface Dictionary<T> {[index: string]: T} type Partial<T> = { [P in keyof T]?: T[P]}; type _TupleOf<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : _TupleOf<T, N, [T, ...R]>; export type Tuple<T, N extends number> = N extends N ? (number extends N ? T[] : _TupleOf<T, N, []>) : never; type Evolvable<E extends Evolver> = {[P in keyof E]?: Evolved<E[P]>}; type Evolver<T extends Evolvable<any> = any> = { [key in keyof Partial<T>]: ((value: T[key]) => T[key]) | (T[key] extends Evolvable<any> ? Evolver<T[key]> : never); }; type Evolve<O extends Evolvable<E>, E extends Evolver> = { [P in keyof O]: P extends keyof E ? EvolveValue<O[P], E[P]> : O[P]; }; type Evolved<A> = A extends (value: infer V) => any ? V : A extends Evolver ? Evolvable<A> : never; type EvolveNestedValue<O, E extends Evolver> = O extends object ? O extends Evolvable<E> ? Evolve<O, E> : never : never; type EvolveValue<V, E> = E extends (value: V) => any ? ReturnType<E> : E extends Evolver ? EvolveNestedValue<V, E> : never; type AtLeastOneFunctionsFlowFromRightToLeft<TArgs extends any[], TResult> = | [(...args: any) => TResult, ...Array<(args: any) => any>, (...args: TArgs) => any] | [(...args: TArgs) => TResult]; type AnyFunction = (...args: any[]) => unknown; type AnyConstructor = new (...args: any[]) => unknown; type RegExpReplacerFn = | ((m: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, p3: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, p6: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, p6: string, p7: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, p6: string, p7: string, p8: string, offset: number, s: string, groups?: Record<string, string>) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, p6: string, p7: string, p8: string, p9: string, offset: number, s: string, groups?: Record<string, string>) => string) type RegExpReplacer = string | RegExpReplacerFn /** `First`, when `First` is a supertype of `Second`; otherwise `never`. */ type IsFirstSubtypeOfSecond<First, Second> = (First extends Second ? Second : never); // RAMBDAX INTERFACES // ============================================ type Func<T> = (input: any) => T; type VoidInputFunc<T> = () => T; type Fn<In, Out> = (x: In) => Out; export type SortObjectPredicate<T> = (aProp: string, bProp: string, aValue: T, bValue: T) => number; export type IdentityFunction<T> = (x: T) => T; interface Filter<T> { (list: T[]): T[]; (obj: Dictionary<T>): Dictionary<T>; } type ArgumentTypes<T> = T extends (...args: infer U) => infer R ? U : never; type isfn<T> = (x: any, y: any) => T; interface Switchem<T> { is: isfn<Switchem<T>>; default: IdentityFunction<T>; } interface Schema { [key: string]: any; } interface SchemaAsync { [key: string]: Promise<boolean>; } export interface IsValid { input: object; schema: Schema; } export interface IsValidAsync { input: object; schema: Schema | SchemaAsync; } export type ProduceRules<Output,K extends keyof Output, Input> = { [P in K]: (input: Input) => Output[P]; }; export type ProduceAsyncRules<Output,K extends keyof Output, Input> = { [P in K]: (input: Input) => Promise<Output[P]>; }; type ProduceAsyncRule<Input> = (input: Input) => Promise<any>; type Async<T> = (x: any) => Promise<T>; type AsyncIterable<T, K> = (x: T) => Promise<K>; type AsyncIterableIndexed<T, K> = (x: T, i: number) => Promise<K>; type AsyncPredicate<T> = (x: T) => Promise<boolean>; type AsyncPredicateIndexed<T> = (x: T, i: number) => Promise<boolean>; type AsyncWithProp<T> = (x: any, prop?: string) => Promise<T>; export type ApplyDiffUpdate = {op:'update', path: string, value: any}; export type ApplyDiffAdd = {op:'add', path: string, value: any}; export type ApplyDiffRemove = {op:'remove', path: string}; export type ApplyDiffRule = ApplyDiffUpdate | ApplyDiffAdd | ApplyDiffRemove; export function F(): boolean; export function T(): boolean; /** * It adds `a` and `b`. */ export function add(a: number, b: number): number; export function add(a: number): (b: number) => number; export function addIndex(originalFn: any): (fn: any) => (list: any[]) => any[]; export function addIndex(originalFn: any): (fn: any, list: any[]) => any[]; /** * Same as `R.addIndex`, but it will passed indexes are decreasing, instead of increasing. */ export function addIndexRight(originalFn: any): (fn: any) => (list: any[]) => any[]; export function addIndexRight(originalFn: any): (fn: any, list: any[]) => any[]; /** * It replaces `index` in array `list` with the result of `replaceFn(list[i])`. */ export function adjust<T>(index: number, replaceFn: (x: T) => T, list: T[]): T[]; export function adjust<T>(index: number, replaceFn: (x: T) => T): (list: T[]) => T[]; /** * It returns `true`, if all members of array `list` returns `true`, when applied as argument to `predicate` function. */ export function all<T>(predicate: (x: T) => boolean, list: T[]): boolean; export function all<T>(predicate: (x: T) => boolean): (list: T[]) => boolean; /** * It returns `true` if all `inputs` arguments are falsy(empty objects and empty arrays are considered falsy). * * Functions are valid inputs, but these functions cannot have their own arguments. * * This method is very similar to `R.anyFalse`, `R.anyTrue` and `R.allTrue` */ export function allFalse(...inputs: any[]): boolean; /** * It returns `true`, if all functions of `predicates` return `true`, when `input` is their argument. */ export function allPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean; export function allPass<T>(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean; /** * It returns `true` if all `inputs` arguments are truthy(empty objects and empty arrays are considered falsy). */ export function allTrue(...input: any[]): boolean; /** * It returns a function which will return `true` if all of its `inputs` arguments belong to `targetType`. */ export function allType(targetType: RambdaTypes): (...input: any[]) => boolean; /** * It returns function that always returns `x`. */ export function always<T>(x: T): (...args: unknown[]) => T; /** * Logical AND */ export function and<T, U>(x: T, y: U): T | U; export function and<T>(x: T): <U>(y: U) => T | U; /** * It returns `true`, if at least one member of `list` returns true, when passed to a `predicate` function. */ export function any<T>(predicate: (x: T) => boolean, list: T[]): boolean; export function any<T>(predicate: (x: T) => boolean): (list: T[]) => boolean; /** * It returns `true` if any of `inputs` is falsy(empty objects and empty arrays are considered falsy). */ export function anyFalse(...input: any[]): boolean; /** * It accepts list of `predicates` and returns a function. This function with its `input` will return `true`, if any of `predicates` returns `true` for this `input`. */ export function anyPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean; export function anyPass<T>(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean; /** * It returns `true` if any of `inputs` arguments are truthy(empty objects and empty arrays are considered falsy). */ export function anyTrue(...input: any[]): boolean; /** * It returns a function which will return `true` if at least one of its `inputs` arguments belongs to `targetType`. * * `targetType` is one of the possible returns of `R.type` */ export function anyType(targetType: RambdaTypes): (...input: any[]) => boolean; /** * It takes a list of functions and a list of values. Then it returns a list of values obtained by applying each function to each value. */ export function ap<T, U>(fns: Array<(a: T) => U>[], vs: T[]): U[]; export function ap<T, U>(fns: Array<(a: T) => U>): (vs: T[]) => U[]; export function ap<R, A, B>(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B; /** * It returns a new list, composed of consecutive `n`-tuples from a `list`. */ export function aperture<N extends number, T>(n: N, list: T[]): Array<Tuple<T, N>> | []; export function aperture<N extends number>(n: N): <T>(list: T[]) => Array<Tuple<T, N>> | []; /** * It adds element `x` at the end of `iterable`. */ export function append<T>(xToAppend: T, iterable: T[]): T[]; export function append<T, U>(xToAppend: T, iterable: IsFirstSubtypeOfSecond<T, U>[]) : U[]; export function append<T>(xToAppend: T): <U>(iterable: IsFirstSubtypeOfSecond<T, U>[]) => U[]; export function append<T>(xToAppend: T): (iterable: T[]) => T[]; /** * It applies function `fn` to the list of arguments. * * This is useful for creating a fixed-arity function from a variadic function. `fn` should be a bound function if context is significant. */ export function apply<T = any>(fn: (...args: any[]) => T, args: any[]): T; export function apply<T = any>(fn: (...args: any[]) => T): (args: any[]) => T; /** * It changes paths in an object according to a list of operations. Valid operations are `add`, `update` and `delete`. Its use-case is while writing tests and you need to change the test data. * * Note, that you cannot use `update` operation, if the object path is missing in the input object. * Also, you cannot use `add` operation, if the object path has a value. */ export function applyDiff<Output>(rules: ApplyDiffRule[], obj: object): Output; export function applyDiff<Output>(rules: ApplyDiffRule[]): ( obj: object) => Output; export function applySpec<Spec extends Record<string, AnyFunction>>( spec: Spec ): ( ...args: Parameters<ValueOfRecord<Spec>> ) => { [Key in keyof Spec]: ReturnType<Spec[Key]> }; export function applySpec<T>(spec: any): (...args: unknown[]) => T; export function applyTo<T, U>(el: T, fn: (t: T) => U): U; export function applyTo<T>(el: T): <U>(fn: (t: T) => U) => U; export function ascend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering; export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering; /** * It makes a shallow clone of `obj` with setting or overriding the property `prop` with `newValue`. */ export function assoc<K extends PropertyKey>(prop: K): { <T>(val: T): <U extends Record<K, T>>(obj: U) => U; <U extends Record<K, T>, T>(val: T, obj: U): U; }; export function assoc<T, K extends PropertyKey>(prop: K, val: T): { <U>(obj: U): U extends Record<K, any> ? U[K] extends T ? U : Record<K, T> & Omit<U, K> : U & Record<K, T>; }; export function assoc<U, K extends keyof U, T extends U[K]>(prop: K, val: T, obj: U): U; /** * It makes a shallow clone of `obj` with setting or overriding with `newValue` the property found with `path`. */ export function assocPath<Output>(path: Path, newValue: any, obj: object): Output; export function assocPath<Output>(path: Path, newValue: any): (obj: object) => Output; export function assocPath<Output>(path: Path): (newValue: any) => (obj: object) => Output; export function binary<T extends (...arg: any[]) => any>(fn: T): (...args: any[]) => ReturnType<T>; /** * Creates a function that is bound to a context. */ export function bind<F extends AnyFunction, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>; export function bind<F extends AnyFunction, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>; /** * It returns a function with `input` argument. * * This function will return `true`, if both `firstCondition` and `secondCondition` return `true` when `input` is passed as their argument. */ export function both(pred1: Pred, pred2: Pred): Pred; export function both<T>(pred1: Predicate<T>, pred2: Predicate<T>): Predicate<T>; export function both<T>(pred1: Predicate<T>): (pred2: Predicate<T>) => Predicate<T>; export function both(pred1: Pred): (pred2: Pred) => Pred; export function call<T extends (...args: any[]) => any>(fn: T, ...args: Parameters<T>): ReturnType<T>; /** * The method is also known as `flatMap`. */ export function chain<T, U>(fn: (n: T) => U[], list: T[]): U[]; export function chain<T, U>(fn: (n: T) => U[]): (list: T[]) => U[]; /** * Restrict a number `input` to be within `min` and `max` limits. * * If `input` is bigger than `max`, then the result is `max`. * * If `input` is smaller than `min`, then the result is `min`. */ export function clamp(min: number, max: number, input: number): number; export function clamp(min: number, max: number): (input: number) => number; /** * It creates a deep copy of the `input`, which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates. */ export function clone<T>(input: T): T; export function clone<T>(input: T[]): T[]; export function collectBy<T, K extends PropertyKey>(keyFn: (value: T) => K, list: T[]): T[][]; export function collectBy<T, K extends PropertyKey>(keyFn: (value: T) => K): (list: T[]) => T[][]; /** * It returns a comparator function that can be used in `sort` method. */ export function comparator<T>(pred: (a: T, b: T) => boolean): (x: T, y: T) => Ordering; /** * It returns `inverted` version of `origin` function that accept `input` as argument. * * The return value of `inverted` is the negative boolean value of `origin(input)`. */ export function complement<T extends any[]>(predicate: (...args: T) => unknown): (...args: T) => boolean; /** * It performs right-to-left function composition. */ export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7, TResult>( ...func: [ fnLast: (a: any) => TResult, ...func: Array<(a: any) => any>, f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ] ): (...args: TArgs) => TResult; export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7, TResult>( f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R7; export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7>( f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R7; export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6>( f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R6; export function compose<TArgs extends any[], R1, R2, R3, R4, R5>( f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R5; export function compose<TArgs extends any[], R1, R2, R3, R4>( f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R4; export function compose<TArgs extends any[], R1, R2, R3>( f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R3; export function compose<TArgs extends any[], R1, R2>( f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R2; export function compose<TArgs extends any[], R1>( f1: (...args: TArgs) => R1 ): (...args: TArgs) => R1; /** * Asynchronous version of `R.compose`. `await`s the result of each function before passing it to the next. Returns a `Promise` of the result. */ export function composeAsync<TArg, R1, R2, R3, R4, R5, R6, R7, TResult>( ...func: [ fnLast: (a: any) => TResult, ...func: Array<(a: any) => any>, f7: (a: Awaited<R6>) => R7, f6: (a: Awaited<R5>) => R6, f5: (a: Awaited<R4>) => R5, f4: (a: Awaited<R3>) => R4, f3: (a: Awaited<R2>) => R3, f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ] ): (a: TArg | Promise<TArg>) => TResult; export function composeAsync<TArg, R1, R2, R3, R4, R5, R6, R7, TResult>( f7: (a: Awaited<R6>) => R7, f6: (a: Awaited<R5>) => R6, f5: (a: Awaited<R4>) => R5, f4: (a: Awaited<R3>) => R4, f3: (a: Awaited<R2>) => R3, f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R7; export function composeAsync<TArg, R1, R2, R3, R4, R5, R6, R7>( f7: (a: Awaited<R6>) => R7, f6: (a: Awaited<R5>) => R6, f5: (a: Awaited<R4>) => R5, f4: (a: Awaited<R3>) => R4, f3: (a: Awaited<R2>) => R3, f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R7; export function composeAsync<TArg, R1, R2, R3, R4, R5, R6>( f6: (a: Awaited<R5>) => R6, f5: (a: Awaited<R4>) => R5, f4: (a: Awaited<R3>) => R4, f3: (a: Awaited<R2>) => R3, f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R6; export function composeAsync<TArg, R1, R2, R3, R4, R5>( f5: (a: Awaited<R4>) => R5, f4: (a: Awaited<R3>) => R4, f3: (a: Awaited<R2>) => R3, f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R5; export function composeAsync<TArg, R1, R2, R3, R4>( f4: (a: Awaited<R3>) => R4, f3: (a: Awaited<R2>) => R3, f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R4; export function composeAsync<TArg, R1, R2, R3>( f3: (a: Awaited<R2>) => R3, f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R3; export function composeAsync<TArg, R1, R2>( f2: (a: Awaited<R1>) => R2, f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R2; export function composeAsync<TArg, R1>( f1: (a: Awaited<TArg>) => R1 ): (a: TArg | Promise<TArg>) => R1; export function composeWith<TArgs extends any[], TResult>( transformer: (fn: (...args: any[]) => any, intermediatResult: any) => any, fns: AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>, ): (...args: TArgs) => TResult; export function composeWith( transformer: (fn: (...args: any[]) => any, intermediatResult: any) => any, ): <TArgs extends any[], TResult>( fns: AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>, ) => (...args: TArgs) => TResult; /** * It returns a new string or array, which is the result of merging `x` and `y`. */ export function concat<T>(x: T[], y: T[]): T[]; export function concat<T>(x: T[]): (y: T[]) => T[]; export function concat(x: string, y: string): string; export function concat(x: string): (y: string) => string; /** * It takes list with `conditions` and returns a new function `fn` that expects `input` as argument. * * This function will start evaluating the `conditions` in order to find the first winner(order of conditions matter). * * The winner is this condition, which left side returns `true` when `input` is its argument. Then the evaluation of the right side of the winner will be the final result. * * If no winner is found, then `fn` returns `undefined`. */ export function cond<T extends any[], R>(conditions: Array<CondPair<T, R>>): (...args: T) => R; /** * It returns `true` if all of `target` object properties are `R.equal` to `compareTo` object. */ export function contains<T, U>(target: T, compareTo: U): boolean; export function contains<T, U>(target: T): (compareTo: U) => boolean; /** * Accepts a converging function and a list of branching functions and returns a new function. When invoked, this new function is applied to some arguments, each branching function is applied to those same arguments. The results of each branching function are passed as arguments to the converging function to produce the return value. */ export function converge(after: ((...a: any[]) => any), fns: ((...x: any[]) => any)[]): (...y: any[]) => any; /** * It counts how many times `predicate` function returns `true`, when supplied with iteration of `list`. */ export function count<T>(predicate: (x: T) => boolean, list: T[]): number; export function count<T>(predicate: (x: T) => boolean): (list: T[]) => number; /** * It counts elements in a list after each instance of the input list is passed through `transformFn` function. */ export function countBy<T extends unknown>(transformFn: (x: T) => any, list: T[]): Record<string, number>; export function countBy<T extends unknown>(transformFn: (x: T) => any): (list: T[]) => Record<string, number>; /** * It expects a function as input and returns its curried version. */ export function curry(fn: AnyFunction): (...a: any[]) => any; /** * It returns a curried equivalent of the provided function, with the specified arity. */ export function curryN(length: number, fn: AnyFunction): (...a: any[]) => any; export function debounce<T, U>(fn: (input: T) => U, ms: number, immediate?: boolean): (input: T) => void; export function debounce<T, Q, U>(fn: (input1: T, input2: Q) => U, ms: number, immediate?: boolean): (input1: T, input2: Q) => void; export function debounce<T, Q, Z, U>(fn: (input1: T, input2: Q, input3: Z) => U, ms: number, immediate?: boolean): (input1: T, input2: Q, input3: Z) => void; /** * It decrements a number. */ export function dec(x: number): number; /** * It returns `defaultValue`, if all of `inputArguments` are `undefined`, `null` or `NaN`. * * Else, it returns the first truthy `inputArguments` instance(from left to right). */ export function defaultTo<T>(defaultValue: T, input: T | null | undefined): T; export function defaultTo<T>(defaultValue: T): (input: T | null | undefined) => T; /** * `setTimeout` as a promise that resolves to `R.DELAY` variable after `ms` milliseconds. */ export function delay(ms: number): Promise<'RAMBDAX_DELAY'>; export function descend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering; export function descend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering; /** * It returns the uniq set of all elements in the first list `a` not contained in the second list `b`. * * `R.equals` is used to determine equality. */ export function difference<T>(a: T[], b: T[]): T[]; export function difference<T>(a: T[]): (b: T[]) => T[]; export function differenceWith<T1, T2>( pred: (a: T1, b: T2) => boolean, list1: T1[], list2: T2[], ): T1[]; export function differenceWith<T1, T2>( pred: (a: T1, b: T2) => boolean, ): (list1: T1[], list2: T2[]) => T1[]; export function differenceWith<T1, T2>( pred: (a: T1, b: T2) => boolean, list1: T1[], ): (list2: T2[]) => T1[]; /** * It returns a new object that does not contain property `prop`. */ export function dissoc<K extends PropertyKey>(prop: K): <U extends { [P in K]?: any}>(obj: string extends keyof U ? U : undefined extends U[K] ? U : never) => U; export function dissoc<U, K extends keyof U>(prop: string extends keyof U ? K : undefined extends U[K] ? K : never, obj: U): U; export function dissocPath<T>(path: Path, obj: any): T; export function dissocPath<T>(path: Path): (obj: any) => T; export function divide(x: number, y: number): number; export function divide(x: number): (y: number) => number; /** * It returns `howMany` items dropped from beginning of list or string `input`. */ export function drop<T>(howMany: number, input: T[]): T[]; export function drop(howMany: number, input: string): string; export function drop<T>(howMany: number): { <T>(input: T[]): T[]; (input: string): string; }; /** * It returns `howMany` items dropped from the end of list or string `input`. */ export function dropLast<T>(howMany: number, input: T[]): T[]; export function dropLast(howMany: number, input: string): string; export function dropLast<T>(howMany: number): { <T>(input: T[]): T[]; (input: string): string; }; export function dropLastWhile(predicate: (x: string) => boolean, iterable: string): string; export function dropLastWhile(predicate: (x: string) => boolean): (iterable: string) => string; export function dropLastWhile<T>(predicate: (x: T) => boolean, iterable: T[]): T[]; export function dropLastWhile<T>(predicate: (x: T) => boolean): <T>(iterable: T[]) => T[]; /** * It removes any successive duplicates according to `R.equals`. */ export function dropRepeats<T>(list: T[]): T[]; export function dropRepeatsBy<T, U>(fn: (a: T) => U, list: T[]): T[]; export function dropRepeatsBy<T, U>( fn: (a: T) => U ): (list: T[]) => T[]; export function dropRepeatsBy(fn: any): <T>(list: T[]) => T[]; export function dropRepeatsWith<T>(predicate: (x: T, y: T) => boolean, list: T[]): T[]; export function dropRepeatsWith<T>(predicate: (x: T, y: T) => boolean): (list: T[]) => T[]; export function dropWhile(fn: Predicate<string>, iterable: string): string; export function dropWhile(fn: Predicate<string>): (iterable: string) => string; export function dropWhile<T>(fn: Predicate<T>, iterable: T[]): T[]; export function dropWhile<T>(fn: Predicate<T>): (iterable: T[]) => T[]; /** * It returns a new `predicate` function from `firstPredicate` and `secondPredicate` inputs. * * This `predicate` function will return `true`, if any of the two input predicates return `true`. */ export function either(firstPredicate: Pred, secondPredicate: Pred): Pred; export function either<T>(firstPredicate: Predicate<T>, secondPredicate: Predicate<T>): Predicate<T>; export function either<T>(firstPredicate: Predicate<T>): (secondPredicate: Predicate<T>) => Predicate<T>; export function either(firstPredicate: Pred): (secondPredicate: Pred) => Pred; export function empty<T>(x: T): T; /** * When iterable is a string, then it behaves as `String.prototype.endsWith`. * When iterable is a list, then it uses R.equals to determine if the target list ends in the same way as the given target. */ export function endsWith<T extends string>(question: T, str: string): boolean; export function endsWith<T extends string>(question: T): (str: string) => boolean; export function endsWith<T>(question: T[], list: T[]): boolean; export function endsWith<T>(question: T[]): (list: T[]) => boolean; export function eqBy<T>(fn: (a: T) => unknown, a: T, b: T): boolean; export function eqBy<T>(fn: (a: T) => unknown, a: T): (b: T) => boolean; export function eqBy<T>(fn: (a: T) => unknown): { (a: T, b: T): boolean; (a: T): (b: T) => boolean; }; /** * It returns `true` if property `prop` in `obj1` is equal to property `prop` in `obj2` according to `R.equals`. */ export function eqProps<T, U>(prop: string, obj1: T, obj2: U): boolean; export function eqProps<P extends string>(prop: P): <T, U>(obj1: Record<P, T>, obj2: Record<P, U>) => boolean; export function eqProps<T>(prop: string, obj1: T): <U>(obj2: U) => boolean; /** * It deeply compares `x` and `y` and returns `true` if they are equal. */ export function equals<T>(x: T, y: T): boolean; export function equals<T>(x: T): (y: T) => boolean; /** * It takes object or array of functions as set of rules. These `rules` are applied to the `iterable` input to produce the result. */ export function evolve<T, U>(rules: ((x: T) => U)[], list: T[]): U[]; export function evolve<T, U>(rules: ((x: T) => U)[]) : (list: T[]) => U[]; export function evolve<E extends Evolver, V extends Evolvable<E>>(rules: E, obj: V): Evolve<V, E>; export function evolve<E extends Evolver>(rules: E): <V extends Evolvable<E>>(obj: V) => Evolve<V, E>; /** * Opposite of `R.includes` * * `R.equals` is used to determine equality. */ export function excludes(valueToFind: string, input: string[] | string): boolean; export function excludes(valueToFind: string): (input: string[] | string) => boolean; export function excludes<T>(valueToFind: T, input: T[]): boolean; export function excludes<T>(valueToFind: T): (input: T[]) => boolean; /** * It filters list or object `input` using a `predicate` function. */ export function filter<T>(predicate: Predicate<T>): (input: T[]) => T[]; export function filter<T>(predicate: Predicate<T>, input: T[]): T[]; export function filter<T, U>(predicate: ObjectPredicate<T>): (x: Dictionary<T>) => Dictionary<T>; export function filter<T>(predicate: ObjectPredicate<T>, x: Dictionary<T>): Dictionary<T>; export function filterArray<T>(predicate: Predicate<T>): (input: T[]) => T[]; export function filterArray<T>(predicate: Predicate<T>, input: T[]): T[]; /** * Asynchronous version of `R.filter` */ export function filterAsync<T>(fn: AsyncPredicate<T>, list: T[]): Promise<T[]>; export function filterAsync<T>(fn: AsyncPredicateIndexed<T>, list: T[]): Promise<T[]>; export function filterAsync<T>(fn: AsyncPredicate<T>) : ( list: T[]) => Promise<T[]>; export function filterAsync<T>(fn: AsyncPredicateIndexed<T>) : ( list: T[]) => Promise<T[]>; /** * Same as `R.filter`, but it passes index/property as second argument to the predicate, when looping over arrays/objects. */ export function filterIndexed<T>(predicate: IndexedPredicate<T>): (x: T[]) => T[]; export function filterIndexed<T>(predicate: IndexedPredicate<T>, x: T[]): T[]; export function filterIndexed<T, U>(predicate: ObjectPredicate<T>): (x: Dictionary<T>) => Dictionary<T>; export function filterIndexed<T>(predicate: ObjectPredicate<T>, x: Dictionary<T>): Dictionary<T>; export function filterObject<T>(predicate: ObjectPredicate<T>): (x: Dictionary<T>) => Dictionary<T>; export function filterObject<T>(predicate: ObjectPredicate<T>, x: Dictionary<T>): Dictionary<T>; /** * It returns the first element of `list` that satisfy the `predicate`. * * If there is no such element, it returns `undefined`. */ export function find<T>(predicate: (x: T) => boolean, list: T[]): T | undefined; export function find<T>(predicate: (x: T) => boolean): (list: T[]) => T | undefined; /** * Asynchronous version of `R.find`. */ export function findAsync<T>(predicate: (x: T) => Promise<boolean>, list: T[]): T | undefined; export function findAsync<T>(predicate: (x: T) => Promise<boolean>): (list: T[]) => T | undefined; /** * It returns the index of the first element of `list` satisfying the `predicate` function. * * If there is no such element, then `-1` is returned. */ export function findIndex<T>(predicate: (x: T) => boolean, list: T[]): number; export function findIndex<T>(predicate: (x: T) => boolean): (list: T[]) => number; /** * It returns the last element of `list` satisfying the `predicate` function. * * If there is no such element, then `undefined` is returned. */ export function findLast<T>(fn: (x: T) => boolean, list: T[]): T | undefined; export function findLast<T>(fn: (x: T) => boolean): (list: T[]) => T | undefined; /** * It returns the index of the last element of `list` satisfying the `predicate` function. * * If there is no such element, then `-1` is returned. */ export function findLastIndex<T>(predicate: (x: T) => boolean, list: T[]): number; export function findLastIndex<T>(predicate: (x: T) => boolean): (list: T[]) => number; /** * It deeply flattens an array. */ export function flatten<T>(list: any[]): T[]; /** * It returns function which calls `fn` with exchanged first and second argument. */ export function flip<T, U, TResult>(fn: (arg0: T, arg1: U) => TResult): (arg1: U, arg0?: T) => TResult; /** * It applies `iterable` function over all members of `list` and returns `list`. */ export function forEach<T>(fn: Iterator<T, void>, list: T[]): T[]; export function forEach<T>(fn: Iterator<T, void>): (list: T[]) => T[]; export function forEach<T>(fn: ObjectIterator<T, void>, list: Dictionary<T>): Dictionary<T>; export function forEach<T, U>(fn: ObjectIterator<T, void>): (list: Dictionary<T>) => Dictionary<T>; export function forEachIndexed<T>(fn: IndexedIterator<T, void>, list: T[]): T[]; export function forEachIndexed<T>(fn: IndexedIterator<T, void>): (list: T[]) => T[]; export function forEachIndexed<T>(fn: ObjectIterator<T, void>, list: Dictionary<T>): Dictionary<T>; export function forEachIndexed<T, U>(fn: ObjectIterator<T, void>): (list: Dictionary<T>) => Dictionary<T>; export function forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void, obj: T): T; export function forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void): (obj: T) => T; /** * It transforms a `listOfPairs` to an object. */ export function fromPairs<V>(listOfPairs: ([number, V])[]): { [index: number]: V }; export function fromPairs<V>(listOfPairs: ([string, V])[]): { [index: string]: V }; /** * The set of methods `R.setter`, `R.getter` and `R.reset` allow different parts of your logic to access communicate indirectly via shared cache object. * * Usually these methods show that you might need to refactor to classes. Still, they can be helpful meanwhile. * * `R.getter`: It provides access to the cache object. If `undefined` is used as a key, this method will return the whole cache object. If `string` is passed, then it will return cache value for this key. If array of `string` is passed, then it assume that this is array of keys and it will return the corresponding cache values for these keys. * * `R.setter`: It allows cache object's keys to be changed. You can either set individual key-value pairs with `R.setter(key, value)` or you pass directly object, which will be merged with the cache object. * * `R.reset`: It resets the cache object. */ export function getter<T>(keyOrKeys: string | string[] | undefined): T; /** * It transforms multiline string to single line by gluing together the separate lines with the `glueString` and removing the empty spaces. By default `glueString` is equal to single space, so if that is what you need, then you can just pass a single argument. */ export function glue(input: string, glueString?: string): string; /** * It splits `list` according to a provided `groupFn` function and returns an object. */ export function groupBy<T, K extends string = string>(fn: (a: T) => K): (list: T[]) => Partial<Record<K, T[]>>; export function groupBy<T, K extends string = string>(fn: (a: T) => K, list: T[]): Partial<Record<K, T[]>>; /** * It returns separated version of list or string `input`, where separation is done with equality `compareFn` function. */ export function groupWith<T>(compareFn: (x: T, y: T) => boolean): (input: T[]) => (T[])[]; export function groupWith<T>(compareFn: (x: T, y: T) => boolean, input: T[]): (T[])[]; export function groupWith<T>(compareFn: (x: T, y: T) => boolean, input: string): string[]; export function gt<T, U>(x: T, y: U): boolean; export function gt<T, U>(x: T): (y: U) => boolean; export function gte<T, U>(x: T, y: U): boolean; export function gte<T, U>(x: T): (y: U) => boolean; /** * It returns `true` if `obj` has property `prop`. */ export function has<T>(prop: string, obj: T): boolean; export function has(prop: string): <T>(obj: T) => boolean; export function hasIn(searchProperty: string): <T>(obj: T) => boolean; export function hasIn<T>(searchProperty: string, obj: T): boolean; /** * It will return true, if `input` object has truthy `path`(calculated with `R.path`). */ export function hasPath<T>( path: string | string[], input: object ): boolean; export function hasPath<T>( path: string | string[] ): (input: object) => boolean; /** * It returns the first element of list or string `input`. It returns `undefined` if array has length of 0. */ export function head(str: string): string; export function head(str: ''): undefined; export function head(list: readonly[]): undefined; export function head<T>(list: never[]): undefined; export function head<T extends unknown[]>(array: T): FirstArrayElement<T> export function head<T extends readonly unknown[]>(array: T): FirstArrayElement<T> /** * It returns `true` if its arguments `a` and `b` are identical. * * Otherwise, it returns `false`. */ export function identical<T>(x: T, y: T): boolean; export function identical<T>(x: T): (y: T) => boolean; /** * It just passes back the supplied `input` argument. */ export function identity<T>(input: T): T; /** * It expects `condition`, `onTrue` and `onFalse` functions as inputs and it returns a new function with example name of `fn`. * * When `fn`` is called with `input` argument, it will return either `onTrue(input)` or `onFalse(input)` depending on `condition(input)` evaluation. */ export function ifElse<T, TFiltered extends T, TOnTrueResult, TOnFalseResult>( pred: (a: T) => a is TFiltered, onTrue: (a: TFiltered) => TOnTrueResult, onFalse: (a: Exclude<T, TFiltered>) => TOnFalseResult, ): (a: T) => TOnTrueResult | TOnFalseResult; export function ifElse<TArgs extends any[], TOnTrueResult, TOnFalseResult>(fn: (...args: TArgs) => boolean, onTrue: (...args: TArgs) => TOnTrueResult, onFalse: (...args: TArgs) => TOnFalseResult): (...args: TArgs) => TOnTrueResult | TOnFalseResult; /** * Asynchronous version of `R.ifElse`. Any of `condition`, `ifFn` and `elseFn` can be either asynchronous or synchronous function. */ export function ifElseAsync<T, U>( condition: (x: T) => Promise<boolean>, onTrue: (x: T) => U, onFalse: (x: T) => U, ): (x: T) => Promise<U>; export function ifElseAsync<T, U>( condition: (x: T) => boolean, onTrue: (x: T) => Promise<U>, onFalse: (x: T) => Promise<U>, ): (x: T) => Promise<U>; export function ifElseAsync<T, U>( condition: (x: T) => Promise<boolean>, onTrue: (x: T) => Promise<U>, onFalse: (x: T) => Promise<U>, ): (x: T) => Promise<U>; export function ifElseAsync<T, K, U>( condition: (x: T, y: K) => Promise<boolean>, onTrue: (x: T, y: K) => U, onFalse: (x: T, y: K) => U, ): (x: T, y: K) => Promise<U>; export function ifElseAsync<T, K, U>( condition: (x: T, y: K) => boolean, onTrue: (x: T, y: K) => Promise<U>, onFalse: (x: T, y: K) => Promise<U>, ): (x: T, y: K) => Promise<U>; export function ifElseAsync<T, K, U>( condition: (x: T, y: K) => Promise<boolean>, onTrue: (x: T, y: K) => Promise<U>, onFalse: (x: T, y: K) => Promise<U>, ): (x: T, y: K) => Promise<U>; /** * It increments a number. */ export function inc(x: number): number; /** * If `input` is string, then this method work as native `String.includes`. * * If `input` is array, then `R.equals` is used to define if `valueToFind` belongs to the list. */ export function includes<T extends string>(valueToFind: T, input: string): boolean; export function includes<T extends string>(valueToFind: T): (input: string) => boolean; export function includes<T>(valueToFind: T, input: T[]): boolean; export function includes<T>(valueToFind: T): (input: T[]) => boolean; /** * It generates object with properties provided by `condition` and values provided by `list` array. * * If `condition` is a function, then all list members are passed through it. * * If `condition` is a string, then all list members are passed through `R.path(condition)`. */ export function indexBy<T, K extends string | number = string>(condition: (key: T) => K, list: T[]): { [key in K]: T }; export function indexBy<T, K extends string | number | undefined = string>(condition: (key: T) => K, list: T[]): { [key in NonNullable<K>]?: T }; export function indexBy<T, K extends string | number = string>(condition: (key: T) => K): (list: T[]) => { [key in K]: T }; export function indexBy<T, K extends string | number | undefined = string>(condition: (key: T) => K | undefined): (list: T[]) => { [key in NonNullable<K>]?: T }; export function indexBy<T>(condition: string, list: T[]): { [key: string]: T }; export function indexBy<T>(condition: string): (list: T[]) => { [key: string]: T }; /** * It returns the index of the first element of `list` equals to `valueToFind`. * * If there is no such element, it returns `-1`. */ export function indexOf<T>(valueToFind: T, list: T[]): number; export function indexOf<T>(valueToFind: T): (list: T[]) => number; /** * It returns all but the last element of list or string `input`. */ export function init<T extends unknown[]>(input: T): T extends readonly [...infer U, any] ? U : [...T]; export function init(input: string): string; /** * It returns a new list by applying a `predicate` function to all elements of `list1` and `list2` and keeping only these elements where `predicate` returns `true`. */ export function innerJoin<T1, T2>( pred: (a: T1, b: T2) => boolean, ): (list1: T1[], list2: T2[]) => T1[]; export function innerJoin<T1, T2>( pred: (a: T1, b: T2) => boolean, list1: T1[], ): (list2: T2[]) => T1[]; export function innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: T1[], list2: T2[]): T1[]; export function insert(index: number): <T>(itemToInsert: T, list: T[]) => T[]; export function insert<T>(index: number, itemToInsert: T): (list: T[]) => T[]; export function insert<T>(index: number, itemToInsert: T, list: T[]): T[]; export function insertAll(index: number): <T>(itemsToInsert: T[], list: T[]) => T[]; export function insertAll<T>(index: number, itemsToInsert: T[]): (list: T[]) => T[]; export function insertAll<T>(index: number, itemsToInsert: T[], list: T[]): T[]; /** * It generates a new string from `inputWithTags` by replacing all `{{x}}` occurrences with values provided by `templateArguments`. */ export function interpolate(inputWithTags: string, templateArguments: object): string; export function interpolate(inputWithTags: string): (templateArguments: object) => string; /** * It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`. */ export function intersection<T>(listA: T[], listB: T[]): T[]; export function intersection<T>(listA: T[]): (listB: T[]) => T[]; /** * It adds a `separator` between members of `list`. */ export function intersperse<T>(separator: T, list: T[]): T[]; export function intersperse<T>(separator: T): (list: T[]) => T[]; /** * It returns `true` if `x` is instance of `targetPrototype`. */ export function is<C extends () => any>(targetPrototype: C, val: any): val is ReturnType<C>; export function is<C extends new () => any>(targetPrototype: C, val: any): val is InstanceType<C>; export function is<C extends () => any>(targetPrototype: C): (val: any) => val is ReturnType<C>; export function is<C extends new () => any>(targetPrototype: C): (val: any) => val is InstanceType<C>; /** * It returns `true` if `x` is `empty`. */ export function isEmpty<T>(x: T): boolean; /** * It returns `true` if `x` is either `null` or `undefined`. */ export function isNil(x: any): x is null | undefined; export function isNotEmpty<T>(value: T[]): value is NonEmptyArray<T>; export function isNotEmpty<T>(value: readonly T[]): value is ReadonlyNonEmptyArray<T>; export function isNotEmpty(value: any): boolean; export function isNotNil<T>(value: T): value is NonNullable<T>; export function isPromise(input: any): boolean; /** * It returns true if `targetType` is equal to type of `input` according to `R.type`. */ export function isType(targetType: RambdaTypes, input: any): boolean; export function isType(targetType: RambdaTypes): (input: any) => boolean; /** * It checks if `input` is following `schema` specifications. * * If validation fails, it returns `false`. * * Please [check the detailed explanation](https://github.com/selfrefactor/rambdax/blob/master/files/isValid.md) as it is hard to write a short description for this method. */ export function isValid({input: object, schema: Schema}: IsValid): boolean; /** * Asynchronous version of `R.isValid` */ export function isValidAsync(x: IsValidAsync): Promise<boolean>; /** * It returns a string of all `list` instances joined with a `glue`. */ export function join<T>(glue: string, list: T[]): string; export function join<T>(glue: string): (list: T[]) => string; /** * It applies list of function to a list of inputs. */ export function juxt<A extends any[], R1>(fns: [(...a: A) => R1]): (...a: A) => [R1]; export function juxt<A extends any[], R1, R2>(fns: [(...a: A) => R1, (...a: A) => R2]): (...a: A) => [R1, R2]; export function juxt<A extends any[], R1, R2, R3>(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3]): (...a: A) => [R1, R2, R3]; export function juxt<A extends any[], R1, R2, R3, R4>(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3, (...a: A) => R4]): (...a: A) => [R1, R2, R3, R4]; export function juxt<A extends any[], R1, R2, R3, R4, R5>(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3, (...a: A) => R4, (...a: A) => R5]): (...a: A) => [R1, R2, R3, R4, R5]; export function juxt<A extends any[], U>(fns: Array<(...args: A) => U>): (...args: A) => U[]; /** * It applies `Object.keys` over `x` and returns its keys. */ export function keys<T extends object>(x: T): (keyof T & string)[]; export function keys<T>(x: T): string[]; /** * It returns the last element of `input`, as the `input` can be either a string or an array. It returns `undefined` if array has length of 0. */ export function last(str: ''): undefined; export function last(str: string): string; export function last(list: readonly[]): undefined; export function last(list: never[]): undefined; export function last<T extends unknown[]>(array: T): LastArrayElement<T>; export function last<T extends readonly unknown[]>(array: T): LastArrayElement<T>; export function last(str: string): string | undefined; /** * It returns the last index of `target` in `list` array. * * `R.equals` is used to determine equality between `target` and members of `list`. * * If there is no such index, then `-1` is returned. */ export function lastIndexOf<T>(target: T, list: T[]): number; export function lastIndexOf<T>(target: T): (list: T[]) => number; /** * It returns the `length` property of list or string `input`. */ export function length<T>(input: T[]): number; /** * It returns a `lens` for the given `getter` and `setter` functions. * * The `getter` **gets** the value of the focus; the `setter` **sets** the value of the focus. * * The setter should not mutate the data structure. */ export function lens<S, A>(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens<S, A>; /** * It returns `true` if data structure focused by the given lens equals to the `target` value. * * `R.equals` is used to determine equality. */ export function lensEq(lens: Function, value: any, data: any): boolean; export function lensEq(lens: Function, value: any): (data: any) => boolean; export function lensEq(lens: Function): (value: any) => (data: any) => boolean; /** * It returns a lens that focuses on specified `index`. */ export function lensIndex<A>(n: number): Lens<A[], A>; export function lensIndex<A extends any[], N extends number>(n: N): Lens<A, A[N]>; /** * It returns a lens that focuses on specified `path`. */ export function lensPath<S, K0 extends keyof S = keyof S>(path: [K0]): Lens<S, S[K0]>; export function lensPath<S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0]>( path: [K0,