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[]]; export type ReadonlyNonEmptyArray = readonly [T, ...T[]]; type LastArrayElement = ValueType extends readonly [infer ElementType] ? ElementType : ValueType extends readonly [infer _, ...infer Tail] ? LastArrayElement : ValueType extends ReadonlyArray ? ElementType : never; type FirstArrayElement = ValueType extends readonly [infer ElementType] ? ElementType : ValueType extends readonly [...infer Head, infer _] ? FirstArrayElement : ValueType extends ReadonlyArray ? ElementType : never; export function reduceStopper(input: T) : T export type IndexedIterator = (x: T, i: number) => U; export type Iterator = (x: T) => U; export type ObjectIterator = (x: T, prop: string, inputObj: Dictionary) => 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 = (x: T) => boolean; export type IndexedPredicate = (x: T, i: number) => boolean; export type ObjectPredicate = (x: T, prop: string, inputObj: Dictionary) => boolean; type CondPair = [(...val: T) => boolean, (...val: T) => R] type Prop = P extends keyof Exclude ? T extends undefined ? undefined : T[Extract] : undefined; type ValueOfRecord = R extends Record ? T : never; interface KeyValuePair extends Array { 0: K; 1: V; } export type Functor = { map: (fn: (a: A) => B) => Functor; [key: string]: any }; export type Lens = (functorFactory: (a: A) => Functor) => (s: S) => Functor; export type ObjPred = (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 {[index: string]: T} type Partial = { [P in keyof T]?: T[P]}; type _TupleOf = R['length'] extends N ? R : _TupleOf; export type Tuple = N extends N ? (number extends N ? T[] : _TupleOf) : never; type Evolvable = {[P in keyof E]?: Evolved}; type Evolver = any> = { [key in keyof Partial]: ((value: T[key]) => T[key]) | (T[key] extends Evolvable ? Evolver : never); }; type Evolve, E extends Evolver> = { [P in keyof O]: P extends keyof E ? EvolveValue : O[P]; }; type Evolved = A extends (value: infer V) => any ? V : A extends Evolver ? Evolvable : never; type EvolveNestedValue = O extends object ? O extends Evolvable ? Evolve : never : never; type EvolveValue = E extends (value: V) => any ? ReturnType : E extends Evolver ? EvolveNestedValue : never; type AtLeastOneFunctionsFlowFromRightToLeft = | [(...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) | ((m: string, p1: string, offset: number, s: string, groups?: Record) => string) | ((m: string, p1: string, p2: string, offset: number, s: string, groups?: Record) => string) | ((m: string, p1: string, p2: string, p3: string, offset: number, s: string, groups?: Record) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, offset: number, s: string, groups?: Record) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, offset: number, s: string, groups?: Record) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, p6: string, offset: number, s: string, groups?: Record) => string) | ((m: string, p1: string, p2: string, p3: string, p4: string, p5: string, p6: string, p7: string, offset: number, s: string, groups?: Record) => 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) | ((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) type RegExpReplacer = string | RegExpReplacerFn /** `First`, when `First` is a supertype of `Second`; otherwise `never`. */ type IsFirstSubtypeOfSecond = (First extends Second ? Second : never); // RAMBDAX INTERFACES // ============================================ type Func = (input: any) => T; type VoidInputFunc = () => T; type Fn = (x: In) => Out; export type SortObjectPredicate = (aProp: string, bProp: string, aValue: T, bValue: T) => number; export type IdentityFunction = (x: T) => T; interface Filter { (list: T[]): T[]; (obj: Dictionary): Dictionary; } type ArgumentTypes = T extends (...args: infer U) => infer R ? U : never; type isfn = (x: any, y: any) => T; interface Switchem { is: isfn>; default: IdentityFunction; } interface Schema { [key: string]: any; } interface SchemaAsync { [key: string]: Promise; } export interface IsValid { input: object; schema: Schema; } export interface IsValidAsync { input: object; schema: Schema | SchemaAsync; } export type ProduceRules = { [P in K]: (input: Input) => Output[P]; }; export type ProduceAsyncRules = { [P in K]: (input: Input) => Promise; }; type ProduceAsyncRule = (input: Input) => Promise; type Async = (x: any) => Promise; type AsyncIterable = (x: T) => Promise; type AsyncIterableIndexed = (x: T, i: number) => Promise; type AsyncPredicate = (x: T) => Promise; type AsyncPredicateIndexed = (x: T, i: number) => Promise; type AsyncWithProp = (x: any, prop?: string) => Promise; 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(index: number, replaceFn: (x: T) => T, list: T[]): T[]; export function adjust(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(predicate: (x: T) => boolean, list: T[]): boolean; export function all(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(predicates: ((x: T) => boolean)[]): (input: T) => boolean; export function allPass(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(x: T): (...args: unknown[]) => T; /** * Logical AND */ export function and(x: T, y: U): T | U; export function and(x: T): (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(predicate: (x: T) => boolean, list: T[]): boolean; export function any(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(predicates: ((x: T) => boolean)[]): (input: T) => boolean; export function anyPass(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(fns: Array<(a: T) => U>[], vs: T[]): U[]; export function ap(fns: Array<(a: T) => U>): (vs: T[]) => U[]; export function ap(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: N, list: T[]): Array> | []; export function aperture(n: N): (list: T[]) => Array> | []; /** * It adds element `x` at the end of `iterable`. */ export function append(xToAppend: T, iterable: T[]): T[]; export function append(xToAppend: T, iterable: IsFirstSubtypeOfSecond[]) : U[]; export function append(xToAppend: T): (iterable: IsFirstSubtypeOfSecond[]) => U[]; export function append(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(fn: (...args: any[]) => T, args: any[]): T; export function apply(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(rules: ApplyDiffRule[], obj: object): Output; export function applyDiff(rules: ApplyDiffRule[]): ( obj: object) => Output; export function applySpec>( spec: Spec ): ( ...args: Parameters> ) => { [Key in keyof Spec]: ReturnType }; export function applySpec(spec: any): (...args: unknown[]) => T; export function applyTo(el: T, fn: (t: T) => U): U; export function applyTo(el: T): (fn: (t: T) => U) => U; export function ascend(fn: (obj: T) => Ord, a: T, b: T): Ordering; export function ascend(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(prop: K): { (val: T): >(obj: U) => U; , T>(val: T, obj: U): U; }; export function assoc(prop: K, val: T): { (obj: U): U extends Record ? U[K] extends T ? U : Record & Omit : U & Record; }; export function assoc(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(path: Path, newValue: any, obj: object): Output; export function assocPath(path: Path, newValue: any): (obj: object) => Output; export function assocPath(path: Path): (newValue: any) => (obj: object) => Output; export function binary any>(fn: T): (...args: any[]) => ReturnType; /** * Creates a function that is bound to a context. */ export function bind(fn: F, thisObj: T): (...args: Parameters) => ReturnType; export function bind(fn: F): (thisObj: T) => (...args: Parameters) => ReturnType; /** * 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(pred1: Predicate, pred2: Predicate): Predicate; export function both(pred1: Predicate): (pred2: Predicate) => Predicate; export function both(pred1: Pred): (pred2: Pred) => Pred; export function call any>(fn: T, ...args: Parameters): ReturnType; /** * The method is also known as `flatMap`. */ export function chain(fn: (n: T) => U[], list: T[]): U[]; export function chain(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(input: T): T; export function clone(input: T[]): T[]; export function collectBy(keyFn: (value: T) => K, list: T[]): T[][]; export function collectBy(keyFn: (value: T) => K): (list: T[]) => T[][]; /** * It returns a comparator function that can be used in `sort` method. */ export function comparator(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(predicate: (...args: T) => unknown): (...args: T) => boolean; /** * It performs right-to-left function composition. */ export function compose( ...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( 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( 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( 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( 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( f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R4; export function compose( f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R3; export function compose( f2: (a: R1) => R2, f1: (...args: TArgs) => R1 ): (...args: TArgs) => R2; export function compose( 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( ...func: [ fnLast: (a: any) => TResult, ...func: Array<(a: any) => any>, f7: (a: Awaited) => R7, f6: (a: Awaited) => R6, f5: (a: Awaited) => R5, f4: (a: Awaited) => R4, f3: (a: Awaited) => R3, f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ] ): (a: TArg | Promise) => TResult; export function composeAsync( f7: (a: Awaited) => R7, f6: (a: Awaited) => R6, f5: (a: Awaited) => R5, f4: (a: Awaited) => R4, f3: (a: Awaited) => R3, f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R7; export function composeAsync( f7: (a: Awaited) => R7, f6: (a: Awaited) => R6, f5: (a: Awaited) => R5, f4: (a: Awaited) => R4, f3: (a: Awaited) => R3, f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R7; export function composeAsync( f6: (a: Awaited) => R6, f5: (a: Awaited) => R5, f4: (a: Awaited) => R4, f3: (a: Awaited) => R3, f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R6; export function composeAsync( f5: (a: Awaited) => R5, f4: (a: Awaited) => R4, f3: (a: Awaited) => R3, f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R5; export function composeAsync( f4: (a: Awaited) => R4, f3: (a: Awaited) => R3, f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R4; export function composeAsync( f3: (a: Awaited) => R3, f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R3; export function composeAsync( f2: (a: Awaited) => R2, f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R2; export function composeAsync( f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R1; export function composeWith( transformer: (fn: (...args: any[]) => any, intermediatResult: any) => any, fns: AtLeastOneFunctionsFlowFromRightToLeft, ): (...args: TArgs) => TResult; export function composeWith( transformer: (fn: (...args: any[]) => any, intermediatResult: any) => any, ): ( fns: AtLeastOneFunctionsFlowFromRightToLeft, ) => (...args: TArgs) => TResult; /** * It returns a new string or array, which is the result of merging `x` and `y`. */ export function concat(x: T[], y: T[]): T[]; export function concat(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(conditions: Array>): (...args: T) => R; /** * It returns `true` if all of `target` object properties are `R.equal` to `compareTo` object. */ export function contains(target: T, compareTo: U): boolean; export function contains(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(predicate: (x: T) => boolean, list: T[]): number; export function count(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(transformFn: (x: T) => any, list: T[]): Record; export function countBy(transformFn: (x: T) => any): (list: T[]) => Record; /** * 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(fn: (input: T) => U, ms: number, immediate?: boolean): (input: T) => void; export function debounce(fn: (input1: T, input2: Q) => U, ms: number, immediate?: boolean): (input1: T, input2: Q) => void; export function debounce(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(defaultValue: T, input: T | null | undefined): T; export function defaultTo(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(fn: (obj: T) => Ord, a: T, b: T): Ordering; export function descend(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(a: T[], b: T[]): T[]; export function difference(a: T[]): (b: T[]) => T[]; export function differenceWith( pred: (a: T1, b: T2) => boolean, list1: T1[], list2: T2[], ): T1[]; export function differenceWith( pred: (a: T1, b: T2) => boolean, ): (list1: T1[], list2: T2[]) => T1[]; export function differenceWith( 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(prop: K): (obj: string extends keyof U ? U : undefined extends U[K] ? U : never) => U; export function dissoc(prop: string extends keyof U ? K : undefined extends U[K] ? K : never, obj: U): U; export function dissocPath(path: Path, obj: any): T; export function dissocPath(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(howMany: number, input: T[]): T[]; export function drop(howMany: number, input: string): string; export function drop(howMany: number): { (input: T[]): T[]; (input: string): string; }; /** * It returns `howMany` items dropped from the end of list or string `input`. */ export function dropLast(howMany: number, input: T[]): T[]; export function dropLast(howMany: number, input: string): string; export function dropLast(howMany: number): { (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(predicate: (x: T) => boolean, iterable: T[]): T[]; export function dropLastWhile(predicate: (x: T) => boolean): (iterable: T[]) => T[]; /** * It removes any successive duplicates according to `R.equals`. */ export function dropRepeats(list: T[]): T[]; export function dropRepeatsBy(fn: (a: T) => U, list: T[]): T[]; export function dropRepeatsBy( fn: (a: T) => U ): (list: T[]) => T[]; export function dropRepeatsBy(fn: any): (list: T[]) => T[]; export function dropRepeatsWith(predicate: (x: T, y: T) => boolean, list: T[]): T[]; export function dropRepeatsWith(predicate: (x: T, y: T) => boolean): (list: T[]) => T[]; export function dropWhile(fn: Predicate, iterable: string): string; export function dropWhile(fn: Predicate): (iterable: string) => string; export function dropWhile(fn: Predicate, iterable: T[]): T[]; export function dropWhile(fn: Predicate): (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(firstPredicate: Predicate, secondPredicate: Predicate): Predicate; export function either(firstPredicate: Predicate): (secondPredicate: Predicate) => Predicate; export function either(firstPredicate: Pred): (secondPredicate: Pred) => Pred; export function empty(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(question: T, str: string): boolean; export function endsWith(question: T): (str: string) => boolean; export function endsWith(question: T[], list: T[]): boolean; export function endsWith(question: T[]): (list: T[]) => boolean; export function eqBy(fn: (a: T) => unknown, a: T, b: T): boolean; export function eqBy(fn: (a: T) => unknown, a: T): (b: T) => boolean; export function eqBy(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(prop: string, obj1: T, obj2: U): boolean; export function eqProps

(property: P): (list: Record[]) => T[]; export function pluck(property: number): (list: { [k: number]: T }[]) => T[]; /** * It adds element `x` at the beginning of `list`. */ export function prepend(xToPrepend: T, iterable: T[]): T[]; export function prepend(xToPrepend: T, iterable: IsFirstSubtypeOfSecond[]) : U[]; export function prepend(xToPrepend: T): (iterable: IsFirstSubtypeOfSecond[]) => U[]; export function prepend(xToPrepend: T): (iterable: T[]) => T[]; /** * It returns the next index of the list when the order is descending. * * If we have reached the beginning of the list, then it will return the last index of the list. */ export function prevIndex(index: number, list: any[]): number; /** * It returns an object created by applying each value of `rules` to `input` argument. */ export function produce( rules: ProduceRules, input: Input ): Output; export function produce( rules: ProduceRules ): ( input: Input ) => Output; /** * It returns an object created by applying each value of `rules` to `input` argument. * * `rules` input is an object with synchronous or asynchronous functions as values. * * The return value is wrapped in a promise, even if all `rules` are synchronous functions. */ export function produceAsync( rules: ProduceAsyncRules, input: Input ): Promise; export function produceAsync( rules: ProduceAsyncRules ): ( input: Input ) => Promise; export function product(list: number[]): number; /** * It returns the value of property `propToFind` in `obj`. * * If there is no such property, it returns `undefined`. */ export function prop<_, P extends keyof never, T>(p: P, value: T): Prop; export function prop(p: keyof never, value: unknown): V; export function prop<_, P extends keyof never>(p: P): (value: T) => Prop; export function prop(p: keyof never): (value: unknown) => V; /** * It returns true if `obj` has property `propToFind` and its value is equal to `valueToMatch`. */ export function propEq(valueToMatch: any, propToFind: K, obj: Record): boolean; export function propEq(valueToMatch: any, propToFind: K): (obj: Record) => boolean; export function propEq(valueToMatch: any): { (propToFind: K, obj: Record): boolean; (propToFind: K): (obj: Record) => boolean; }; /** * It returns `true` if `property` of `obj` is from `target` type. */ export function propIs(type: C, name: K, obj: any): obj is Record>; export function propIs(type: C, name: K, obj: any): obj is Record>; export function propIs(type: C, name: K): (obj: any) => obj is Record>; export function propIs(type: C, name: K): (obj: any) => obj is Record>; export function propIs(type: C): { (name: K, obj: any): obj is Record>; (name: K): (obj: any) => obj is Record>; }; /** * It returns either `defaultValue` or the value of `property` in `obj`. */ export function propOr(defaultValue: T, property: P, obj: Partial> | undefined): T; export function propOr(defaultValue: T, property: P): (obj: Partial> | undefined) => T; export function propOr(defaultValue: T): {

(property: P, obj: Partial> | undefined): T;

(property: P): (obj: Partial> | undefined) => T; } /** * It returns `true` if the object property satisfies a given predicate. */ export function propSatisfies(predicate: Predicate, property: string, obj: Record): boolean; export function propSatisfies(predicate: Predicate, property: string): (obj: Record) => boolean; /** * It takes list with properties `propsToPick` and returns a list with property values in `obj`. */ export function props

(propsToPick: P[], obj: Record): T[]; export function props

(propsToPick: P[]): (obj: Record) => T[]; export function props

(propsToPick: P[]): (obj: Record) => T[]; /** * It returns a random number between `min` inclusive and `max` inclusive. */ export function random(minInclusive: number, maxInclusive: number): number; /** * It returns list of numbers between `startInclusive` to `endExclusive` markers. */ export function range(startInclusive: number, endExclusive: number): number[]; export function range(startInclusive: number): (endExclusive: number) => number[]; export function reduce(reducer: (prev: TResult, current: T, i: number) => TResult, initialValue: TResult, list: T[]): TResult; export function reduce(reducer: (prev: TResult, current: T) => TResult, initialValue: TResult, list: T[]): TResult; export function reduce(reducer: (prev: TResult, current: T, i: number) => TResult): (initialValue: TResult, list: T[]) => TResult; export function reduce(reducer: (prev: TResult, current: T, i: number) => TResult, initialValue: TResult): (list: T[]) => TResult; export function reduceBy( valueFn: (acc: TResult, elem: T) => TResult, ): (a: TResult, b: (elem: T) => string, c: T[]) => { [index: string]: TResult } export function reduceBy( valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, ): (a: (elem: T) => string, b: T[]) => { [index: string]: TResult } export function reduceBy( valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string, ): (list: T[]) => { [index: string]: TResult }; export function reduceBy( valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string, list: T[], ): { [index: string]: TResult }; /** * It has the opposite effect of `R.filter`. */ export function reject(predicate: Predicate, list: T[]): T[]; export function reject(predicate: Predicate): (list: T[]) => T[]; export function reject(predicate: Predicate, obj: Dictionary): Dictionary; export function reject(predicate: Predicate): (obj: Dictionary) => Dictionary; /** * Same as `R.reject`, but it passes index/property as second argument to the predicate, when looping over arrays/objects. */ export function rejectIndexed(predicate: IndexedPredicate): (x: T[]) => T[]; export function rejectIndexed(predicate: IndexedPredicate, x: T[]): T[]; export function rejectIndexed(predicate: ObjectPredicate): (x: Dictionary) => Dictionary; export function rejectIndexed(predicate: ObjectPredicate, x: Dictionary): Dictionary; /** * It will remove all `toRemove` entries from `text` sequentially. * * `toRemove` argument can be either a list of strings/regular expressions or a single string/regular expression. */ export function remove( toRemove: string | RegExp | (string | RegExp)[], text: string ): string; export function remove( toRemove: string | RegExp | (string | RegExp)[] ): (text: string) => string; /** * It returns a copy of `list` input with removed `index`. */ export function removeIndex(index: number, list: T[]): T[]; export function removeIndex(index: number): (list: T[]) => T[]; /** * If property `prop` of `rules` is also a property in `input`, then rename `input` property to `rules[prop]`. */ export function renameProps(rules: object, input: object): object; export function renameProps(rules: object): (input: object) => object; export function renameProps(rules: object, input: object): Output; export function renameProps(rules: object): (input: object) => Output; export function repeat(x: T): (timesToRepeat: number) => T[]; export function repeat(x: T, timesToRepeat: number): T[]; /** * It replaces `strOrRegex` found in `str` with `replacer`. */ export function replace(strOrRegex: RegExp | string, replacer: RegExpReplacer, str: string): string; export function replace(strOrRegex: RegExp | string, replacer: RegExpReplacer): (str: string) => string; export function replace(strOrRegex: RegExp | string): (replacer: RegExpReplacer) => (str: string) => string; /** * Same as `R.replace` but it accepts array of string and regular expressions instead of a single value. */ export function replaceAll(patterns: (RegExp | string)[], replacer: string, input: string): string; export function replaceAll(patterns: (RegExp | string)[], replacer: string): (input: string) => string; export function replaceAll(patterns: (RegExp | string)[]): (replacer: string) => (input: string) => string; export function reset(): void; /** * It returns a reversed copy of list or string `input`. */ export function reverse(input: T[]): T[]; export function reverse(input: string): string; /** * It returns a copied **Object** or **Array** with modified `lens` focus set to `replacer` value. */ export function set(lens: Lens): { (a: A): (obj: S) => S (a: A, obj: S): S }; export function set(lens: Lens, a: A): (obj: S) => S; export function set(lens: Lens, a: A, obj: S): S; export function setter(keyOrObject: string | object, value?: any): void; /** * It returns a randomized copy of array. */ export function shuffle(list: T[]): T[]; export function slice(from: number, to: number, input: string): string; export function slice(from: number, to: number, input: T[]): T[]; export function slice(from: number, to: number): { (input: string): string; (input: T[]): T[]; }; export function slice(from: number): { (to: number, input: string): string; (to: number, input: T[]): T[]; }; /** * It returns copy of `list` sorted by `sortFn` function, where `sortFn` needs to return only `-1`, `0` or `1`. */ export function sort(sortFn: (a: T, b: T) => number, list: T[]): T[]; export function sort(sortFn: (a: T, b: T) => number): (list: T[]) => T[]; /** * It returns copy of `list` sorted by `sortFn` function, where `sortFn` function returns a value to compare, i.e. it doesn't need to return only `-1`, `0` or `1`. */ export function sortBy(sortFn: (a: T) => Ord, list: T[]): T[]; export function sortBy(sortFn: (a: T) => Ord): (list: T[]) => T[]; export function sortBy(sortFn: (a: any) => Ord): (list: T[]) => T[]; /** * It returns copy of `list` sorted by `sortPath` value. * * As `sortPath` is passed to `R.path`, it can be either a string or an array of strings. */ export function sortByPath(sortPath: Path, list: T[]): T[]; export function sortByPath(sortPath: Path): (list: T[]) => T[]; /** * It returns sorted copy of `list` of objects. * * Sorting is done using a list of strings, each representing a path. Two members `a` and `b` from `list` can be sorted if both return a value for a given path. If the value is equal, then the next member of `sortPaths`(if there is such) will be used in order to find difference between `a` and `b`. */ export function sortByProps(sortPaths: string[], list: T[]): T[]; export function sortByProps(sortPaths: string[]): (list: T[]) => T[]; /** * It returns a sorted version of `input` object. */ export function sortObject(predicate: SortObjectPredicate, input: { [key: string]: T }): { [keyOutput: string]: T }; export function sortObject(predicate: SortObjectPredicate): (input: { [key: string]: T }) => { [keyOutput: string]: T }; export function sortWith(fns: Array<(a: T, b: T) => number>): (list: T[]) => T[]; export function sortWith(fns: Array<(a: T, b: T) => number>, list: T[]): T[]; /** * Curried version of `String.prototype.split` */ export function split(separator: string | RegExp): (str: string) => string[]; export function split(separator: string | RegExp, str: string): string[]; /** * It splits string or array at a given index. */ export function splitAt(index: number, input: T[]): [T[], T[]]; export function splitAt(index: number, input: string): [string, string]; export function splitAt(index: number): { (input: T[]): [T[], T[]]; (input: string): [string, string]; }; /** * It splits `input` into slices of `sliceLength`. */ export function splitEvery(sliceLength: number, input: T[]): (T[])[]; export function splitEvery(sliceLength: number, input: string): string[]; export function splitEvery(sliceLength: number): { (input: string): string[]; (input: T[]): (T[])[]; }; /** * It splits `list` to two arrays according to a `predicate` function. * * The first array contains all members of `list` before `predicate` returns `true`. */ export function splitWhen(predicate: Predicate, list: U[]): (U[])[]; export function splitWhen(predicate: Predicate): (list: U[]) => (U[])[]; /** * When iterable is a string, then it behaves as `String.prototype.startsWith`. * When iterable is a list, then it uses R.equals to determine if the target list starts in the same way as the given target. */ export function startsWith(question: T, input: string): boolean; export function startsWith(question: T): (input: string) => boolean; export function startsWith(question: T[], input: T[]): boolean; export function startsWith(question: T[]): (input: T[]) => boolean; /** * Curried version of `x - y` */ export function subtract(x: number, y: number): number; export function subtract(x: number): (y: number) => number; export function sum(list: number[]): number; export function swap(indexA: number, indexB: number): (list: T[]) => T[]; export function swap(indexA: number, indexB: number, list: T[]): T[]; /** * Edited fork of [Switchem](https://github.com/planttheidea/switchem) library. * * The method return a value if the matched option is a value. * * If the matched option is a function, then `R.switcher` returns a function which expects input. Tests of the method explain it better than this short description. * * `R.equals` is used to determine equality. */ export function switcher(valueToMatch: any): Switchem; /** * It returns a merged list of `x` and `y` with all equal elements removed. * * `R.equals` is used to determine equality. */ export function symmetricDifference(x: T[], y: T[]): T[]; export function symmetricDifference(x: T[]): (y: T[]) => T[]; /** * It returns all but the first element of `input`. */ export function tail(input: T): T extends [any, ...infer U] ? U : [...T]; export function tail(input: string): string; /** * It returns the first `howMany` elements of `input`. */ export function take(howMany: number, input: T): T extends string ? string : T; export function take(howMany: number) : (input: T) => T extends string ? string : T; /** * It returns the last `howMany` elements of `input`. */ export function takeLast(howMany: number, input: T): T extends string ? string : T; export function takeLast(howMany: number) : (input: T) => T extends string ? string : T; export function takeLastWhile(predicate: (x: string) => boolean, input: string): string; export function takeLastWhile(predicate: (x: string) => boolean): (input: string) => string; export function takeLastWhile(predicate: (x: T) => boolean, input: T[]): T[]; export function takeLastWhile(predicate: (x: T) => boolean): (input: T[]) => T[]; export function takeUntil(predicate: (x: T) => boolean, list: T[]): T[]; export function takeUntil(predicate: (x: T) => boolean): (list: T[]) => T[]; export function takeWhile(fn: Predicate, iterable: string): string; export function takeWhile(fn: Predicate): (iterable: string) => string; export function takeWhile(fn: Predicate, iterable: T[]): T[]; export function takeWhile(fn: Predicate): (iterable: T[]) => T[]; /** * It applies function `fn` to input `x` and returns `x`. * * One use case is debugging in the middle of `R.compose`. */ export function tap(fn: (x: T) => void, input: T): T; export function tap(fn: (x: T) => void): (input: T) => T; /** * Asynchronous version of `R.tap`. */ export function tapAsync(fn: Func | Promise, input: T): T; export function tapAsync(fn: Func | Promise): (input: T) => T; /** * It determines whether `str` matches `regExpression`. */ export function test(regExpression: RegExp): (str: string) => boolean; export function test(regExpression: RegExp, str: string): boolean; export function throttle(fn: () => T, ms: number): () => T; export function throttle(fn: (input: T) => U, ms: number): (input: T) => U; export function throttle(fn: (input1: T, input2: Q) => U, ms: number): (input1: T, input2: Q) => U; export function throttle(fn: (input1: T, input2: Q, input3: Z) => U, ms: number): (input1: T, input2: Q, input3: Z) => U; /** * It returns the result of applying function `fn` over members of range array. * * The range array includes numbers between `0` and `howMany`(exclusive). */ export function times(fn: (i: number) => T, howMany: number): T[]; export function times(fn: (i: number) => T): (howMany: number) => T[]; export function toDecimal(num: number, charsAfterDecimalPoint?: number): number; export function toLower(str: S): Lowercase; export function toLower(str: string): string; /** * It transforms an object to a list. */ export function toPairs>(obj: O): Array<{ [key in K]: [`${key}`, O[key]] }[K]>; export function toPairs(obj: Record): Array<[string, S]>; export function toString(x: unknown): string; export function toUpper(str: S): Uppercase; export function toUpper(str: string): string; export function transpose(list: (T[])[]): (T[])[]; export function trim(str: string): string; /** * It returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result. Note that `fn` can be value or asynchronous/synchronous function(unlike `Ramda` where fallback can only be a synchronous function). */ export function tryCatch( fn: (input: T) => U, fallback: U ): (input: T) => U; export function tryCatch( fn: (input: T) => U, fallback: (input: T) => U ): (input: T) => U; export function tryCatch( fn: (input: any) => Promise, fallback: T ): (input: any) => Promise; export function tryCatch( fn: (input: any) => Promise, fallback: (input: any) => Promise, ): (input: any) => Promise; /** * It returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result. */ export function tryCatchAsync( fn: (input: any) => Promise, fallback: T ): (input: any) => Promise; export function tryCatchAsync( fn: (input: any) => Promise, fallback: (input: any) => Promise, ): (input: any) => Promise; export const DELAY: 'RAMBDAX_DELAY'; /** * It accepts any input and it returns its type. */ export function type(x: any): RambdaTypes; /** * It calls a function `fn` with the list of values of the returned function. * * `R.unapply` is the opposite of `R.apply` method. */ export function unapply(fn: (args: any[]) => T): (...args: any[]) => T; /** * It takes two lists and return a new list containing a merger of both list with removed duplicates. * * `R.equals` is used to compare for duplication. */ export function union(x: T[], y: T[]): T[]; export function union(x: T[]): (y: T[]) => T[]; /** * It returns a new array containing only one copy of each element of `list`. * * `R.equals` is used to determine equality. */ export function uniq(list: T[]): T[]; /** * It applies uniqueness to input list based on function that defines what to be used for comparison between elements. * * `R.equals` is used to determine equality. */ export function uniqBy(fn: (a: T) => U, list: T[]): T[]; export function uniqBy(fn: (a: T) => U): (list: T[]) => T[]; /** * It returns a new array containing only one copy of each element in `list` according to `predicate` function. * * This predicate should return true, if two elements are equal. */ export function uniqWith(predicate: (x: T, y: T) => boolean, list: T[]): T[]; export function uniqWith(predicate: (x: T, y: T) => boolean): (list: T[]) => T[]; /** * The method returns function that will be called with argument `input`. * * If `predicate(input)` returns `false`, then the end result will be the outcome of `whenFalse(input)`. * * In the other case, the final output will be the `input` itself. */ export function unless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => U, x: T): T | U; export function unless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => U): (x: T) => T | U; export function unless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T, x: T): T; export function unless(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T): (x: T) => T; export function unnest(list: unknown[]): unknown[]; export function unnest(list: unknown[]): T; export function unwind(prop: keyof T, obj: T): U[]; export function unwind(prop: keyof T): (obj: T) => U[]; /** * It returns a copy of `list` with updated element at `index` with `newValue`. */ export function update(index: number, newValue: T, list: T[]): T[]; export function update(index: number, newValue: T): (list: T[]) => T[]; /** * Very similar to `R.assocPath` but it applies list of updates instead of only a single update. * * It returns a copy of `obj` input with changed properties according to `rules` input. * * Each instance of `rules` is a tuple of object path and the new value for this path. If such object path does not exist, then such object path is created. * * As it uses `R.path` underneath, object path can be either string or array of strings(in Typescript object path can be only a string). */ export function updateObject(rules: ([string, any])[], input: object): Output; export function updateObject(rules: ([string, any])[]): (input: object) => Output; /** * With correct input, this is nothing more than `Object.values(Record)`. If `obj` is not an object, then it returns an empty array. */ export function values(obj: T): T[K][]; /** * It returns the value of `lens` focus over `target` object. */ export function view(lens: Lens): (obj: S) => A; export function view(lens: Lens, obj: S): A; /** * A combination between `R.defaultTo` and `R.view. */ export function viewOr(fallback: Output, lens: Lens, input: Input): Output; export function viewOr(fallback: Output, lens: Lens): (input: Input) => Output; /** * It provides `Golang`-like interface for handling promises. */ export function wait(fn: Promise): Promise<[T, Error|undefined]>; export function wait(fn: (x: any) => Promise): Promise<[T, Error|undefined]>; /** * It returns `true`, if `condition` returns `true` within `howLong` milliseconds time period. * * The method accepts an optional third argument `loops`(default to 10), which is the number of times `waitForTrueCondition` will be evaluated for `howLong` period. Once this function returns a value different from `false`, this value will be the final result. * * Otherwise, `R.waitFor` will return `false`. */ export function waitFor( waitForTrueCondition: () => boolean, howLong: number, loops?: number ): () => Promise; export function waitFor( waitForTrueCondition: () => Promise, howLong: number, loops?: number ): () => Promise; export function waitFor( waitForTrueCondition: (input: T) => Promise, howLong: number, loops?: number ): (input: T) => Promise; export function waitFor( waitForTrueCondition: (input: T) => boolean, howLong: number, loops?: number ): (input: T) => Promise; /** * It pass `input` to `predicate` function and if the result is `true`, it will return the result of `whenTrueFn(input)`. * If the `predicate` returns `false`, then it will simply return `input`. */ export function when(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U, input: T): T | U; export function when(predicate: (x: T) => boolean, whenTrueFn: (a: T) => U): (input: T) => T | U; export function when(predicate: (x: T) => boolean): ((whenTrueFn: (a: T) => U) => (input: T) => T | U); /** * It returns `true` if all each property in `conditions` returns `true` when applied to corresponding property in `input` object. */ export function where(conditions: T, input: U): boolean; export function where(conditions: T): (input: U) => boolean; export function where(conditions: ObjFunc2, input: U): boolean; export function where(conditions: ObjFunc2): (input: U) => boolean; /** * Same as `R.where`, but it will return `true` if at least one condition check returns `true`. */ export function whereAny(conditions: T, input: U): boolean; export function whereAny(conditions: T): (input: U) => boolean; export function whereAny(conditions: ObjFunc2, input: U): boolean; export function whereAny(conditions: ObjFunc2): (input: U) => boolean; /** * It will return `true` if all of `input` object fully or partially include `rule` object. * * `R.equals` is used to determine equality. */ export function whereEq(condition: T, input: U): boolean; export function whereEq(condition: T): (input: U) => boolean; /** * It will return a new array, based on all members of `source` list that are not part of `matchAgainst` list. * * `R.equals` is used to determine equality. */ export function without(matchAgainst: T[], source: T[]): T[]; export function without(matchAgainst: T[]): (source: T[]) => T[]; /** * Logical XNOR */ export function xnor(x: boolean, y: boolean): boolean; export function xnor(y: boolean): (y: boolean) => boolean; /** * Logical XOR */ export function xor(x: boolean, y: boolean): boolean; export function xor(y: boolean): (y: boolean) => boolean; /** * It will return a new array containing tuples of equally positions items from both `x` and `y` lists. * * The returned list will be truncated to match the length of the shortest supplied list. */ export function zip(x: K[], y: V[]): KeyValuePair[]; export function zip(x: K[]): (y: V[]) => KeyValuePair[]; /** * It will return a new object with keys of `keys` array and values of `values` array. */ export function zipObj(keys: K[], values: T[]): { [P in K]: T }; export function zipObj(keys: K[]): (values: T[]) => { [P in K]: T }; export function zipObj(keys: K[], values: T[]): { [P in K]: T }; export function zipObj(keys: K[]): (values: T[]) => { [P in K]: T }; export function zipWith(fn: (x: T, y: U) => TResult, list1: T[], list2: U[]): TResult[]; export function zipWith(fn: (x: T, y: U) => TResult, list1: T[]): (list2: U[]) => TResult[]; export function zipWith(fn: (x: T, y: U) => TResult): (list1: T[], list2: U[]) => TResult[];

(prop: P): (obj1: Record, obj2: Record) => boolean; export function eqProps(prop: string, obj1: T): (obj2: U) => boolean; /** * It deeply compares `x` and `y` and returns `true` if they are equal. */ export function equals(x: T, y: T): boolean; export function equals(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(rules: ((x: T) => U)[], list: T[]): U[]; export function evolve(rules: ((x: T) => U)[]) : (list: T[]) => U[]; export function evolve>(rules: E, obj: V): Evolve; export function evolve(rules: E): >(obj: V) => Evolve; /** * 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(valueToFind: T, input: T[]): boolean; export function excludes(valueToFind: T): (input: T[]) => boolean; /** * It filters list or object `input` using a `predicate` function. */ export function filter(predicate: Predicate): (input: T[]) => T[]; export function filter(predicate: Predicate, input: T[]): T[]; export function filter(predicate: ObjectPredicate): (x: Dictionary) => Dictionary; export function filter(predicate: ObjectPredicate, x: Dictionary): Dictionary; export function filterArray(predicate: Predicate): (input: T[]) => T[]; export function filterArray(predicate: Predicate, input: T[]): T[]; /** * Asynchronous version of `R.filter` */ export function filterAsync(fn: AsyncPredicate, list: T[]): Promise; export function filterAsync(fn: AsyncPredicateIndexed, list: T[]): Promise; export function filterAsync(fn: AsyncPredicate) : ( list: T[]) => Promise; export function filterAsync(fn: AsyncPredicateIndexed) : ( list: T[]) => Promise; /** * Same as `R.filter`, but it passes index/property as second argument to the predicate, when looping over arrays/objects. */ export function filterIndexed(predicate: IndexedPredicate): (x: T[]) => T[]; export function filterIndexed(predicate: IndexedPredicate, x: T[]): T[]; export function filterIndexed(predicate: ObjectPredicate): (x: Dictionary) => Dictionary; export function filterIndexed(predicate: ObjectPredicate, x: Dictionary): Dictionary; export function filterObject(predicate: ObjectPredicate): (x: Dictionary) => Dictionary; export function filterObject(predicate: ObjectPredicate, x: Dictionary): Dictionary; /** * It returns the first element of `list` that satisfy the `predicate`. * * If there is no such element, it returns `undefined`. */ export function find(predicate: (x: T) => boolean, list: T[]): T | undefined; export function find(predicate: (x: T) => boolean): (list: T[]) => T | undefined; /** * Asynchronous version of `R.find`. */ export function findAsync(predicate: (x: T) => Promise, list: T[]): T | undefined; export function findAsync(predicate: (x: T) => Promise): (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(predicate: (x: T) => boolean, list: T[]): number; export function findIndex(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(fn: (x: T) => boolean, list: T[]): T | undefined; export function findLast(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(predicate: (x: T) => boolean, list: T[]): number; export function findLastIndex(predicate: (x: T) => boolean): (list: T[]) => number; /** * It deeply flattens an array. */ export function flatten(list: any[]): T[]; /** * It returns function which calls `fn` with exchanged first and second argument. */ export function flip(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(fn: Iterator, list: T[]): T[]; export function forEach(fn: Iterator): (list: T[]) => T[]; export function forEach(fn: ObjectIterator, list: Dictionary): Dictionary; export function forEach(fn: ObjectIterator): (list: Dictionary) => Dictionary; export function forEachIndexed(fn: IndexedIterator, list: T[]): T[]; export function forEachIndexed(fn: IndexedIterator): (list: T[]) => T[]; export function forEachIndexed(fn: ObjectIterator, list: Dictionary): Dictionary; export function forEachIndexed(fn: ObjectIterator): (list: Dictionary) => Dictionary; export function forEachObjIndexed(fn: (value: T[keyof T], key: keyof T, obj: T) => void, obj: T): T; export function forEachObjIndexed(fn: (value: T[keyof T], key: keyof T, obj: T) => void): (obj: T) => T; /** * It transforms a `listOfPairs` to an object. */ export function fromPairs(listOfPairs: ([number, V])[]): { [index: number]: V }; export function fromPairs(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(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(fn: (a: T) => K): (list: T[]) => Partial>; export function groupBy(fn: (a: T) => K, list: T[]): Partial>; /** * It returns separated version of list or string `input`, where separation is done with equality `compareFn` function. */ export function groupWith(compareFn: (x: T, y: T) => boolean): (input: T[]) => (T[])[]; export function groupWith(compareFn: (x: T, y: T) => boolean, input: T[]): (T[])[]; export function groupWith(compareFn: (x: T, y: T) => boolean, input: string): string[]; export function gt(x: T, y: U): boolean; export function gt(x: T): (y: U) => boolean; export function gte(x: T, y: U): boolean; export function gte(x: T): (y: U) => boolean; /** * It returns `true` if `obj` has property `prop`. */ export function has(prop: string, obj: T): boolean; export function has(prop: string): (obj: T) => boolean; export function hasIn(searchProperty: string): (obj: T) => boolean; export function hasIn(searchProperty: string, obj: T): boolean; /** * It will return true, if `input` object has truthy `path`(calculated with `R.path`). */ export function hasPath( path: string | string[], input: object ): boolean; export function hasPath( 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(list: never[]): undefined; export function head(array: T): FirstArrayElement export function head(array: T): FirstArrayElement /** * It returns `true` if its arguments `a` and `b` are identical. * * Otherwise, it returns `false`. */ export function identical(x: T, y: T): boolean; export function identical(x: T): (y: T) => boolean; /** * It just passes back the supplied `input` argument. */ export function identity(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( pred: (a: T) => a is TFiltered, onTrue: (a: TFiltered) => TOnTrueResult, onFalse: (a: Exclude) => TOnFalseResult, ): (a: T) => TOnTrueResult | TOnFalseResult; export function ifElse(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( condition: (x: T) => Promise, onTrue: (x: T) => U, onFalse: (x: T) => U, ): (x: T) => Promise; export function ifElseAsync( condition: (x: T) => boolean, onTrue: (x: T) => Promise, onFalse: (x: T) => Promise, ): (x: T) => Promise; export function ifElseAsync( condition: (x: T) => Promise, onTrue: (x: T) => Promise, onFalse: (x: T) => Promise, ): (x: T) => Promise; export function ifElseAsync( condition: (x: T, y: K) => Promise, onTrue: (x: T, y: K) => U, onFalse: (x: T, y: K) => U, ): (x: T, y: K) => Promise; export function ifElseAsync( condition: (x: T, y: K) => boolean, onTrue: (x: T, y: K) => Promise, onFalse: (x: T, y: K) => Promise, ): (x: T, y: K) => Promise; export function ifElseAsync( condition: (x: T, y: K) => Promise, onTrue: (x: T, y: K) => Promise, onFalse: (x: T, y: K) => Promise, ): (x: T, y: K) => Promise; /** * 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(valueToFind: T, input: string): boolean; export function includes(valueToFind: T): (input: string) => boolean; export function includes(valueToFind: T, input: T[]): boolean; export function includes(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(condition: (key: T) => K, list: T[]): { [key in K]: T }; export function indexBy(condition: (key: T) => K, list: T[]): { [key in NonNullable]?: T }; export function indexBy(condition: (key: T) => K): (list: T[]) => { [key in K]: T }; export function indexBy(condition: (key: T) => K | undefined): (list: T[]) => { [key in NonNullable]?: T }; export function indexBy(condition: string, list: T[]): { [key: string]: T }; export function indexBy(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(valueToFind: T, list: T[]): number; export function indexOf(valueToFind: T): (list: T[]) => number; /** * It returns all but the last element of list or string `input`. */ export function init(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( pred: (a: T1, b: T2) => boolean, ): (list1: T1[], list2: T2[]) => T1[]; export function innerJoin( pred: (a: T1, b: T2) => boolean, list1: T1[], ): (list2: T2[]) => T1[]; export function innerJoin(pred: (a: T1, b: T2) => boolean, list1: T1[], list2: T2[]): T1[]; export function insert(index: number): (itemToInsert: T, list: T[]) => T[]; export function insert(index: number, itemToInsert: T): (list: T[]) => T[]; export function insert(index: number, itemToInsert: T, list: T[]): T[]; export function insertAll(index: number): (itemsToInsert: T[], list: T[]) => T[]; export function insertAll(index: number, itemsToInsert: T[]): (list: T[]) => T[]; export function insertAll(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(listA: T[], listB: T[]): T[]; export function intersection(listA: T[]): (listB: T[]) => T[]; /** * It adds a `separator` between members of `list`. */ export function intersperse(separator: T, list: T[]): T[]; export function intersperse(separator: T): (list: T[]) => T[]; /** * It returns `true` if `x` is instance of `targetPrototype`. */ export function is any>(targetPrototype: C, val: any): val is ReturnType; export function is any>(targetPrototype: C, val: any): val is InstanceType; export function is any>(targetPrototype: C): (val: any) => val is ReturnType; export function is any>(targetPrototype: C): (val: any) => val is InstanceType; /** * It returns `true` if `x` is `empty`. */ export function isEmpty(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(value: T[]): value is NonEmptyArray; export function isNotEmpty(value: readonly T[]): value is ReadonlyNonEmptyArray; export function isNotEmpty(value: any): boolean; export function isNotNil(value: T): value is NonNullable; 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; /** * It returns a string of all `list` instances joined with a `glue`. */ export function join(glue: string, list: T[]): string; export function join(glue: string): (list: T[]) => string; /** * It applies list of function to a list of inputs. */ export function juxt(fns: [(...a: A) => R1]): (...a: A) => [R1]; export function juxt(fns: [(...a: A) => R1, (...a: A) => R2]): (...a: A) => [R1, R2]; export function juxt(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3]): (...a: A) => [R1, R2, R3]; export function juxt(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3, (...a: A) => R4]): (...a: A) => [R1, R2, R3, R4]; export function juxt(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(fns: Array<(...args: A) => U>): (...args: A) => U[]; /** * It applies `Object.keys` over `x` and returns its keys. */ export function keys(x: T): (keyof T & string)[]; export function keys(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(array: T): LastArrayElement; export function last(array: T): LastArrayElement; 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(target: T, list: T[]): number; export function lastIndexOf(target: T): (list: T[]) => number; /** * It returns the `length` property of list or string `input`. */ export function length(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(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens; /** * 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(n: number): Lens; export function lensIndex(n: N): Lens; /** * It returns a lens that focuses on specified `path`. */ export function lensPath(path: [K0]): Lens; export function lensPath( path: [K0, K1], ): Lens; export function lensPath< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1] >(path: [K0, K1, K2]): Lens; export function lensPath< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1], K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2] >(path: [K0, K1, K2, K3]): Lens; export function lensPath< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1], K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2], K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3] >(path: [K0, K1, K2, K3, K4]): Lens; export function lensPath< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1], K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2], K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3], K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4] >(path: [K0, K1, K2, K3, K4, K5]): Lens; export function lensPath(path: Path): Lens; /** * It returns a lens that focuses on specified property `prop`. */ export function lensProp(prop: K): Lens; /** * It returns `true` if data structure focused by the given lens satisfies the predicate. */ export function lensSatisfies(predicate: (x: PredicateInput) => boolean, lens: Lens, input: Input): boolean; export function lensSatisfies(predicate: (x: PredicateInput) => boolean, lens: Lens): (input: Input) => boolean; export function lensSatisfies(predicate: (x: T) => boolean, lens: Lens, input: T[]): boolean; export function lensSatisfies(predicate: (x: T) => boolean, lens: Lens): (input: T[]) => boolean; export function lt(x: T, y: U): boolean; export function lt(x: T): (y: U) => boolean; export function lte(x: T, y: U): boolean; export function lte(x: T): (y: U) => boolean; /** * It returns the result of looping through `iterable` with `fn`. * * It works with both array and object. */ export function map(fn: ObjectIterator, iterable: Dictionary): Dictionary; export function map(fn: Iterator, iterable: T[]): U[]; export function map(fn: Iterator): (iterable: T[]) => U[]; export function map(fn: ObjectIterator): (iterable: Dictionary) => Dictionary; export function map(fn: Iterator): (iterable: T[]) => T[]; export function map(fn: Iterator, iterable: T[]): T[]; export function mapArray(fn: Iterator, iterable: T[]): T[]; export function mapArray(fn: Iterator, iterable: T[]): U[]; export function mapArray(fn: Iterator): (iterable: T[]) => U[]; export function mapArray(fn: Iterator): (iterable: T[]) => T[]; /** * Sequential asynchronous mapping with `fn` over members of `list`. */ export function mapAsync(fn: AsyncIterable, list: T[]): Promise; export function mapAsync(fn: AsyncIterableIndexed, list: T[]): Promise; export function mapAsync(fn: AsyncIterable) : ( list: T[]) => Promise; export function mapAsync(fn: AsyncIterableIndexed) : ( list: T[]) => Promise; /** * Same as `R.map`, but it passes index as second argument to the iterator, when looping over arrays. */ export function mapIndexed(fn: ObjectIterator, iterable: Dictionary): Dictionary; export function mapIndexed(fn: IndexedIterator, iterable: T[]): U[]; export function mapIndexed(fn: IndexedIterator): (iterable: T[]) => U[]; export function mapIndexed(fn: ObjectIterator): (iterable: Dictionary) => Dictionary; export function mapIndexed(fn: IndexedIterator): (iterable: T[]) => T[]; export function mapIndexed(fn: IndexedIterator, iterable: T[]): T[]; /** * It takes an object and returns a new object with changed keys according to `changeKeyFn` function. */ export function mapKeys(changeKeyFn: (x: string) => string, obj: { [key: string]: T}): U; export function mapKeys(changeKeyFn: (x: string) => string): (obj: { [key: string]: T}) => U; /** * It works the same way as `R.map` does for objects. It is added as Ramda also has this method. */ export function mapObjIndexed(fn: ObjectIterator, iterable: Dictionary): Dictionary; export function mapObjIndexed(fn: ObjectIterator, iterable: Dictionary): Dictionary; export function mapObjIndexed(fn: ObjectIterator): (iterable: Dictionary) => Dictionary; export function mapObjIndexed(fn: ObjectIterator): (iterable: Dictionary) => Dictionary; export function mapObject(fn: ObjectIterator, iterable: Dictionary): Dictionary; export function mapObject(fn: ObjectIterator, iterable: Dictionary): Dictionary; export function mapObject(fn: ObjectIterator): (iterable: Dictionary) => Dictionary; export function mapObject(fn: ObjectIterator): (iterable: Dictionary) => Dictionary; /** * Parallel asynchronous mapping with `fn` over members of `list`. */ export function mapParallelAsync(fn: AsyncIterable, list: T[]): Promise; export function mapParallelAsync(fn: AsyncIterableIndexed, list: T[]): Promise; export function mapParallelAsync(fn: AsyncIterable) : ( list: T[]) => Promise; export function mapParallelAsync(fn: AsyncIterableIndexed) : ( list: T[]) => Promise; /** * It is similar to `R.mapParallelAsync` in that it uses `Promise.all`, but not over the whole list, rather than with only slice from `list` with length `limit`. */ export function mapParallelAsyncWithLimit(fn: AsyncIterable, limit: number, list: T[]): Promise; export function mapParallelAsyncWithLimit(fn: AsyncIterable, limit: number): (list: T[]) => Promise; export function mapParallelAsyncWithLimit(fn: AsyncIterableIndexed, limit: number, list: T[]): Promise; export function mapParallelAsyncWithLimit(fn: AsyncIterableIndexed, limit: number): (list: T[]) => Promise; /** * This method allows to generate an object from a list using input function `fn`. * * This function must return either an object or `false` for every member of `list` input. * * If `false` is returned, then this element of `list` will be skipped in the calculation of the result. * * All of returned objects will be merged to generate the final result. */ export function mapToObject(fn: (input: T) => U|false, list: readonly T[]): U; export function mapToObject(fn: (input: T) => U|false): (list: readonly T[]) => U; export function mapToObject(fn: (input: T) => object|false, list: T[]): U; export function mapToObject(fn: (input: T) => object|false): (list: T[]) => U; /** * Asynchronous version of `R.mapToObject` */ export function mapToObjectAsync(fn: (input: T) => Promise, list: readonly T[]): Promise; export function mapToObjectAsync(fn: (input: T) => Promise): (list: readonly T[]) => Promise; export function mapToObjectAsync(fn: (input: T) => object|false, list: T[]): U; export function mapToObjectAsync(fn: (input: T) => object|false): (list: T[]) => U; export function mapcat(x: T): T; /** * Curried version of `String.prototype.match` which returns empty array, when there is no match. */ export function match(regExpression: RegExp, str: string): string[]; export function match(regExpression: RegExp): (str: string) => string[]; /** * `R.mathMod` behaves like the modulo operator should mathematically, unlike the `%` operator (and by extension, `R.modulo`). So while `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`. */ export function mathMod(x: number, y: number): number; export function mathMod(x: number): (y: number) => number; /** * It returns the greater value between `x` and `y`. */ export function max(x: T, y: T): T; export function max(x: T): (y: T) => T; /** * It returns the greater value between `x` and `y` according to `compareFn` function. */ export function maxBy(compareFn: (input: T) => Ord, x: T, y: T): T; export function maxBy(compareFn: (input: T) => Ord, x: T): (y: T) => T; export function maxBy(compareFn: (input: T) => Ord): (x: T) => (y: T) => T; /** * It acts as ternary operator and it is helpful when we have nested ternaries. * * All of the inputs can be either direct values or anonymous functions. This is helpful if we don't want to evaluate certain paths as we can wrap this logic in a function. */ export function maybe(ifRule: boolean, whenIf: T | Func, whenElse: T | Func): T; export function maybe(ifRule: VoidInputFunc, whenIf: T | Func, whenElse: T | Func): T; /** * It returns the mean value of `list` input. */ export function mean(list: number[]): number; /** * It returns the median value of `list` input. */ export function median(list: number[]): number; /** * When `fn` is called for a second time with the same input, then the cache result is returned instead of calling again `fn`. */ export function memoize(fn: (...inputs: K) => T): (...inputs: K) => T; /** * Creates a new function that, when invoked, caches the result of calling fn for a given argument set and returns the result. */ export function memoizeWith(keyGen: any, fn: (...inputs: K) => T): (...inputs: K) => T; /** * Same as `R.mergeRight`. */ export function merge(target: A, newProps: B): A & B export function merge(target: any): (newProps: any) => Output; /** * It merges all objects of `list` array sequentially and returns the result. */ export function mergeAll(list: object[]): T; export function mergeAll(list: object[]): object; export function mergeDeepLeft(newProps: object, target: object): Output; export function mergeDeepLeft(newProps: object): (target: object) => Output; // RAMBDAX_MARKER_START /** * Creates a new object with the own properties of the first object merged with the own properties of the second object. If a key exists in both objects: * * - and both values are objects, the two values will be recursively merged * - otherwise the value from the second object will be used. */ export function mergeDeepRight(target: object, newProps: object): Output; export function mergeDeepRight(target: object): (newProps: object) => Output; /** * Same as `R.merge`, but in opposite direction. */ export function mergeLeft(newProps: object, target: object): Output; export function mergeLeft(newProps: object): (target: object) => Output; /** * It creates a copy of `target` object with overwritten `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same. */ export function mergeRight(target: A, newProps: B): A & B export function mergeRight(target: any): (newProps: any) => Output; /** * It takes two objects and a function, which will be used when there is an overlap between the keys. */ export function mergeWith(fn: (x: any, z: any) => any, a: Record, b: Record): Record; export function mergeWith(fn: (x: any, z: any) => any, a: Record, b: Record): Output; export function mergeWith(fn: (x: any, z: any) => any, a: Record): (b: Record) => Record; export function mergeWith(fn: (x: any, z: any) => any, a: Record): (b: Record) => Output; export function mergeWith(fn: (x: any, z: any) => any): (a: U, b: V) => Record; export function mergeWith(fn: (x: any, z: any) => any): (a: U, b: V) => Output; /** * It returns the lesser value between `x` and `y`. */ export function min(x: T, y: T): T; export function min(x: T): (y: T) => T; /** * It returns the lesser value between `x` and `y` according to `compareFn` function. */ export function minBy(compareFn: (input: T) => Ord, x: T, y: T): T; export function minBy(compareFn: (input: T) => Ord, x: T): (y: T) => T; export function minBy(compareFn: (input: T) => Ord): (x: T) => (y: T) => T; export function modify(prop: K, fn: (value: T) => T): >(object: U) => U; export function modify(prop: K, fn: (value: U[K]) => U[K], object: U): U; export function modify(prop: K): { (fn: (value: T) => T): >(object: U) => U; >(fn: (value: T) => T, object: U): U; }; /** * It changes a property of object on the base of provided path and transformer function. */ export function modifyPath>(path: Path, fn: (x: any) => unknown, object: Record): T; export function modifyPath>(path: Path, fn: (x: any) => unknown): (object: Record) => T; export function modifyPath>(path: Path): (fn: (x: any) => unknown) => (object: Record) => T; /** * Curried version of `x%y`. */ export function modulo(x: number, y: number): number; export function modulo(x: number): (y: number) => number; /** * It returns a copy of `list` with exchanged `fromIndex` and `toIndex` elements. */ export function move(fromIndex: number, toIndex: number, list: T[]): T[]; export function move(fromIndex: number, toIndex: number): (list: T[]) => T[]; export function move(fromIndex: number): { (toIndex: number, list: T[]): T[]; (toIndex: number): (list: T[]) => T[]; }; /** * Curried version of `x*y`. */ export function multiply(x: number, y: number): number; export function multiply(x: number): (y: number) => number; export function negate(x: number): number; /** * It returns the next index of the list. * * If we have reached the end of the list, then it will return `0`. */ export function nextIndex(index: number, list: any[]): number; /** * It returns `true`, if all members of array `list` returns `false`, when applied as argument to `predicate` function. */ export function none(predicate: (x: T) => boolean, list: T[]): boolean; export function none(predicate: (x: T) => boolean): (list: T[]) => boolean; export function noop(): void; // RAMBDAX_MARKER_END // ============================================ export as namespace R /** * It returns a boolean negated version of `input`. */ export function not(input: any): boolean; /** * Curried version of `input[index]`. */ export function nth(index: number, input: string): string; export function nth(index: number, input: T[]): T | undefined; export function nth(n: number): { (input: T[]): T | undefined; (input: string): string; }; /** * It creates an object with a single key-value pair. */ export function objOf(key: K, value: T): Record; export function objOf(key: K): (value: T) => Record; export function of(x: T): T[]; /** * It checks if `inputs` are following `schemas` specifications according to `R.isValid`. * * If validation fails, it throws. */ export function ok(...inputs: any[]): (...schemas: any[]) => void | never; /** * It returns a partial copy of an `obj` without `propsToOmit` properties. */ export function omit(propsToOmit: K[], obj: T): Omit; export function omit(propsToOmit: K[]): (obj: T) => Omit; export function omit(propsToOmit: string, obj: T): U; export function omit(propsToOmit: string): (obj: T) => U; export function omit(propsToOmit: string, obj: object): T; export function omit(propsToOmit: string): (obj: object) => T; /** * It passes the two inputs through `unaryFn` and then the results are passed as inputs the the `binaryFn` to receive the final result(`binaryFn(unaryFn(FIRST_INPUT), unaryFn(SECOND_INPUT))`). * * This method is also known as P combinator. */ export function on(binaryFn: (a: U, b: U) => R, unaryFn: (value: T) => U, a: T, b: T): R; export function on(binaryFn: (a: U, b: U) => R, unaryFn: (value: T) => U, a: T): (b: T) => R; export function on(binaryFn: (a: U, b: U) => R, unaryFn: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R; }; /** * It returns a function, which invokes only once `fn` function. */ export function once(fn: T, context?: C): T; /** * Logical OR */ export function or(a: T, b: U): T | U; export function or(a: T): (b: U) => T | U; /** * It returns a copied **Object** or **Array** with modified value received by applying function `fn` to `lens` focus. */ export function over(lens: Lens): { (fn: (a: A) => A): (value: S) => S; (fn: (a: A) => A, value: S): S; }; export function over(lens: Lens, fn: (a: A) => A): (value: S) => S; export function over(lens: Lens, fn: (a: A) => A, value: S): S; /** * It is very similar to `R.curry`, but you can pass initial arguments when you create the curried function. * * `R.partial` will keep returning a function until all the arguments that the function `fn` expects are passed. * The name comes from the fact that you partially inject the inputs. */ export function partial(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T; export function partial(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0, V1]): (x2: V2) => T; export function partial(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0]): (x1: V1, x2: V2) => T; export function partial( fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1, V2], ): (x2: V3) => T; export function partial( fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1], ): (x2: V2, x3: V3) => T; export function partial( fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0], ): (x1: V1, x2: V2, x3: V3) => T; export function partial(fn: (...a: any[]) => T, args: any[]): (...a: any[]) => T; /** * Same as `R.partialObject`. * * When `Ramda` introduced `R.partialObject`, `Rambdax` already had such method, i.e. `R.partialCurry`. So this method is kept for backward compatibility. */ export function partialCurry( fn: (input: Input) => Output, partialInput: PartialInput, ): (input: Pick>) => Output; /** * `R.partialObject` is a curry helper designed specifically for functions accepting object as a single argument. * * Initially the function knows only a part from the whole input object and then `R.partialObject` helps in preparing the function for the second part, when it receives the rest of the input. */ export function partialObject( fn: (input: Input) => Output, partialInput: PartialInput, ): (input: Pick>) => Output; /** * It will return array of two objects/arrays according to `predicate` function. The first member holds all instances of `input` that pass the `predicate` function, while the second member - those who doesn't. */ export function partition( predicate: Predicate, input: T[] ): [T[], T[]]; export function partition( predicate: Predicate ): (input: T[]) => [T[], T[]]; export function partition( predicate: (x: T, prop?: string) => boolean, input: { [key: string]: T} ): [{ [key: string]: T}, { [key: string]: T}]; export function partition( predicate: (x: T, prop?: string) => boolean ): (input: { [key: string]: T}) => [{ [key: string]: T}, { [key: string]: T}]; export function partitionIndexed( predicate: IndexedPredicate, input: T[] ): [T[], T[]]; export function partitionIndexed( predicate: IndexedPredicate ): (input: T[]) => [T[], T[]]; export function partitionIndexed( predicate: (x: T, prop?: string) => boolean, input: { [key: string]: T} ): [{ [key: string]: T}, { [key: string]: T}]; export function partitionIndexed( predicate: (x: T, prop?: string) => boolean ): (input: { [key: string]: T}) => [{ [key: string]: T}, { [key: string]: T}]; /** * It checks if `inputs` are following `schemas` specifications according to `R.isValid`. */ export function pass(...inputs: any[]): (...rules: any[]) => boolean; /** * If `pathToSearch` is `'a.b'` then it will return `1` if `obj` is `{a:{b:1}}`. * * It will return `undefined`, if such path is not found. */ export function path(path: [K0], obj: S): S[K0]; export function path(path: [K0, K1], obj: S): S[K0][K1]; export function path< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1] >(path: [K0, K1, K2], obj: S): S[K0][K1][K2]; export function path< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1], K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2], >(path: [K0, K1, K2, K3], obj: S): S[K0][K1][K2][K3]; export function path< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1], K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2], K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3], >(path: [K0, K1, K2, K3, K4], obj: S): S[K0][K1][K2][K3][K4]; export function path< S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0], K2 extends keyof S[K0][K1] = keyof S[K0][K1], K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2], K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3], K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4], >(path: [K0, K1, K2, K3, K4, K5], obj: S): S[K0][K1][K2][K3][K4][K5]; export function path(pathToSearch: string, obj: any): T | undefined; export function path(pathToSearch: string): (obj: any) => T | undefined; export function path(pathToSearch: RamdaPath): (obj: any) => T | undefined; export function path(pathToSearch: RamdaPath, obj: any): T | undefined; /** * It returns `true` if `pathToSearch` of `input` object is equal to `target` value. * * `pathToSearch` is passed to `R.path`, which means that it can be either a string or an array. Also equality between `target` and the found value is determined by `R.equals`. */ export function pathEq(pathToSearch: Path, target: any, input: any): boolean; export function pathEq(pathToSearch: Path, target: any): (input: any) => boolean; export function pathEq(pathToSearch: Path): (target: any) => (input: any) => boolean; /** * It reads `obj` input and returns either `R.path(pathToSearch, Record)` result or `defaultValue` input. */ export function pathOr(defaultValue: T, pathToSearch: Path, obj: any): T; export function pathOr(defaultValue: T, pathToSearch: Path): (obj: any) => T; export function pathOr(defaultValue: T): (pathToSearch: Path) => (obj: any) => T; export function pathSatisfies(pred: (val: T) => boolean, path: Path): (obj: U) => boolean; export function pathSatisfies(pred: (val: T) => boolean, path: Path, obj: U): boolean; /** * It loops over members of `pathsToSearch` as `singlePath` and returns the array produced by `R.path(singlePath, Record)`. * * Because it calls `R.path`, then `singlePath` can be either string or a list. */ export function paths(pathsToSearch: Path[], obj: Input): (T | undefined)[]; export function paths(pathsToSearch: Path[]): (obj: Input) => (T | undefined)[]; export function paths(pathsToSearch: Path[], obj: any): (T | undefined)[]; export function paths(pathsToSearch: Path[]): (obj: any) => (T | undefined)[]; /** * It returns a partial copy of an `input` containing only `propsToPick` properties. * * `input` can be either an object or an array. * * String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`. */ export function pick(propsToPick: K[], input: T): Pick>>; export function pick(propsToPick: K[]): (input: T) => Pick>>; export function pick(propsToPick: string, input: T): U; export function pick(propsToPick: string): (input: T) => U; export function pick(propsToPick: string, input: object): T; export function pick(propsToPick: string): (input: object) => T; /** * Same as `R.pick` but it won't skip the missing props, i.e. it will assign them to `undefined`. */ export function pickAll(propsToPicks: K[], input: T): Pick; export function pickAll(propsToPicks: string[], input: T): U; export function pickAll(propsToPicks: string[]): (input: T) => U; export function pickAll(propsToPick: string, input: T): U; export function pickAll(propsToPick: string): (input: T) => U; export function pickBy(pred: ObjPred): (obj: V) => U; export function pickBy(pred: ObjPred, obj: T): U; /** * It performs left-to-right function composition. */ export function pipe( ...funcs: [ f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: Array<(a: any) => any>, fnLast: (a: any) => TResult ] ): (...args: TArgs) => TResult; // fallback overload if number of piped functions greater than 7 export function pipe( f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7 ): (...args: TArgs) => R7; export function pipe( f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6 ): (...args: TArgs) => R6; export function pipe( f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5 ): (...args: TArgs) => R5; export function pipe( f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4 ): (...args: TArgs) => R4; export function pipe( f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3 ): (...args: TArgs) => R3; export function pipe( f1: (...args: TArgs) => R1, f2: (a: R1) => R2 ): (...args: TArgs) => R2; export function pipe( f1: (...args: TArgs) => R1 ): (...args: TArgs) => R1; /** * Asynchronous version of `R.pipe`, but it accepts only one argument as input(instead of multiple as regular `pipe`). It `await`s the result of each function before passing it to the next. Returns a `Promise` of the result. */ export function pipeAsync( ...funcs: [ f1: (a: Awaited) => R1, f2: (a: Awaited) => R2, f3: (a: Awaited) => R3, f4: (a: Awaited) => R4, f5: (a: Awaited) => R5, f6: (a: Awaited) => R6, f7: (a: Awaited) => R7, ...func: Array<(a: any) => any>, fnLast: (a: any) => TResult ] ): (a: TArg | Promise) => TResult; // fallback overload if number of piped functions greater than 7 export function pipeAsync( f1: (a: Awaited) => R1, f2: (a: Awaited) => R2, f3: (a: Awaited) => R3, f4: (a: Awaited) => R4, f5: (a: Awaited) => R5, f6: (a: Awaited) => R6, f7: (a: Awaited) => R7 ): (a: TArg | Promise) => R7; export function pipeAsync( f1: (a: Awaited) => R1, f2: (a: Awaited) => R2, f3: (a: Awaited) => R3, f4: (a: Awaited) => R4, f5: (a: Awaited) => R5, f6: (a: Awaited) => R6 ): (a: TArg | Promise) => R6; export function pipeAsync( f1: (a: Awaited) => R1, f2: (a: Awaited) => R2, f3: (a: Awaited) => R3, f4: (a: Awaited) => R4, f5: (a: Awaited) => R5 ): (a: TArg | Promise) => R5; export function pipeAsync( f1: (a: Awaited) => R1, f2: (a: Awaited) => R2, f3: (a: Awaited) => R3, f4: (a: Awaited) => R4 ): (a: TArg | Promise) => R4; export function pipeAsync( f1: (a: Awaited) => R1, f2: (a: Awaited) => R2, f3: (a: Awaited) => R3 ): (a: TArg | Promise) => R3; export function pipeAsync( f1: (a: Awaited) => R1, f2: (a: Awaited) => R2 ): (a: TArg | Promise) => R2; export function pipeAsync( f1: (a: Awaited) => R1 ): (a: TArg | Promise) => R1; /** * It is basically `R.pipe`, but instead of passing `input` argument as `R.pipe(...)(input)`, you pass it as the first argument. */ export function piped(input: A, fn0: (x: A) => B) : B; export function piped(input: A, fn0: (x: A) => B, fn1: (x: B) => C) : C; export function piped(input: A, fn0: (x: A) => B, fn1: (x: B) => C, fn2: (x: C) => D) : D; export function piped(input: A, fn0: (x: A) => B, fn1: (x: B) => C, fn2: (x: C) => D, fn3: (x: D) => E) : E; export function piped(input: A, fn0: (x: A) => B, fn1: (x: B) => C, fn2: (x: C) => D, fn3: (x: D) => E, fn4: (x: E) => F) : F; export function piped(input: A, fn0: (x: A) => B, fn1: (x: B) => C, fn2: (x: C) => D, fn3: (x: D) => E, fn4: (x: E) => F, fn5: (x: F) => G) : G; export function piped(input: A, fn0: (x: A) => B, fn1: (x: B) => C, fn2: (x: C) => D, fn3: (x: D) => E, fn4: (x: E) => F, fn5: (x: F) => G, fn6: (x: G) => H) : H; export function piped(input: A, fn0: (x: A) => B, fn1: (x: B) => C, fn2: (x: C) => D, fn3: (x: D) => E, fn4: (x: E) => F, fn5: (x: F) => G, fn6: (x: G) => H, fn7: (x: H) => I) : I; /** * It accepts input as first argument and series of functions as next arguments. It is same as `R.piped` but with support for asynchronous functions like `R.pipeAsync`. */ export function pipedAsync(input: A, fn0: (x: Awaited) => B) : B; export function pipedAsync(input: A, fn0: (x: Awaited) => B, fn1: (x: Awaited) => C) : C; export function pipedAsync(input: A, fn0: (x: Awaited) => B, fn1: (x: Awaited) => C, fn2: (x: Awaited) => D) : D; export function pipedAsync(input: A, fn0: (x: Awaited) => B, fn1: (x: Awaited) => C, fn2: (x: Awaited) => D, fn3: (x: Awaited) => E) : E; export function pipedAsync(input: A, fn0: (x: Awaited) => B, fn1: (x: Awaited) => C, fn2: (x: Awaited) => D, fn3: (x: Awaited) => E, fn4: (x: Awaited) => F) : F; export function pipedAsync(input: A, fn0: (x: Awaited) => B, fn1: (x: Awaited) => C, fn2: (x: Awaited) => D, fn3: (x: Awaited) => E, fn4: (x: Awaited) => F, fn5: (x: Awaited) => G) : G; export function pipedAsync(input: A, fn0: (x: Awaited) => B, fn1: (x: Awaited) => C, fn2: (x: Awaited) => D, fn3: (x: Awaited) => E, fn4: (x: Awaited) => F, fn5: (x: Awaited) => G, fn6: (x: Awaited) => H) : H; export function pipedAsync(input: A, fn0: (x: Awaited) => B, fn1: (x: Awaited) => C, fn2: (x: Awaited) => D, fn3: (x: Awaited) => E, fn4: (x: Awaited) => F, fn5: (x: Awaited) => G, fn6: (x: Awaited) => H, fn7: (x: Awaited) => I) : I; /** * It returns list of the values of `property` taken from the all objects inside `list`. */ export function pluck(property: K, list: T[]): T[K][]; export function pluck(property: number, list: { [k: number]: T }[]): T[]; export function pluck