UNPKG

117 kBTypeScriptView Raw
1// Type definitions for ramda 0.27
2// Project: https://ramdajs.com
3// Definitions by: Scott O'Malley <https://github.com/TheHandsomeCoder>
4// Erwin Poeze <https://github.com/donnut>
5// Matt DeKrey <https://github.com/mdekrey>
6// Stephen King <https://github.com/sbking>
7// Alejandro Fernandez Haro <https://github.com/afharo>
8// Vítor Castro <https://github.com/teves-castro>
9// Jordan Quagliatini <https://github.com/1M0reBug>
10// Simon Højberg <https://github.com/hojberg>
11// Samson Keung <https://github.com/samsonkeung>
12// Angelo Ocana <https://github.com/angeloocana>
13// Rayner Pupo <https://github.com/raynerd>
14// Nikita Moshensky <https://github.com/moshensky>
15// Ethan Resnick <https://github.com/ethanresnick>
16// Tomas Szabo <https://github.com/deftomat>
17// Maciek Blim <https://github.com/blimusiek>
18// Marcin Biernat <https://github.com/biern>
19// Rayhaneh Banyassady <https://github.com/rayhaneh>
20// Ryan McCuaig <https://github.com/rgm>
21// Drew Wyatt <https://github.com/drewwyatt>
22// John Ottenlips <https://github.com/jottenlips>
23// Nitesh Phadatare <https://github.com/minitesh>
24// Krantisinh Deshmukh <https://github.com/krantisinh>
25// Pierre-Antoine Mills <https://github.com/pirix-gh>
26// Aram Kharazyan <https://github.com/nemo108>
27// Jituan Lin <https://github.com/jituanlin>
28// Philippe Mills <https://github.com/Philippe-mills>
29// Saul Mirone <https://github.com/Saul-Mirone>
30// Nicholai Nissen <https://github.com/Nicholaiii>
31// Mike Deverell <https://github.com/devrelm>
32// Jorge Santana <https://github.com/LORDBABUINO>
33// Mikael Couzic <https://github.com/couzic>
34// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
35// TypeScript Version: 4.2
36
37import * as _ from "ts-toolbelt";
38import {
39 Arity0Fn,
40 Arity1Fn,
41 Arity2Fn,
42 AssocPartialOne,
43 ComposeWithFns,
44 Dictionary,
45 Evolvable,
46 Evolve,
47 Evolver,
48 Filter,
49 Functor,
50 KeyValuePair,
51 Lens,
52 Merge,
53 MergeAll,
54 ObjectHavingSome,
55 ObjPred,
56 Ord,
57 Path,
58 Placeholder,
59 Pred,
60 PipeWithFns,
61 Reduced,
62 SafePred,
63 ValueOfRecord,
64 ValueOfUnion
65} from "./tools";
66
67export * from './tools';
68
69/**
70 * Placeholder. When used with functions like curry, or op, the second argument is applied to the second
71 * position, and it returns a function waiting for its first argument.
72 */
73export const __: Placeholder; /* This is used in examples throughout the docs, but I it only seems to be directly explained here: https://ramdajs.com/0.9/docs/#op */
74
75/**
76 * Adds two numbers. Equivalent to a + b but curried.
77 */
78export function add(a: number, b: number): number;
79export function add(a: number): (b: number) => number;
80
81/**
82 * Creates a new list iteration function from an existing one by adding two new parameters to its callback
83 * function: the current index, and the entire list.
84 */
85export function addIndex<T, U>(fn: (f: (item: T) => U, list: readonly T[]) => U[]): _.F.Curry<(a: (item: T, idx: number, list?: T[]) => U, b: readonly T[]) => U[]>;
86/* Special case for forEach */
87export function addIndex<T>(fn: (f: (item: T) => void, list: readonly T[]) => T[]): _.F.Curry<(a: (item: T, idx: number, list?: T[]) => void, b: readonly T[]) => T[]>;
88/* Special case for reduce */
89export function addIndex<T, U>(fn: (f: (acc: U, item: T) => U, aci: U, list: readonly T[]) => U): _.F.Curry<(a: (acc: U, item: T, idx: number, list?: T[]) => U, b: U, c: readonly T[]) => U>;
90
91/**
92 * Applies a function to the value at the given index of an array, returning a new copy of the array with the
93 * element at the given index replaced with the result of the function application.
94 */
95export function adjust<T>(index: number, fn: (a: T) => T, list: readonly T[]): T[];
96export function adjust<T>(index: number, fn: (a: T) => T): (list: readonly T[]) => T[];
97
98/**
99 * Returns true if all elements of the list match the predicate, false if there are any that don't.
100 */
101export function all<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
102export function all<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
103
104/**
105 * Given a list of predicates, returns a new predicate that will be true exactly when all of them are.
106 */
107export function allPass(preds: readonly Pred[]): Pred;
108
109/**
110 * Returns a function that always returns the given value.
111 */
112export function always<T>(val: T): () => T;
113
114/**
115 * A function that returns the first argument if it's falsy otherwise the second argument. Note that this is
116 * NOT short-circuited, meaning that if expressions are passed they are both evaluated.
117 */
118export function and<T extends { and?: ((...a: readonly any[]) => any) | undefined; } | number | boolean | string | null>(fn1: T, val2: any): boolean;
119export function and<T extends { and?: ((...a: readonly any[]) => any) | undefined; } | number | boolean | string | null>(fn1: T): (val2: any) => boolean;
120
121/**
122 * Returns the result of applying the onSuccess function to the value inside a successfully resolved promise. This is useful for working with promises inside function compositions.
123 */
124export function andThen<A, B>(onSuccess: (a: A) => B | Promise<B>, promise: Promise<A>): Promise<B>;
125export function andThen<A, B>(onSuccess: (a: A) => B | Promise<B>): (promise: Promise<A>) => Promise<B>;
126
127/**
128 * Returns true if at least one of elements of the list match the predicate, false otherwise.
129 */
130export function any<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
131export function any<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
132
133/**
134 * Given a list of predicates returns a new predicate that will be true exactly when any one of them is.
135 */
136export function anyPass<T>(preds: Array<SafePred<T>>): SafePred<T>;
137
138/**
139 * ap applies a list of functions to a list of values.
140 */
141export function ap<T, U>(fns: Array<((a: T) => U)>, vs: readonly T[]): U[];
142export function ap<T, U>(fns: Array<((a: T) => U)>): (vs: readonly T[]) => U[];
143export function ap<X0, X1, R>(
144 fn: (x1: X1, x0: X0) => R,
145 fn1: (x1: X1) => X0
146): (x1: X1) => R;
147
148/**
149 * Returns a new list, composed of n-tuples of consecutive elements If n is greater than the length of the list,
150 * an empty list is returned.
151 */
152export function aperture<T>(n: 1, list: readonly T[]): Array<[T]>;
153export function aperture<T>(n: 2, list: readonly T[]): Array<[T, T]>;
154export function aperture<T>(n: 3, list: readonly T[]): Array<[T, T, T]>;
155export function aperture<T>(n: 4, list: readonly T[]): Array<[T, T, T, T]>;
156export function aperture<T>(n: 5, list: readonly T[]): Array<[T, T, T, T, T]>;
157export function aperture<T>(n: 6, list: readonly T[]): Array<[T, T, T, T, T, T]>;
158export function aperture<T>(n: 7, list: readonly T[]): Array<[T, T, T, T, T, T, T]>;
159export function aperture<T>(n: 8, list: readonly T[]): Array<[T, T, T, T, T, T, T, T]>;
160export function aperture<T>(n: 9, list: readonly T[]): Array<[T, T, T, T, T, T, T, T, T]>;
161export function aperture<T>(n: 10, list: readonly T[]): Array<[T, T, T, T, T, T, T, T, T, T]>;
162export function aperture<T>(n: number, list: readonly T[]): T[][];
163export function aperture(n: number): <T>(list: readonly T[]) => T[][];
164
165/**
166 * Returns a new list containing the contents of the given list, followed by the given element.
167 */
168export function append<T>(el: T, list: readonly T[]): T[];
169export function append<T>(el: T): <T>(list: readonly T[]) => T[];
170
171/**
172 * Applies function fn to the argument list args. This is useful for creating a fixed-arity function from
173 * a variadic function. fn should be a bound function if context is significant.
174 */
175export function apply<T, U, TResult>(fn: (arg0: T, ...args: readonly T[]) => TResult, args: readonly U[]): TResult;
176export function apply<T, TResult>(fn: (arg0: T, ...args: readonly T[]) => TResult): <U>(args: readonly U[]) => TResult;
177
178/**
179 * Given a spec object recursively mapping properties to functions, creates a function producing an object
180 * of the same structure, by mapping each property to the result of calling its associated function with
181 * the supplied arguments.
182 */
183export function applySpec<Obj extends Record<string, (...args: readonly any[]) => any>>(
184 obj: Obj
185): (
186 ...args: Parameters<ValueOfRecord<Obj>>
187 ) => { [Key in keyof Obj]: ReturnType<Obj[Key]> };
188export function applySpec<T>(obj: any): (...args: readonly any[]) => T;
189
190/**
191 * Takes a value and applies a function to it.
192 * This function is also known as the thrush combinator.
193 */
194export function applyTo<T, U>(el: T, fn: (t: T) => U): U;
195export function applyTo<T>(el: T): <U>(fn: (t: T) => U) => U;
196
197/**
198 * Makes an ascending comparator function out of a function that returns a value that can be compared with < and >.
199 */
200export function ascend<T>(fn: (obj: T) => any, a: T, b: T): number;
201export function ascend<T>(fn: (obj: T) => any): (a: T, b: T) => number;
202
203/**
204 * Makes a shallow clone of an object, setting or overriding the specified property with the given value.
205 */
206export function assoc<T, U>(__: Placeholder, val: T, obj: U): <K extends string>(prop: K) => Record<K, T> & U;
207export function assoc<U, K extends string>(prop: K, __: Placeholder, obj: U): <T>(val: T) => Record<K, T> & U;
208export function assoc<T, U, K extends string>(prop: K, val: T, obj: U): Record<K, T> & U;
209export function assoc<T, K extends string>(prop: K, val: T): <U>(obj: U) => Record<K, T> & U;
210export function assoc<K extends string>(prop: K): AssocPartialOne<K>;
211
212/**
213 * Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and
214 * placing the specific value at the tail end of that path.
215 */
216export function assocPath<T, U>(__: Placeholder, val: T, obj: U): (path: Path) => U;
217export function assocPath<T, U>(path: Path, __: Placeholder, obj: U): (val: T) => U;
218export function assocPath<T, U>(path: Path, val: T, obj: U): U;
219export function assocPath<T, U>(path: Path, val: T): (obj: U) => U;
220export function assocPath<T, U>(path: Path): _.F.Curry<(a: T, b: U) => U>;
221
222/**
223 * Wraps a function of any arity (including nullary) in a function that accepts exactly 2
224 * parameters. Any extraneous parameters will not be passed to the supplied function.
225 */
226export function binary<T extends (...arg: any) => any>(fn: T): (...arg: _.T.Take<Parameters<T>, '2'>) => ReturnType<T>;
227
228/**
229 * Creates a function that is bound to a context. Note: R.bind does not provide the additional argument-binding
230 * capabilities of Function.prototype.bind.
231 */
232export function bind<F extends (...args: readonly any[]) => any, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
233export function bind<F extends (...args: readonly any[]) => any, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>;
234
235/**
236 * A function wrapping calls to the two functions in an && operation, returning the result of the first function
237 * if it is false-y and the result of the second function otherwise. Note that this is short-circuited, meaning
238 * that the second function will not be invoked if the first returns a false-y value.
239 */
240export function both(pred1: Pred, pred2: Pred): Pred;
241export function both(pred1: Pred): (pred2: Pred) => Pred;
242
243/**
244 * Returns the result of calling its first argument with the remaining arguments. This is occasionally useful
245 * as a converging function for R.converge: the left branch can produce a function while the right branch
246 * produces a value to be passed to that function as an argument.
247 */
248export function call(fn: (...args: readonly any[]) => (...args: readonly any[]) => any, ...args: readonly any[]): any;
249
250/**
251 * `chain` maps a function over a list and concatenates the results.
252 * This implementation is compatible with the Fantasy-land Chain spec
253 */
254export function chain<T, U>(fn: (n: T) => readonly U[], list: readonly T[]): U[];
255export function chain<T, U>(fn: (n: T) => readonly U[]): (list: readonly T[]) => U[];
256export function chain<X0, X1, R>(fn: (x0: X0) => (x1: X1) => R, fn1: (x1: X1) => X0): (x1: X1) => R;
257
258/**
259 * Restricts a number to be within a range.
260 * Also works for other ordered types such as Strings and Date
261 */
262export function clamp<T>(min: T, max: T, value: T): T;
263export function clamp<T>(min: T, max: T): (value: T) => T;
264export function clamp<T>(min: T): (max: T, value: T) => T;
265export function clamp<T>(min: T): (max: T) => (value: T) => T;
266
267/**
268 * Creates a deep copy of the value which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates.
269 */
270export function clone<T>(value: T): T;
271export function clone<T>(value: readonly T[]): T[];
272
273/**
274 * Makes a comparator function out of a function that reports whether the first element is less than the second.
275 */
276// comparator(pred: (a: any, b: any) => boolean): (x: number, y: number) => number;
277export function comparator<T>(pred: (a: T, b: T) => boolean): (x: T, y: T) => number;
278
279/**
280 * Takes a function f and returns a function g such that:
281 * - applying g to zero or more arguments will give true if applying the same arguments to f gives
282 * a logical false value; and
283 * - applying g to zero or more arguments will give false if applying the same arguments to f gives
284 * a logical true value.
285 */
286export function complement<As extends any[]>(pred: (...args: As) => boolean): (...args: As) => boolean;
287
288/**
289 * Performs right-to-left function composition. The rightmost function may have any arity; the remaining
290 * functions must be unary.
291 */
292// generic rest parameters in TS 3.0 allows writing a single variant for any number of Vx
293// compose<V extends any[], T1>(fn0: (...args: V) => T1): (...args: V) => T1;
294// compose<V extends any[], T1, T2>(fn1: (x: T1) => T2, fn0: (...args: V) => T1): (...args: V) => T2;
295// but requiring TS>=3.0 sounds like a breaking change, so just leaving a comment for the future
296// tslint:disable:max-line-length
297export function compose<T1>(fn0: () => T1): () => T1;
298export function compose<V0, T1>(fn0: (x0: V0) => T1): (x0: V0) => T1;
299export function compose<V0, V1, T1>(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1;
300export function compose<V0, V1, V2, T1>(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1;
301
302export function compose<T1, T2>(fn1: (x: T1) => T2, fn0: () => T1): () => T2;
303export function compose<V0, T1, T2>(fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T2;
304export function compose<V0, V1, T1, T2>(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T2;
305export function compose<V0, V1, V2, T1, T2>(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T2;
306
307export function compose<T1, T2, T3>(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: () => T1): () => T3;
308export function compose<V0, T1, T2, T3>(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x: V0) => T1): (x: V0) => T3;
309export function compose<V0, V1, T1, T2, T3>(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T3;
310export function compose<V0, V1, V2, T1, T2, T3>(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T3;
311
312export function compose<T1, T2, T3, T4>(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: () => T1): () => T4;
313export function compose<V0, T1, T2, T3, T4>(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x: V0) => T1): (x: V0) => T4;
314export function compose<V0, V1, T1, T2, T3, T4>(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T4;
315export function compose<V0, V1, V2, T1, T2, T3, T4>(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T4;
316
317export function compose<T1, T2, T3, T4, T5>(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: () => T1): () => T5;
318export function compose<V0, T1, T2, T3, T4, T5>(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x: V0) => T1): (x: V0) => T5;
319export function compose<V0, V1, T1, T2, T3, T4, T5>(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T5;
320export function compose<V0, V1, V2, T1, T2, T3, T4, T5>(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T5;
321
322export function compose<T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: () => T1): () => T6;
323export function compose<V0, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x: V0) => T1): (x: V0) => T6;
324export function compose<V0, V1, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T6;
325export function compose<V0, V1, V2, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T6;
326// tslint:enable:max-line-length
327
328/**
329 * Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain.
330 * The typings only support arrays for now.
331 * All functions must be unary.
332 * R.composeK(h, g, f) is equivalent to R.compose(R.chain(h), R.chain(g), f).
333 *
334 * @deprecated since 0.26 in favor of composeWith(chain)
335 */
336// tslint:disable:max-line-length
337export function composeK<V0, T1>(fn0: (x0: V0) => T1[]): (x0: V0) => T1[];
338export function composeK<V0, T1, T2>(fn1: (x: T1) => T2[], fn0: (x0: V0) => T1[]): (x0: V0) => T2[];
339export function composeK<V0, T1, T2, T3>(fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T3[];
340export function composeK<V0, T1, T2, T3, T4>(fn3: (x: T3) => T4[], fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T4[];
341export function composeK<V0, T1, T2, T3, T4, T5>(fn4: (x: T4) => T5[], fn3: (x: T3) => T4[], fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T5[];
342export function composeK<V0, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => T6[], fn4: (x: T4) => T5[], fn3: (x: T3) => T4[], fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T6[];
343// tslint:enable:max-line-length
344
345/**
346 * Performs right-to-left composition of one or more Promise-returning functions.
347 * All functions must be unary.
348 *
349 * @deprecated since 0.26 in favor of composeWith(then)
350 */
351// tslint:disable:max-line-length
352export function composeP<V0, T1>(fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T1>;
353export function composeP<V0, T1, T2>(fn1: (x: T1) => Promise<T2>, fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T2>;
354export function composeP<V0, T1, T2, T3>(fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T3>;
355export function composeP<V0, T1, T2, T3, T4>(fn3: (x: T3) => Promise<T4>, fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T4>;
356export function composeP<V0, T1, T2, T3, T4, T5>(fn4: (x: T4) => Promise<T5>, fn3: (x: T3) => Promise<T4>, fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T5>;
357export function composeP<V0, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => Promise<T6>, fn4: (x: T4) => Promise<T5>, fn3: (x: T3) => Promise<T4>, fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T6>;
358// tslint:enable:max-line-length
359
360/**
361 * Performs right-to-left function composition using transforming function.
362 * With the current typings, all functions must be unary.
363 */
364export function composeWith<V0, T>(composer: (...args: any[]) => any, fns: ComposeWithFns<V0, T>): (x0: V0) => T;
365export function composeWith(composer: (...args: any[]) => any): <V0, T>(fns: ComposeWithFns<V0, T>) => (x: V0) => T;
366
367/**
368 * Returns the result of concatenating the given lists or strings.
369 */
370export function concat(
371 placeholder: Placeholder,
372): (<L1 extends any[], L2 extends any[]>(list1: L1, list2: L2) => [...L1, ...L2]) &
373 (<S1 extends string, S2 extends string>(s1: S1, s2: S2) => `${S1}${S2}`);
374export function concat<L2 extends any[]>(placeholder: Placeholder, list2: L2): <L1 extends any[]>(list1: L1) => [...L1, ...L2];
375export function concat<S2 extends string>(placeholder: Placeholder, s2: S2): <S1 extends string>(s1: S1) => `${S1}${S2}`;
376export function concat<L1 extends any[]>(list1: L1): <L2 extends any[]>(list2: L2) => [...L1, ...L2];
377export function concat<S1 extends string>(s1: S1): <S2 extends string>(s2: S2) => `${S1}${S2}`;
378export function concat<L1 extends any[], L2 extends any[]>(list1: L1, list2: L2): [...L1, ...L2];
379export function concat<S1 extends string, S2 extends string>(s1: S1, s2: S2): `${S1}${S2}`;
380export function concat(s1: string, s2: string): string;
381export function concat(s1: string): (s2: string) => string;
382
383/**
384 * Returns a function, fn, which encapsulates if/else-if/else logic. R.cond takes a list of [predicate, transform] pairs.
385 * All of the arguments to fn are applied to each of the predicates in turn until one returns a "truthy" value, at which
386 * point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates
387 * matches, fn returns undefined.
388 */
389export function cond(fns: Array<[Pred, (...a: readonly any[]) => any]>): (...a: readonly any[]) => any;
390export function cond<A, B>(fns: Array<[SafePred<A>, (...a: readonly A[]) => B]>): (...a: readonly A[]) => B;
391
392/**
393 * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
394 */
395export function construct<A extends any[], T>(constructor: { new(...a: A): T } | ((...a: A) => T)): (...a: A) => T;
396
397/**
398 * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
399 * The arity of the function returned is specified to allow using variadic constructor functions.
400 */
401export function constructN<A extends any[], T>(n: number, constructor: { new(...a: A): T } | ((...a: A) => T)): (...a: Partial<A>) => T;
402
403/**
404 * Returns `true` if the specified item is somewhere in the list, `false` otherwise.
405 * Equivalent to `indexOf(a)(list) > -1`. Uses strict (`===`) equality checking.
406 *
407 * @deprecated since 0.26 in favor of includes
408 */
409export function contains(__: Placeholder, list: string): (a: string) => boolean;
410export function contains<T>(__: Placeholder, list: readonly T[]): (a: T) => boolean;
411export function contains(__: Placeholder): (list: string, a: string) => boolean;
412export function contains<T>(__: Placeholder): (list: readonly T[], a: T) => boolean;
413export function contains(a: string, list: string): boolean;
414export function contains<T>(a: T, list: readonly T[]): boolean;
415export function contains(a: string): (list: string) => boolean;
416export function contains<T>(a: T): (list: readonly T[]) => boolean;
417
418/**
419 * Accepts a converging function and a list of branching functions and returns a new
420 * function. When invoked, this new function is applied to some arguments, each branching
421 * function is applied to those same arguments. The results of each branching function
422 * are passed as arguments to the converging function to produce the return value.
423 */
424export function converge(after: ((...a: readonly any[]) => any), fns: Array<((...a: readonly any[]) => any)>): (...a: readonly any[]) => any;
425
426/**
427 * Counts the elements of a list according to how many match each value
428 * of a key generated by the supplied function. Returns an object
429 * mapping the keys produced by `fn` to the number of occurrences in
430 * the list. Note that all keys are coerced to strings because of how
431 * JavaScript objects work.
432 */
433export function countBy<T>(fn: (a: T) => string | number, list: readonly T[]): { [index: string]: number };
434export function countBy<T>(fn: (a: T) => string | number): (list: readonly T[]) => { [index: string]: number };
435
436/**
437 * Returns a curried equivalent of the provided function. The curried function has two unusual capabilities.
438 * First, its arguments needn't be provided one at a time.
439 */
440export function curry<F extends (...args: any) => any>(f: F): _.F.Curry<F>;
441
442/**
443 * Returns a curried equivalent of the provided function, with the specified arity. The curried function has
444 * two unusual capabilities. First, its arguments needn't be provided one at a time.
445 */
446export function curryN<N extends number, F extends (...args: any) => any>(length: N, fn: F): _.F.Curry<(...a: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>;
447export function curryN<N extends number>(length: N): <F extends (...args: any) => any>(fn: F) => _.F.Curry<(...a: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>;
448
449/**
450 * Decrements its argument.
451 */
452export function dec(n: number): number;
453
454/**
455 * Returns the second argument if it is not null or undefined. If it is null or undefined, the
456 * first (default) argument is returned.
457 */
458export function defaultTo<T, U>(a: T, b: U | null | undefined): T | U;
459export function defaultTo<T>(a: T): <U>(b: U | null | undefined) => T | U;
460
461/**
462 * Makes a descending comparator function out of a function that returns a value that can be compared with < and >.
463 */
464export function descend<T>(fn: (obj: T) => any, a: T, b: T): number;
465export function descend<T>(fn: (obj: T) => any): (a: T, b: T) => number;
466
467/**
468 * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
469 */
470export function difference<T>(list1: readonly T[], list2: readonly T[]): T[];
471export function difference<T>(list1: readonly T[]): (list2: readonly T[]) => T[];
472
473/**
474 * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
475 * Duplication is determined according to the value returned by applying the supplied predicate to two list
476 * elements.
477 */
478export function differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[], list2: readonly T2[]): T1[];
479export function differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean): (list1: readonly T1[], list2: readonly T2[]) => T1[];
480export function differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[]): (list2: readonly T2[]) => T1[];
481
482/*
483 * Returns a new object that does not contain a prop property.
484 */
485export function dissoc<T extends object, K extends keyof T>(prop: K, obj: T): Omit<T, K>;
486export function dissoc<K extends string | number>(prop: K): <T extends object>(obj: T) => Omit<T, K>;
487
488/**
489 * Makes a shallow clone of an object, omitting the property at the given path.
490 */
491export function dissocPath<T>(path: Path, obj: any): T;
492export function dissocPath<T>(path: Path): (obj: any) => T;
493
494/**
495 * Divides two numbers. Equivalent to a / b.
496 */
497export function divide(__: Placeholder, b: number): (a: number) => number;
498export function divide(__: Placeholder): (b: number, a: number) => number;
499export function divide(a: number, b: number): number;
500export function divide(a: number): (b: number) => number;
501
502/**
503 * Returns a new list containing all but the first n elements of the given list.
504 */
505export function drop<T>(n: number, xs: readonly T[]): T[];
506export function drop(n: number, xs: string): string;
507export function drop<T>(n: number): {
508 (xs: string): string;
509 (xs: readonly T[]): T[];
510};
511
512/**
513 * Returns a list containing all but the last n elements of the given list.
514 */
515export function dropLast<T>(n: number, xs: readonly T[]): T[];
516export function dropLast(n: number, xs: string): string;
517export function dropLast<T>(n: number): {
518 (xs: readonly T[]): T[];
519 (xs: string): string;
520};
521
522/**
523 * Returns a new list containing all but last then elements of a given list, passing each value from the
524 * right to the supplied predicate function, skipping elements while the predicate function returns true.
525 */
526export function dropLastWhile<T>(fn: (a: T) => boolean, list: readonly T[]): T[];
527export function dropLastWhile<T>(fn: (a: T) => boolean): (list: readonly T[]) => T[];
528
529/**
530 * Returns a new list without any consecutively repeating elements. R.equals is used to determine equality.
531 */
532export function dropRepeats<T>(list: readonly T[]): T[];
533
534/**
535 * Returns a new list without any consecutively repeating elements.
536 * Equality is determined by applying the supplied predicate to each pair of consecutive elements.
537 * The first element in a series of equal elements will be preserved.
538 */
539export function dropRepeatsWith<T>(predicate: (left: T, right: T) => boolean, list: readonly T[]): T[];
540export function dropRepeatsWith<T>(predicate: (left: T, right: T) => boolean): (list: readonly T[]) => T[];
541
542/**
543 * Returns a new list containing the last n elements of a given list, passing each value to the supplied
544 * predicate function, skipping elements while the predicate function returns true.
545 */
546export function dropWhile<T>(fn: (a: T) => boolean, list: readonly T[]): T[];
547export function dropWhile<T>(fn: (a: T) => boolean): (list: readonly T[]) => T[];
548
549/**
550 * A function wrapping calls to the two functions in an || operation, returning the result of the first
551 * function if it is truth-y and the result of the second function otherwise. Note that this is
552 * short-circuited, meaning that the second function will not be invoked if the first returns a truth-y value.
553 */
554export function either(pred1: Pred, pred2: Pred): Pred;
555export function either(pred1: Pred): (pred2: Pred) => Pred;
556
557/**
558 * Returns the empty value of its argument's type. Ramda defines the empty value of Array ([]), Object ({}),
559 * String (''), and Arguments. Other types are supported if they define <Type>.empty and/or <Type>.prototype.empty.
560 * Dispatches to the empty method of the first argument, if present.
561 */
562export function empty<T>(x: T): T;
563
564/**
565 * Checks if a list ends with the provided values
566 */
567export function endsWith(a: string, list: string): boolean;
568export function endsWith(a: string): (list: string) => boolean;
569export function endsWith<T>(a: T | readonly T[], list: readonly T[]): boolean;
570export function endsWith<T>(a: T | readonly T[]): (list: readonly T[]) => boolean;
571
572/**
573 * Takes a function and two values in its domain and returns true if the values map to the same value in the
574 * codomain; false otherwise.
575 */
576export function eqBy<T, U = T>(fn: (a: T) => U, a: T, b: T): boolean;
577export function eqBy<T, U = T>(fn: (a: T) => U, a: T): (b: T) => boolean;
578export function eqBy<T, U = T>(fn: (a: T) => U): _.F.Curry<(a: T, b: T) => boolean>;
579
580/**
581 * Reports whether two functions have the same value for the specified property.
582 */
583export function eqProps<T, U>(prop: string, obj1: T, obj2: U): boolean;
584export function eqProps<P extends string>(prop: P): <T, U>(obj1: Record<P, T>, obj2: Record<P, U>) => boolean;
585export function eqProps<T>(prop: string, obj1: T): <U>(obj2: U) => boolean;
586
587/**
588 * Returns true if its arguments are equivalent, false otherwise. Dispatches to an equals method if present.
589 * Handles cyclical data structures.
590 */
591export function equals<T>(__: Placeholder, b: T): (a: T) => boolean;
592export function equals<T>(a: T, b: T): boolean;
593export function equals<T>(a: T): (b: T) => boolean;
594
595/**
596 * Creates a new object by evolving a shallow copy of object, according to the transformation functions.
597 */
598export function evolve<E extends Evolver, V extends Evolvable<E>>(transformations: E, obj: V): Evolve<V, E>;
599export function evolve<E extends Evolver>(transformations: E): <V extends Evolvable<E>>(obj: V) => Evolve<V, E>;
600
601/*
602* A function that always returns false. Any passed in parameters are ignored.
603*/
604export function F(): boolean;
605
606/**
607 * Returns a new list containing only those items that match a given predicate function. The predicate function is passed one argument: (value).
608 */
609export const filter: Filter;
610
611/**
612 * Returns the first element of the list which matches the predicate, or `undefined` if no
613 * element matches.
614 */
615export function find<T>(fn: (a: T) => boolean, list: readonly T[]): T | undefined;
616export function find<T>(fn: (a: T) => boolean): (list: readonly T[]) => T | undefined;
617
618/**
619 * Returns the index of the first element of the list which matches the predicate, or `-1`
620 * if no element matches.
621 */
622export function findIndex<T>(fn: (a: T) => boolean, list: readonly T[]): number;
623export function findIndex<T>(fn: (a: T) => boolean): (list: readonly T[]) => number;
624
625/**
626 * Returns the last element of the list which matches the predicate, or `undefined` if no
627 * element matches.
628 */
629export function findLast<T>(fn: (a: T) => boolean, list: readonly T[]): T | undefined;
630export function findLast<T>(fn: (a: T) => boolean): (list: readonly T[]) => T | undefined;
631
632/**
633 * Returns the index of the last element of the list which matches the predicate, or
634 * `-1` if no element matches.
635 */
636export function findLastIndex<T>(fn: (a: T) => boolean, list: readonly T[]): number;
637export function findLastIndex<T>(fn: (a: T) => boolean): (list: readonly T[]) => number;
638
639/**
640 * Returns a new list by pulling every item out of it (and all its sub-arrays) and putting
641 * them in a new array, depth-first.
642 */
643export function flatten<T extends readonly any[]>(list: T): _.T.Flatten<T>;
644
645/**
646 * Returns a new function much like the supplied one, except that the first two arguments'
647 * order is reversed.
648 */
649export function flip<T, U, TResult>(fn: (arg0: T, arg1: U) => TResult): (arg1: U, arg0?: T) => TResult;
650export function flip<F extends (...args: any) => any, P extends _.F.Parameters<F>>(fn: F): _.F.Curry<(...args: _.T.Merge<[P[1], P[0]], P>) => _.F.Return<F>>;
651
652/**
653 * Iterate over an input list, calling a provided function fn for each element in the list.
654 */
655export function forEach<T>(fn: (x: T) => void, list: readonly T[]): T[];
656export function forEach<T>(fn: (x: T) => void): (list: readonly T[]) => T[];
657export function forEach<T>(fn: (x: T) => void, list: readonly T[]): T[];
658export function forEach<T>(fn: (x: T) => void): (list: readonly T[]) => T[];
659
660/**
661 * Iterate over an input object, calling a provided function fn for each key and value in the object.
662 */
663export function forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void, obj: T): T;
664export function forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void): (obj: T) => T;
665
666/**
667 * Creates a new object out of a list key-value pairs.
668 */
669export function fromPairs<V>(pairs: Array<KeyValuePair<string, V>> | Array<KeyValuePair<number, V>>): { [index: string]: V };
670
671/**
672 * Splits a list into sublists stored in an object, based on the result of
673 * calling a String-returning function
674 * on each element, and grouping the results according to values returned.
675 */
676export function groupBy<T, K extends string = string>(fn: (a: T) => K, list: readonly T[]): Record<K, T[]>;
677export function groupBy<T, K extends string = string>(fn: (a: T) => K): (list: readonly T[]) => Record<K, T[]>;
678
679/**
680 * Takes a list and returns a list of lists where each sublist's elements are all "equal" according to the provided equality function
681 */
682export function groupWith<T>(fn: (x: T, y: T) => boolean): (list: readonly T[]) => T[][];
683export function groupWith<T>(fn: (x: T, y: T) => boolean, list: readonly T[]): T[][];
684export function groupWith<T>(fn: (x: T, y: T) => boolean, list: string): string[];
685
686/**
687 * Returns true if the first parameter is greater than the second.
688 */
689export function gt(__: Placeholder, b: number): (a: number) => boolean;
690export function gt(__: Placeholder): (b: number, a: number) => boolean;
691export function gt(a: number, b: number): boolean;
692export function gt(a: string, b: string): boolean;
693export function gt(a: number): (b: number) => boolean;
694
695/**
696 * Returns true if the first parameter is greater than or equal to the second.
697 */
698export function gte(__: Placeholder, b: number): (a: number) => boolean;
699export function gte(__: Placeholder): (b: number, a: number) => boolean;
700export function gte(a: number, b: number): boolean;
701export function gte(a: string, b: string): boolean;
702export function gte(a: number): (b: number) => boolean;
703
704/**
705 * Returns whether or not an object has an own property with the specified name.
706 */
707export function has(__: Placeholder, obj: unknown): (s: string) => boolean;
708export function has(__: Placeholder): <P extends string>(obj: unknown, s: P) => obj is ObjectHavingSome<P>;
709export function has<P extends string>(s: P, obj: unknown): obj is ObjectHavingSome<P>;
710export function has<P extends string>(s: P): (obj: unknown) => obj is ObjectHavingSome<P>;
711
712/**
713 * Returns whether or not an object or its prototype chain has a property with the specified name
714 */
715export function hasIn<T>(s: string, obj: T): boolean;
716export function hasIn(s: string): <T>(obj: T) => boolean;
717
718/**
719 * Returns whether or not a path exists in an object. Only the object's own properties are checked.
720 */
721export function hasPath<T>(list: readonly string[], obj: T): boolean;
722export function hasPath(list: readonly string[]): <T>(obj: T) => boolean;
723
724/**
725 * Returns the first element in a list.
726 * In some libraries this function is named `first`.
727 */
728export function head(str: string): string;
729export function head(list: readonly []): undefined;
730export function head<T extends any>(list: readonly T[]): T | undefined;
731
732/**
733 * Returns true if its arguments are identical, false otherwise. Values are identical if they reference the
734 * same memory. NaN is identical to NaN; 0 and -0 are not identical.
735 */
736export function identical<T>(a: T, b: T): boolean;
737export function identical<T>(a: T): (b: T) => boolean;
738
739/**
740 * A function that does nothing but return the parameter supplied to it. Good as a default
741 * or placeholder function.
742 */
743export function identity<T>(a: T): T;
744
745/**
746 * Creates a function that will process either the onTrue or the onFalse function depending upon the result
747 * of the condition predicate.
748 */
749export function ifElse(fn: Pred, onTrue: Arity1Fn, onFalse: Arity1Fn): Arity1Fn;
750export function ifElse(fn: Pred, onTrue: Arity2Fn, onFalse: Arity2Fn): Arity2Fn;
751
752/**
753 * Increments its argument.
754 */
755export function inc(n: number): number;
756
757/**
758 * Given a target, this function checks a list for the target and returns a boolean.
759 * Given a string, this function checks for the string in another string or list and returns
760 * a boolean.
761 */
762export function includes(__: Placeholder, list: readonly string[] | string): (s: string) => boolean;
763export function includes<T>(__: Placeholder, list: readonly T[]): (target: T) => boolean;
764export function includes(__: Placeholder): (list: readonly string[] | string, s: string) => boolean;
765export function includes<T>(__: Placeholder): (list: readonly T[], target: T) => boolean;
766export function includes(s: string, list: readonly string[] | string): boolean;
767export function includes(s: string): (list: readonly string[] | string) => boolean;
768export function includes<T>(target: T, list: readonly T[]): boolean;
769export function includes<T>(target: T): (list: readonly T[]) => boolean;
770
771/**
772 * Given a function that generates a key, turns a list of objects into an object indexing the objects
773 * by the given key.
774 */
775export function indexBy<T, K extends string | number = string>(fn: (a: T) => K, list: readonly T[]): { [key in K]: T };
776export function indexBy<T, K extends string | number | undefined = string>(fn: (a: T) => K, list: readonly T[]): { [key in NonNullable<K>]?: T };
777export function indexBy<T, K extends string | number = string>(fn: (a: T) => K): (list: readonly T[]) => { [key in K]: T };
778export function indexBy<T, K extends string | number | undefined = string>(fn: (a: T) => K | undefined): (list: readonly T[]) => { [key in NonNullable<K>]?: T };
779
780/**
781 * Returns the position of the first occurrence of an item in an array
782 * (by strict equality),
783 * or -1 if the item is not included in the array.
784 */
785export function indexOf<T>(target: T, list: readonly T[]): number;
786export function indexOf<T>(target: T): (list: readonly T[]) => number;
787
788/**
789 * Returns all but the last element of a list or string.
790 */
791export function init<T>(list: readonly T[]): T[];
792export function init(list: string): string;
793
794/**
795 * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list
796 * `xs'` comprising each of the elements of `xs` which is equal to one or more
797 * elements of `ys` according to `pred`.
798 *
799 * `pred` must be a binary function expecting an element from each list.
800 *
801 * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should
802 * not be significant, but since `xs'` is ordered the implementation guarantees
803 * that its values are in the same order as they appear in `xs`. Duplicates are
804 * not removed, so `xs'` may contain duplicates if `xs` contains duplicates.
805 */
806
807export function innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[], list2: readonly T2[]): T1[];
808export function innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean): (list1: readonly T1[], list2: readonly T2[]) => T1[];
809export function innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[]): (list2: readonly T2[]) => T1[];
810
811/**
812 * Inserts the supplied element into the list, at index index. Note that
813 * this is not destructive: it returns a copy of the list with the changes.
814 */
815export function insert<T>(index: number, elt: T, list: readonly T[]): T[];
816export function insert<T>(index: number, elt: T): (list: readonly T[]) => T[];
817export function insert(index: number): <T>(elt: T, list: readonly T[]) => T[];
818
819/**
820 * Inserts the sub-list into the list, at index `index`. _Note that this
821 * is not destructive_: it returns a copy of the list with the changes.
822 */
823export function insertAll<T>(index: number, elts: readonly T[], list: readonly T[]): T[];
824export function insertAll<T>(index: number, elts: readonly T[]): (list: readonly T[]) => T[];
825export function insertAll(index: number): <T>(elts: readonly T[], list: readonly T[]) => T[];
826
827/**
828 * Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.
829 */
830export function intersection<T>(list1: readonly T[], list2: readonly T[]): T[];
831export function intersection<T>(list1: readonly T[]): (list2: readonly T[]) => T[];
832
833/**
834 * Creates a new list with the separator interposed between elements.
835 */
836export function intersperse<T>(separator: T, list: readonly T[]): T[];
837export function intersperse<T>(separator: T): (list: readonly T[]) => T[];
838
839/**
840 * Transforms the items of the list with the transducer and appends the transformed items to the accumulator
841 * using an appropriate iterator function based on the accumulator type.
842 */
843export function into<T>(acc: any, xf: (...a: readonly any[]) => any, list: readonly T[]): T[];
844export function into<T, R>(acc: any, xf: (...a: readonly any[]) => R[], list: readonly T[]): R[];
845export function into(acc: any, xf: (...a: readonly any[]) => any): <T>(list: readonly T[]) => T[];
846export function into(acc: any): <T>(xf: (...a: readonly any[]) => any, list: readonly T[]) => T[];
847
848/**
849 * Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array.
850 */
851export function invert<T>(obj: T): { [index: string]: string[] };
852
853/**
854 * Returns a new object with the keys of the given object as values, and the values of the given object as keys.
855 */
856export function invertObj(obj: { [index: string]: string } | { [index: number]: string }): { [index: string]: string };
857
858/**
859 * Turns a named method with a specified arity into a function that can be called directly
860 * supplied with arguments and a target object.
861 *
862 * The returned function is curried and accepts `arity + 1` parameters where the final
863 * parameter is the target object.
864 */
865export function invoker(arity: number, method: string): (...a: readonly any[]) => any;
866
867/**
868 * See if an object (`val`) is an instance of the supplied constructor.
869 * This function will check up the inheritance chain, if any.
870 */
871export function is(ctor: any, val: any): boolean;
872export function is(ctor: any): (val: any) => boolean;
873
874/**
875 * Reports whether the list has zero elements.
876 */
877export function isEmpty(value: any): boolean;
878
879/**
880 * Checks if the input value is null or undefined.
881 */
882export function isNil(value: any): value is null | undefined;
883
884/**
885 * Returns a string made by inserting the `separator` between each
886 * element and concatenating all the elements into a single string.
887 */
888export function join(x: string, xs: readonly any[]): string;
889export function join(x: string): (xs: readonly any[]) => string;
890
891/**
892 * Applies a list of functions to a list of values.
893 */
894export function juxt<A extends any[], R1, R2>(fns: [(...a: A) => R1, (...a: A) => R2]): (...a: A) => [R1, R2];
895export function juxt<A extends any[], R1, R2, R3>(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3]): (...a: A) => [R1, R2, R3];
896export function juxt<A extends any[], R1, R2, R3, R4>(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3, (...a: A) => R4]): (...a: A) => [R1, R2, R3, R4];
897export function juxt<A extends any[], R1, R2, R3, R4, R5>(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3, (...a: A) => R4, (...a: A) => R5]): (...a: A) => [R1, R2, R3, R4, R5];
898export function juxt<A extends any[], U>(fns: Array<(...args: A) => U>): (...args: A) => U[];
899
900/**
901 * Returns a list containing the names of all the enumerable own
902 * properties of the supplied object.
903 */
904export function keys<T extends object>(x: T): Array<keyof T>;
905export function keys<T>(x: T): string[];
906
907/**
908 * Returns a list containing the names of all the
909 * properties of the supplied object, including prototype properties.
910 */
911export function keysIn<T>(obj: T): string[];
912
913/**
914 * Returns the last element from a list.
915 */
916export function last(str: string): string;
917export function last(list: readonly []): undefined;
918export function last<T extends any>(list: readonly T[]): T | undefined;
919
920/**
921 * Returns the position of the last occurrence of an item (by strict equality) in
922 * an array, or -1 if the item is not included in the array.
923 */
924export function lastIndexOf<T>(target: T, list: readonly T[]): number;
925
926/**
927 * Returns the number of elements in the array by returning list.length.
928 */
929export function length<T>(list: readonly T[]): number;
930
931/**
932 * Returns a lens for the given getter and setter functions. The getter
933 * "gets" the value of the focus; the setter "sets" the value of the focus.
934 * The setter should not mutate the data structure.
935 */
936export function lens<S, A>(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens<S, A>;
937
938/**
939 * Creates a lens that will focus on index n of the source array.
940 */
941export function lensIndex<A>(n: number): Lens<A[], A>;
942export function lensIndex<A extends any[], N extends number>(n: N): Lens<A, A[N]>;
943
944/**
945 * Returns a lens whose focus is the specified path.
946 * See also view, set, over.
947 */
948export function lensPath<S, K0 extends keyof S = keyof S>(path: [K0]): Lens<S, S[K0]>;
949export function lensPath<S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0]>(path: [K0, K1]): Lens<S, S[K0][K1]>;
950export function lensPath<
951 S,
952 K0 extends keyof S = keyof S,
953 K1 extends keyof S[K0] = keyof S[K0],
954 K2 extends keyof S[K0][K1] = keyof S[K0][K1]
955>(
956 path: [K0, K1, K2]
957): Lens<S, S[K0][K1][K2]>;
958export function lensPath<
959 S,
960 K0 extends keyof S = keyof S,
961 K1 extends keyof S[K0] = keyof S[K0],
962 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
963 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
964>(
965 path: [K0, K1, K2, K3]
966): Lens<S, S[K0][K1][K2][K3]>;
967export function lensPath<
968 S,
969 K0 extends keyof S = keyof S,
970 K1 extends keyof S[K0] = keyof S[K0],
971 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
972 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
973 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
974>(
975 path: [K0, K1, K2, K3, K4]
976): Lens<S, S[K0][K1][K2][K3][K4]>;
977export function lensPath<
978 S,
979 K0 extends keyof S = keyof S,
980 K1 extends keyof S[K0] = keyof S[K0],
981 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
982 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
983 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
984 K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4],
985>(
986 path: [K0, K1, K2, K3, K4, K5]
987): Lens<S, S[K0][K1][K2][K3][K4][K5]>;
988
989export function lensPath<S = any, A = any>(path: Path): Lens<S, A>;
990
991/**
992 * lensProp creates a lens that will focus on property k of the source object.
993 */
994export function lensProp<S, K extends keyof S = keyof S>(prop: K): Lens<S, S[K]>;
995
996/**
997 * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other object that satisfies
998 * the FantasyLand Apply spec.
999 */
1000export function lift(fn: ((...a: readonly any[]) => any), ...args: readonly any[]): any;
1001
1002/**
1003 * "lifts" a function to be the specified arity, so that it may "map over" that many lists, Functions or other
1004 * objects that satisfy the FantasyLand Apply spec.
1005 */
1006export function liftN(n: number, fn: ((...a: readonly any[]) => any), ...args: readonly any[]): any;
1007
1008/**
1009 * Returns true if the first parameter is less than the second.
1010 */
1011export function lt(__: Placeholder, b: number): (a: number) => boolean;
1012export function lt(__: Placeholder): (b: number, a: number) => boolean;
1013export function lt(a: number, b: number): boolean;
1014export function lt(a: string, b: string): boolean;
1015export function lt(a: number): (b: number) => boolean;
1016
1017/**
1018 * Returns true if the first parameter is less than or equal to the second.
1019 */
1020export function lte(__: Placeholder, b: number): (a: number) => boolean;
1021export function lte(__: Placeholder): (b: number, a: number) => boolean;
1022export function lte(a: number, b: number): boolean;
1023export function lte(a: string, b: string): boolean;
1024export function lte(a: number): (b: number) => boolean;
1025
1026/**
1027 * Returns a new list, constructed by applying the supplied function to every element of the supplied list.
1028 */
1029export function map<T, U>(fn: (x: T) => U, list: readonly T[]): U[];
1030export function map<T, U>(fn: (x: T) => U): (list: readonly T[]) => U[];
1031export function map<T, U>(fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U], list: T): U;
1032export function map<T, U>(fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U]): (list: T) => U;
1033export function map<T, U>(fn: (x: T) => U, obj: Functor<T>): Functor<U>; // used in functors
1034export function map<T, U>(fn: (x: T) => U): (obj: Functor<T>) => Functor<U>; // used in functors
1035
1036/**
1037 * The mapAccum function behaves like a combination of map and reduce.
1038 */
1039export function mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U, list: readonly T[]): [U, TResult[]];
1040export function mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: readonly T[]) => [U, TResult[]];
1041export function mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: readonly T[]) => [U, TResult[]];
1042
1043/**
1044 * The mapAccumRight function behaves like a combination of map and reduce.
1045 */
1046export function mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U, list: readonly T[]): [U, TResult[]];
1047export function mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: readonly T[]) => [U, TResult[]];
1048export function mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: readonly T[]) => [U, TResult[]];
1049
1050/**
1051 * Like mapObj, but but passes additional arguments to the predicate function.
1052 */
1053type PartialRecord<K extends keyof any, T> = {
1054 [P in K]?: T;
1055};
1056export function mapObjIndexed<T, TResult, TKey extends string>(
1057 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult,
1058 obj: Record<TKey, T>
1059): Record<TKey, TResult>;
1060export function mapObjIndexed<T, TResult, TKey extends string>(
1061 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult,
1062 obj: PartialRecord<TKey, T>
1063): PartialRecord<TKey, TResult>;
1064export function mapObjIndexed<T, TResult, TKey extends string>(
1065 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult
1066): (obj: Record<TKey, T>) => Record<TKey, TResult>;
1067export function mapObjIndexed<T, TResult, TKey extends string>(
1068 fn: (value: T, key: TKey, obj?: PartialRecord<TKey, T>) => TResult
1069): (obj: Record<TKey, T>) => PartialRecord<TKey, TResult>;
1070export function mapObjIndexed<T, TResult>(
1071 fn: (value: T, key: string, obj?: {
1072 [key: string]: T
1073 }) => TResult,
1074 obj: {
1075 [key: string]: T
1076 }
1077): {
1078 [key: string]: TResult
1079};
1080/**
1081 * Tests a regular expression agains a String
1082 */
1083export function match(regexp: RegExp, str: string): string[];
1084export function match(regexp: RegExp): (str: string) => string[];
1085
1086/**
1087 * mathMod behaves like the modulo operator should mathematically, unlike the `%`
1088 * operator (and by extension, R.modulo). So while "-17 % 5" is -2,
1089 * mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN
1090 * when the modulus is zero or negative.
1091 */
1092export function mathMod(__: Placeholder, b: number): (a: number) => number;
1093export function mathMod(__: Placeholder): (b: number, a: number) => number;
1094export function mathMod(a: number, b: number): number;
1095export function mathMod(a: number): (b: number) => number;
1096
1097/**
1098 * Returns the larger of its two arguments.
1099 */
1100export function max<T extends Ord>(a: T, b: T): T;
1101export function max<T extends Ord>(a: T): (b: T) => T;
1102
1103/**
1104 * Takes a function and two values, and returns whichever value produces
1105 * the larger result when passed to the provided function.
1106 */
1107export function maxBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T;
1108export function maxBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T;
1109export function maxBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>;
1110
1111/**
1112 * Returns the mean of the given list of numbers.
1113 */
1114export function mean(list: readonly number[]): number;
1115
1116/**
1117 * Returns the median of the given list of numbers.
1118 */
1119export function median(list: readonly number[]): number;
1120
1121/**
1122 * Creates a new function that, when invoked, caches the result of calling fn for a given argument set and returns the result.
1123 * Subsequent calls to the memoized fn with the same argument set will not result in an additional call to fn; instead, the cached result for that set of arguments will be returned.
1124 */
1125export function memoizeWith<T extends (...args: readonly any[]) => any>(keyFn: (...v: Parameters<T>) => string, fn: T): T;
1126
1127/**
1128 * Create a new object with the own properties of a
1129 * merged with the own properties of object b.
1130 * This function will *not* mutate passed-in objects.
1131 *
1132 * @deprecated since 0.26 in favor of mergeRight
1133 */
1134export function merge<O2 extends object>(__: Placeholder, b: O2): <O1 extends object>(a: O1) => Merge<O2, O1, 'flat'>;
1135export function merge(__: Placeholder): <O1 extends object, O2 extends object>(b: O2, a: O1) => Merge<O2, O1, 'flat'>;
1136export function merge<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O2, O1, 'flat'>;
1137export function merge<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O2, O1, 'flat'>;
1138
1139/**
1140 * Merges a list of objects together into one object.
1141 */
1142export function mergeAll<Os extends readonly object[]>(list: Os): MergeAll<Os>;
1143/**
1144 * Creates a new object with the own properties of the first object merged with the own properties of the second object.
1145 * If a key exists in both objects:
1146 * and both values are objects, the two values will be recursively merged
1147 * otherwise the value from the first object will be used.
1148 */
1149export function mergeDeepLeft<O1 extends object, O2 extends object>(o1: O1, o2: O2): Merge<O1, O2, 'deep'>;
1150export function mergeDeepLeft<O1 extends object>(o1: O1): <O2 extends object>(o2: O2) => Merge<O1, O2, 'deep'>;
1151
1152/**
1153 * Creates a new object with the own properties of the first object merged with the own properties of the second object.
1154 * If a key exists in both objects:
1155 * and both values are objects, the two values will be recursively merged
1156 * otherwise the value from the second object will be used.
1157 */
1158export function mergeDeepRight<O1 extends object, O2 extends object>(o1: O1, o2: O2): Merge<O2, O1, 'deep'>;
1159export function mergeDeepRight<O1 extends object>(a: O1): <O2 extends object>(o2: O2) => Merge<O2, O1, 'deep'>;
1160
1161/**
1162 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects:
1163 * and both associated values are also objects then the values will be recursively merged.
1164 * otherwise the provided function is applied to associated values using the resulting value as the new value
1165 * associated with the key. If a key only exists in one object, the value will be associated with the key of the resulting object.
1166 */
1167export function mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any, a: T1, b: T2): any;
1168export function mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any, a: T1): (b: T2) => any;
1169export function mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any): (a: T1, b: T2) => any;
1170
1171/**
1172 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects:
1173 * and both associated values are also objects then the values will be recursively merged.
1174 * otherwise the provided function is applied to the key and associated values using the resulting value as
1175 * the new value associated with the key. If a key only exists in one object, the value will be associated with
1176 * the key of the resulting object.
1177 */
1178export function mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any, a: T1, b: T2): any;
1179export function mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any, a: T1): (b: T2) => any;
1180export function mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any): (a: T1, b: T2) => any;
1181
1182/**
1183 * Create a new object with the own properties of the first object merged with the own properties of the second object.
1184 * If a key exists in both objects, the value from the first object will be used.
1185 */
1186export function mergeLeft<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O1, O2, 'flat'>;
1187export function mergeLeft<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O1, O2, 'flat'>;
1188
1189/**
1190 * Create a new object with the own properties of the first object merged with the own properties of the second object.
1191 * If a key exists in both objects, the value from the second object will be used.
1192 */
1193export function mergeRight<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O2, O1, 'flat'>;
1194export function mergeRight<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O2, O1, 'flat'>;
1195
1196/**
1197 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects,
1198 * the provided function is applied to the values associated with the key in each object, with the result being used as
1199 * the value associated with the key in the returned object. The key will be excluded from the returned object if the
1200 * resulting value is undefined.
1201 */
1202export function mergeWith<U, V>(fn: (x: any, z: any) => any, a: U, b: V): any;
1203export function mergeWith<U>(fn: (x: any, z: any) => any, a: U): <V>(b: V) => any;
1204export function mergeWith(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => any;
1205
1206/**
1207 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects,
1208 * the provided function is applied to the key and the values associated with the key in each object, with the
1209 * result being used as the value associated with the key in the returned object. The key will be excluded from
1210 * the returned object if the resulting value is undefined.
1211 */
1212export function mergeWithKey<U, V>(fn: (str: string, x: any, z: any) => any, a: U, b: V): any;
1213export function mergeWithKey<U>(fn: (str: string, x: any, z: any) => any, a: U): <V>(b: V) => any;
1214export function mergeWithKey(fn: (str: string, x: any, z: any) => any): <U, V>(a: U, b: V) => any;
1215
1216/**
1217 * Returns the smaller of its two arguments.
1218 */
1219export function min<T extends Ord>(a: T, b: T): T;
1220export function min<T extends Ord>(a: T): (b: T) => T;
1221
1222/**
1223 * Takes a function and two values, and returns whichever value produces
1224 * the smaller result when passed to the provided function.
1225 */
1226export function minBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T;
1227export function minBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T;
1228export function minBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>;
1229
1230/**
1231 * Divides the second parameter by the first and returns the remainder.
1232 * The flipped version (`moduloBy`) may be more useful curried.
1233 * Note that this functions preserves the JavaScript-style behavior for
1234 * modulo. For mathematical modulo see `mathMod`
1235 */
1236export function modulo(__: Placeholder, b: number): (a: number) => number;
1237export function modulo(__: Placeholder): (b: number, a: number) => number;
1238export function modulo(a: number, b: number): number;
1239export function modulo(a: number): (b: number) => number;
1240
1241/**
1242 * Multiplies two numbers. Equivalent to a * b but curried.
1243 */
1244export function multiply(a: number, b: number): number;
1245export function multiply(a: number): (b: number) => number;
1246
1247/**
1248 * Moves an item, at index `from`, to index `to`, in a `list` of elements.
1249 * A new list will be created containing the new elements order.
1250 */
1251export function move<T>(from: number, to: number, list: readonly T[]): T[];
1252export function move(from: number, to: number): <T>(list: readonly T[]) => T[];
1253export function move(from: number): {
1254 <T>(to: number, list: readonly T[]): T[];
1255 (to: number): <T>(list: readonly T[]) => T[];
1256};
1257
1258/**
1259 * Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters.
1260 * Any extraneous parameters will not be passed to the supplied function.
1261 */
1262export function nAry<N extends number, T extends (...arg: any) => any>(n: N, fn: T): (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>;
1263export function nAry<N extends number>(n: N): <T extends (...arg: any) => any>(fn: T) => (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>;
1264
1265/**
1266 * Negates its argument.
1267 */
1268export function negate(n: number): number;
1269
1270/**
1271 * Returns true if no elements of the list match the predicate, false otherwise.
1272 */
1273export function none<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
1274export function none<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
1275
1276/**
1277 * A function that returns the ! of its argument.
1278 * It will return true when passed false-y value, and false when passed a truth-y one.
1279 */
1280export function not(value: any): boolean;
1281
1282/**
1283 * Returns the nth element in a list.
1284 */
1285export function nth<T>(n: number, list: readonly T[]): T | undefined;
1286export function nth(n: number): <T>(list: readonly T[]) => T | undefined;
1287
1288/**
1289 * Returns a function which returns its nth argument.
1290 */
1291export function nthArg(n: number): (...a: readonly any[]) => any;
1292
1293/**
1294 * o is a curried composition function that returns a unary function. Like compose, o performs right-to-left function composition.
1295 * Unlike compose, the rightmost function passed to o will be invoked with only one argument.
1296 * Also, unlike compose, o is limited to accepting only 2 unary functions.
1297 * The name o was chosen because of its similarity to the mathematical composition operator ∘.
1298 */
1299export function o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2, v: T1): R;
1300export function o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2): (v: T1) => R;
1301export function o<T2, R>(
1302 f: (x: T2) => R,
1303): {
1304 <T1>(g: (x: T1) => T2, v: T1): R;
1305 <T1>(g: (x: T1) => T2): (v: T1) => R;
1306};
1307
1308/**
1309 * Creates an object containing a single key:value pair.
1310 */
1311export function objOf<T, K extends string>(key: K, value: T): Record<K, T>;
1312export function objOf<K extends string>(key: K): <T>(value: T) => Record<K, T>;
1313
1314/**
1315 * Returns a singleton array containing the value provided.
1316 */
1317export function of<T>(x: T): T[];
1318
1319/**
1320 * Returns a partial copy of an object omitting the keys specified.
1321 */
1322export function omit<T, K extends string>(names: readonly K[], obj: T): Omit<T, K>;
1323export function omit<K extends string>(names: readonly K[]): <T>(obj: T) => Omit<T, K>;
1324
1325/**
1326 * Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be
1327 * called once, no matter how many times the returned function is invoked. The first value calculated is
1328 * returned in subsequent invocations.
1329 */
1330export function once<F extends (...a: readonly any[]) => any>(fn: F): F;
1331
1332/**
1333 * A function that returns the first truthy of two arguments otherwise the last argument. Note that this is
1334 * NOT short-circuited, meaning that if expressions are passed they are both evaluated.
1335 * Dispatches to the or method of the first argument if applicable.
1336 */
1337export function or<T, U>(a: T, b: U): T | U;
1338export function or<T>(a: T): <U>(b: U) => T | U;
1339export function or<T extends { or?: ((...a: readonly any[]) => any) | undefined; }, U>(fn1: T, val2: U): T | U;
1340export function or<T extends { or?: ((...a: readonly any[]) => any) | undefined; }>(fn1: T): <U>(val2: U) => T | U;
1341
1342/**
1343 * Returns the result of applying the onFailure function to the value inside a failed promise.
1344 * This is useful for handling rejected promises inside function compositions.
1345 */
1346export function otherwise<A, B>(onError: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<B>;
1347export function otherwise<A, B>(onError: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<B>;
1348
1349/**
1350 * Returns the result of "setting" the portion of the given data structure
1351 * focused by the given lens to the given value.
1352 */
1353export function over<S, A>(lens: Lens<S, A>, fn: (a: A) => A, value: S): S;
1354export function over<S, A>(lens: Lens<S, A>, fn: (a: A) => A): (value: S) => S;
1355export function over<S, A>(lens: Lens<S, A>): (fn: (a: A) => A, value: S) => S;
1356
1357/**
1358 * Takes two arguments, fst and snd, and returns [fst, snd].
1359 */
1360export function pair<F, S>(fst: F, snd: S): [F, S];
1361export function pair<F>(fst: F): <S>(snd: S) => [F, S];
1362
1363/**
1364 * Takes a function `f` and a list of arguments, and returns a function `g`.
1365 * When applied, `g` returns the result of applying `f` to the arguments
1366 * provided initially followed by the arguments provided to `g`.
1367 */
1368export function partial<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T;
1369
1370export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0, V1]): (x2: V2) => T;
1371export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0]): (x1: V1, x2: V2) => T;
1372
1373export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1, V2]): (x2: V3) => T;
1374export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1]): (x2: V2, x3: V3) => T;
1375export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0]): (x1: V1, x2: V2, x3: V3) => T;
1376
1377export function partial<T>(fn: (...a: readonly any[]) => T, args: readonly any[]): (...a: readonly any[]) => T;
1378
1379/**
1380 * Takes a function `f` and a list of arguments, and returns a function `g`.
1381 * When applied, `g` returns the result of applying `f` to the arguments
1382 * provided to `g` followed by the arguments provided initially.
1383 */
1384export function partialRight<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V1]): (x1: V0) => T;
1385
1386export function partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V1, V2]): (x2: V0) => T;
1387export function partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V2]): (x1: V0, x2: V1) => T;
1388
1389export function partialRight<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V1, V2, V3]): (x0: V0) => T;
1390export function partialRight<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V2, V3]): (x0: V0, x1: V1) => T;
1391export function partialRight<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V3]): (x0: V0, x1: V1, x2: V2) => T;
1392
1393export function partialRight<T>(fn: (...a: readonly any[]) => T, args: readonly any[]): (...a: readonly any[]) => T;
1394
1395/**
1396 * Takes a predicate and a list and returns the pair of lists of elements
1397 * which do and do not satisfy the predicate, respectively.
1398 */
1399export function partition(fn: (a: string) => boolean, list: readonly string[]): [string[], string[]];
1400export function partition<T>(fn: (a: T) => boolean, list: readonly T[]): [T[], T[]];
1401export function partition<T>(fn: (a: T) => boolean): (list: readonly T[]) => [T[], T[]];
1402export function partition(fn: (a: string) => boolean): (list: readonly string[]) => [string[], string[]];
1403
1404/**
1405 * Retrieve the value at a given path.
1406 */
1407export function path<T>(path: Path, obj: any): T | undefined;
1408export function path<T>(path: Path): (obj: any) => T | undefined;
1409
1410/**
1411 * Determines whether a nested path on an object has a specific value,
1412 * in `R.equals` terms. Most likely used to filter a list.
1413 */
1414export function pathEq(path: Path, val: any, obj: any): boolean;
1415export function pathEq(path: Path, val: any): (obj: any) => boolean;
1416export function pathEq(path: Path): _.F.Curry<(a: any, b: any) => boolean>;
1417
1418/**
1419 * If the given, non-null object has a value at the given path, returns the value at that path.
1420 * Otherwise returns the provided default value.
1421 */
1422export function pathOr<T>(defaultValue: T, path: Path, obj: any): T;
1423export function pathOr<T>(defaultValue: T, path: Path): (obj: any) => T;
1424export function pathOr<T>(defaultValue: T): _.F.Curry<(a: Path, b: any) => T>;
1425
1426/**
1427 * Retrieves the values at given paths of an object.
1428 */
1429export function paths<T>(paths: Path[], obj: any): Array<T | undefined>;
1430export function paths<T>(paths: Path[]): (obj: any) => Array<T | undefined>;
1431
1432/**
1433 * Returns true if the specified object property at given path satisfies the given predicate; false otherwise.
1434 */
1435export function pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path, obj: U): boolean;
1436export function pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path): (obj: U) => boolean;
1437export function pathSatisfies<T, U>(pred: (val: T) => boolean): _.F.Curry<(a: Path, b: U) => boolean>;
1438
1439/**
1440 * Returns a partial copy of an object containing only the keys specified. If the key does not exist, the
1441 * property is ignored.
1442 */
1443export function pick<T, K extends string | number | symbol>(names: readonly K[], obj: T): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
1444export function pick<K extends string | number | symbol>(names: readonly K[]): <T>(obj: T) => Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
1445
1446/**
1447 * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist.
1448 */
1449export function pickAll<T, U>(names: readonly string[], obj: T): U;
1450export function pickAll(names: readonly string[]): <T, U>(obj: T) => U;
1451
1452/**
1453 * Returns a partial copy of an object containing only the keys that satisfy the supplied predicate.
1454 */
1455export function pickBy<T, U>(pred: ObjPred<T>, obj: T): U;
1456export function pickBy<T>(pred: ObjPred<T>): <U, V extends T>(obj: V) => U;
1457
1458/**
1459 * Creates a new function that runs each of the functions supplied as parameters in turn,
1460 * passing the return value of each function invocation to the next function invocation,
1461 * beginning with whatever arguments were passed to the initial invocation.
1462 */
1463// tslint:disable:max-line-length
1464export function pipe<T1>(fn0: () => T1): () => T1;
1465export function pipe<V0, T1>(fn0: (x0: V0) => T1): (x0: V0) => T1;
1466export function pipe<V0, V1, T1>(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1;
1467export function pipe<V0, V1, V2, T1>(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1;
1468
1469export function pipe<T1, T2>(fn0: () => T1, fn1: (x: T1) => T2): () => T2;
1470export function pipe<V0, T1, T2>(fn0: (x0: V0) => T1, fn1: (x: T1) => T2): (x0: V0) => T2;
1471export function pipe<V0, V1, T1, T2>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1) => T2;
1472export function pipe<V0, V1, V2, T1, T2>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1, x2: V2) => T2;
1473
1474export function pipe<T1, T2, T3>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): () => T3;
1475export function pipe<V0, T1, T2, T3>(fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x: V0) => T3;
1476export function pipe<V0, V1, T1, T2, T3>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1) => T3;
1477export function pipe<V0, V1, V2, T1, T2, T3>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1, x2: V2) => T3;
1478
1479export function pipe<T1, T2, T3, T4>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): () => T4;
1480export function pipe<V0, T1, T2, T3, T4>(fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x: V0) => T4;
1481export function pipe<V0, V1, T1, T2, T3, T4>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1) => T4;
1482export function pipe<V0, V1, V2, T1, T2, T3, T4>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1, x2: V2) => T4;
1483
1484export function pipe<T1, T2, T3, T4, T5>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): () => T5;
1485export function pipe<V0, T1, T2, T3, T4, T5>(fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x: V0) => T5;
1486export function pipe<V0, V1, T1, T2, T3, T4, T5>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1) => T5;
1487export function pipe<V0, V1, V2, T1, T2, T3, T4, T5>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1, x2: V2) => T5;
1488
1489export function pipe<T1, T2, T3, T4, T5, T6>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): () => T6;
1490export function pipe<V0, T1, T2, T3, T4, T5, T6>(fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x: V0) => T6;
1491export function pipe<V0, V1, T1, T2, T3, T4, T5, T6>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1) => T6;
1492export function pipe<V0, V1, V2, T1, T2, T3, T4, T5, T6>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1, x2: V2) => T6;
1493
1494export function pipe<T1, T2, T3, T4, T5, T6, T7>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn: (x: T6) => T7): () => T7;
1495export function pipe<V0, T1, T2, T3, T4, T5, T6, T7>(fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn: (x: T6) => T7): (x: V0) => T7;
1496export function pipe<V0, V1, T1, T2, T3, T4, T5, T6, T7>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1) => T7;
1497export function pipe<V0, V1, V2, T1, T2, T3, T4, T5, T6, T7>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1, x2: V2) => T7;
1498
1499export function pipe<T1, T2, T3, T4, T5, T6, T7, T8>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn: (x: T7) => T8): () => T8;
1500export function pipe<V0, T1, T2, T3, T4, T5, T6, T7, T8>(fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn: (x: T7) => T8): (x: V0) => T8;
1501export function pipe<V0, V1, T1, T2, T3, T4, T5, T6, T7, T8>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1) => T8;
1502export function pipe<V0, V1, V2, T1, T2, T3, T4, T5, T6, T7, T8>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1, x2: V2) => T8;
1503
1504export function pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): () => T9;
1505export function pipe<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0) => T9;
1506export function pipe<V0, V1, T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1) => T9;
1507export function pipe<V0, V1, V2, T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1, x2: V2) => T9;
1508
1509export function pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9, fn9: (x: T9) => T10): () => T10;
1510export function pipe<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9, fn9: (x: T9) => T10): (x0: V0) => T10;
1511export function pipe<V0, V1, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9, fn9: (x: T9) => T10): (x0: V0, x1: V1) => T10;
1512export function pipe<V0, V1, V2, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9, fn9: (x: T9) => T10): (x0: V0, x1: V1, x2: V2) => T10;
1513// tslint:enable:max-line-length
1514
1515/**
1516 * Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain.
1517 * The typings currently support arrays only as return values.
1518 * All functions need to be unary.
1519 * R.pipeK(f, g, h) is equivalent to R.pipe(f, R.chain(g), R.chain(h)).
1520 *
1521 * @deprecated since 0.26 in favor of pipeWith(chain)
1522 */
1523// tslint:disable:max-line-length
1524export function pipeK<V0, T1>(fn0: (x0: V0) => T1[]): (x0: V0) => T1[];
1525export function pipeK<V0, T1, T2>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[]): (x0: V0) => T2[];
1526export function pipeK<V0, T1, T2, T3>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[]): (x: V0) => T3[];
1527export function pipeK<V0, T1, T2, T3, T4>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[]): (x: V0) => T4[];
1528export function pipeK<V0, T1, T2, T3, T4, T5>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[]): (x: V0) => T5[];
1529export function pipeK<V0, T1, T2, T3, T4, T5, T6>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[]): (x: V0) => T6[];
1530export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn: (x: T6) => T7[]): (x: V0) => T7[];
1531export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn6: (x: T6) => T7[], fn: (x: T7) => T8[]): (x: V0) => T8[];
1532export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn6: (x: T6) => T7[], fn7: (x: T7) => T8[], fn8: (x: T8) => T9[]): (x0: V0) => T9[];
1533export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn6: (x: T6) => T7[], fn7: (x: T7) => T8[], fn8: (x: T8) => T9[], fn9: (x: T9) => T10[]): (x0: V0) => T10[];
1534// tslint:enable:max-line-length
1535
1536/**
1537 * Performs left-to-right composition of one or more Promise-returning functions.
1538 * All functions need to be unary.
1539 *
1540 * @deprecated since 0.26 in favor of pipeWith(then)
1541 */
1542// tslint:disable:max-line-length
1543export function pipeP<V0, T1>(fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T1>;
1544export function pipeP<V0, T1, T2>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>): (x0: V0) => Promise<T2>;
1545export function pipeP<V0, T1, T2, T3>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>): (x: V0) => Promise<T3>;
1546export function pipeP<V0, T1, T2, T3, T4>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>): (x: V0) => Promise<T4>;
1547export function pipeP<V0, T1, T2, T3, T4, T5>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>): (x: V0) => Promise<T5>;
1548export function pipeP<V0, T1, T2, T3, T4, T5, T6>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>): (x: V0) => Promise<T6>;
1549export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn: (x: T6) => Promise<T7>): (x: V0) => Promise<T7>;
1550export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn6: (x: T6) => Promise<T7>, fn: (x: T7) => Promise<T8>): (x: V0) => Promise<T8>;
1551export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn6: (x: T6) => Promise<T7>, fn7: (x: T7) => Promise<T8>, fn8: (x: T8) => Promise<T9>): (x0: V0) => Promise<T9>;
1552export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn6: (x: T6) => Promise<T7>, fn7: (x: T7) => Promise<T8>, fn8: (x: T8) => Promise<T9>, fn9: (x: T9) => Promise<T10>): (x0: V0) => Promise<T10>;
1553// tslint:enable:max-line-length
1554
1555/*
1556 * Performs left-to-right function composition using transforming function.
1557 * With the current typings, all functions must be unary.
1558 */
1559export function pipeWith<V0, T>(composer: (f: (value: any) => any, res: any) => any, fns: PipeWithFns<V0, T>): (x0: V0) => T;
1560export function pipeWith(composer: (f: (value: any) => any, res: any) => any): <V0, T>(fns: PipeWithFns<V0, T>) => (x0: V0) => T;
1561
1562/**
1563 * Returns a new list by plucking the same named property off all objects in the list supplied.
1564 */
1565export function pluck<K extends keyof T, T>(p: K, list: readonly T[]): Array<T[K]>;
1566export function pluck<T>(p: number, list: Array<{ [k: number]: T }>): T[];
1567export function pluck<P extends string>(p: P): <T>(list: Array<Record<P, T>>) => T[];
1568export function pluck(p: number): <T>(list: Array<{ [k: number]: T }>) => T[];
1569
1570/**
1571 * Returns a new list with the given element at the front, followed by the contents of the
1572 * list.
1573 */
1574export function prepend<T>(el: T, list: readonly T[]): T[];
1575export function prepend<T>(el: T): (list: readonly T[]) => T[];
1576
1577/**
1578 * Multiplies together all the elements of a list.
1579 */
1580export function product(list: readonly number[]): number;
1581
1582/**
1583 * Reasonable analog to SQL `select` statement.
1584 */
1585export function project<T, U>(props: readonly string[], objs: readonly T[]): U[];
1586export function project<T, U>(props: readonly string[]): (objs: readonly T[]) => U[];
1587
1588/**
1589 * Returns a function that when supplied an object returns the indicated property of that object, if it exists.
1590 */
1591export function prop<T>(__: Placeholder, obj: T): <P extends keyof T>(p: P) => T[P];
1592export function prop<P extends keyof T, T>(p: P, obj: T): T[P];
1593export function prop<P extends string>(p: P): <T>(obj: Record<P, T>) => T;
1594export function prop<P extends string, T>(p: P): (obj: Record<P, T>) => T;
1595
1596/**
1597 * Determines whether the given property of an object has a specific
1598 * value according to strict equality (`===`). Most likely used to
1599 * filter a list.
1600 */
1601export function propEq<K extends string | number>(name: K, val: any, obj: Record<K, any>): boolean;
1602export function propEq<K extends string | number>(name: K, val: any): (obj: Record<K, any>) => boolean;
1603export function propEq<K extends string | number>(name: K): {
1604 (val: any, obj: Record<K, any>): boolean;
1605 (val: any): (obj: Record<K, any>) => boolean;
1606};
1607
1608/**
1609 * Returns true if the specified object property is of the given type; false otherwise.
1610 */
1611export function propIs(type: any, name: string, obj: any): boolean;
1612export function propIs(type: any, name: string): (obj: any) => boolean;
1613export function propIs(type: any): {
1614 (name: string, obj: any): boolean;
1615 (name: string): (obj: any) => boolean;
1616};
1617
1618/**
1619 * If the given, non-null object has an own property with the specified name, returns the value of that property.
1620 * Otherwise returns the provided default value.
1621 */
1622export function propOr<T, U>(val: T, __: Placeholder, obj: U): <V>(p: string) => V;
1623export function propOr<U>(__: Placeholder, p: string, obj: U): <T, V>(val: T) => V;
1624export function propOr<T, U, V>(val: T, p: string, obj: U): V;
1625export function propOr<T>(val: T, p: string): <U, V>(obj: U) => V;
1626export function propOr<T>(val: T): <U, V>(p: string, obj: U) => V;
1627
1628/**
1629 * Returns the value at the specified property.
1630 * The only difference from `prop` is the parameter order.
1631 * Note: TS1.9 # replace any by dictionary
1632 */
1633export function props<P extends string, T>(ps: readonly P[], obj: Record<P, T>): T[];
1634export function props<P extends string>(ps: readonly P[]): <T>(obj: Record<P, T>) => T[];
1635export function props<P extends string, T>(ps: readonly P[]): (obj: Record<P, T>) => T[];
1636
1637/**
1638 * Returns true if the specified object property satisfies the given predicate; false otherwise.
1639 */
1640export function propSatisfies<T, U>(pred: (val: T) => boolean, name: string, obj: U): boolean;
1641export function propSatisfies<T, U>(pred: (val: T) => boolean, name: string): (obj: U) => boolean;
1642export function propSatisfies<T, U>(pred: (val: T) => boolean): _.F.Curry<(a: string, b: U) => boolean>;
1643
1644/**
1645 * Returns a list of numbers from `from` (inclusive) to `to`
1646 * (exclusive). In mathematical terms, `range(a, b)` is equivalent to
1647 * the half-open interval `[a, b)`.
1648 */
1649export function range(from: number, to: number): number[];
1650export function range(from: number): (to: number) => number[];
1651
1652/**
1653 * Returns a single item by iterating through the list, successively calling the iterator
1654 * function and passing it an accumulator value and the current value from the array, and
1655 * then passing the result to the next call.
1656 */
1657export function reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>, acc: TResult, list: readonly T[]): TResult;
1658export function reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>): (acc: TResult, list: readonly T[]) => TResult;
1659export function reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>, acc: TResult): (list: readonly T[]) => TResult;
1660
1661/**
1662 * Groups the elements of the list according to the result of calling the String-returning function keyFn on each
1663 * element and reduces the elements of each group to a single value via the reducer function valueFn.
1664 */
1665export function reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string, list: readonly T[]): { [index: string]: TResult };
1666export function reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string): (list: readonly T[]) => { [index: string]: TResult };
1667export function reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult): _.F.Curry<(a: (elem: T) => string, b: readonly T[]) => { [index: string]: TResult }>;
1668export function reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult): _.F.Curry<(a: TResult, b: (elem: T) => string, c: readonly T[]) => { [index: string]: TResult }>;
1669
1670/**
1671 * Returns a value wrapped to indicate that it is the final value of the reduce and
1672 * transduce functions. The returned value should be considered a black box: the internal
1673 * structure is not guaranteed to be stable.
1674 */
1675export function reduced<T>(elem: T): Reduced<T>;
1676
1677/**
1678 * Returns a single item by iterating through the list, successively calling the iterator
1679 * function and passing it an accumulator value and the current value from the array, and
1680 * then passing the result to the next call.
1681 */
1682export function reduceRight<T, TResult>(fn: (elem: T, acc: TResult) => TResult, acc: TResult, list: readonly T[]): TResult;
1683export function reduceRight<T, TResult>(fn: (elem: T, acc: TResult) => TResult): (acc: TResult, list: readonly T[]) => TResult;
1684export function reduceRight<T, TResult>(fn: (elem: T, acc: TResult) => TResult, acc: TResult): (list: readonly T[]) => TResult;
1685
1686/**
1687 * Like reduce, reduceWhile returns a single item by iterating through the list, successively
1688 * calling the iterator function. reduceWhile also takes a predicate that is evaluated before
1689 * each step. If the predicate returns false, it "short-circuits" the iteration and returns
1690 * the current value of the accumulator.
1691 */
1692export function reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult, acc: TResult, list: readonly T[]): TResult;
1693export function reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult, acc: TResult): (list: readonly T[]) => TResult;
1694export function reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult): _.F.Curry<(a: TResult, b: readonly T[]) => TResult>;
1695export function reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean): _.F.Curry<(a: (acc: TResult, elem: T) => TResult, b: TResult, c: readonly T[]) => TResult>;
1696
1697/**
1698 * Similar to `filter`, except that it keeps only values for which the given predicate
1699 * function returns falsy.
1700 */
1701export const reject: Filter;
1702
1703/**
1704 * Removes the sub-list of `list` starting at index `start` and containing `count` elements.
1705 */
1706export function remove<T>(start: number, count: number, list: readonly T[]): T[];
1707export function remove<T>(start: number): (count: number, list: readonly T[]) => T[];
1708export function remove<T>(start: number, count: number): (list: readonly T[]) => T[];
1709
1710/**
1711 * Returns a fixed list of size n containing a specified identical value.
1712 */
1713export function repeat<T>(a: T, n: number): T[];
1714export function repeat<T>(a: T): (n: number) => T[];
1715
1716/**
1717 * Replace a substring or regex match in a string with a replacement.
1718 */
1719export function replace(pattern: RegExp | string, replacement: string | ((match: string, ...args: readonly any[]) => string), str: string): string;
1720export function replace(pattern: RegExp | string, replacement: string | ((match: string, ...args: readonly any[]) => string)): (str: string) => string;
1721export function replace(pattern: RegExp | string): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => (str: string) => string;
1722
1723/**
1724 * Returns a new list with the same elements as the original list, just in the reverse order.
1725 */
1726export function reverse<T>(list: readonly T[]): T[];
1727/**
1728 * Returns a new string with the characters in reverse order.
1729 */
1730export function reverse(str: string): string;
1731
1732/**
1733 * Scan is similar to reduce, but returns a list of successively reduced values from the left.
1734 */
1735export function scan<T, TResult>(fn: (acc: TResult, elem: T) => any, acc: TResult, list: readonly T[]): TResult[];
1736export function scan<T, TResult>(fn: (acc: TResult, elem: T) => any, acc: TResult): (list: readonly T[]) => TResult[];
1737export function scan<T, TResult>(fn: (acc: TResult, elem: T) => any): (acc: TResult, list: readonly T[]) => TResult[];
1738
1739/**
1740 * Returns the result of "setting" the portion of the given data structure focused by the given lens to the
1741 * given value.
1742 */
1743export function set<S, A>(lens: Lens<S, A>, a: A, obj: S): S;
1744export function set<S, A>(lens: Lens<S, A>, a: A): (obj: S) => S;
1745export function set<S, A>(lens: Lens<S, A>): (a: A, obj: S) => S;
1746
1747/**
1748 * Returns the elements from `xs` starting at `a` and ending at `b - 1`.
1749 */
1750export function slice(a: number, b: number, list: string): string;
1751export function slice<T>(a: number, b: number, list: readonly T[]): T[];
1752export function slice(a: number, b: number): {
1753 (list: string): string;
1754 <T>(list: readonly T[]): T[];
1755};
1756export function slice(a: number): {
1757 (b: number, list: string): string;
1758 <T>(b: number, list: readonly T[]): T[];
1759};
1760
1761/**
1762 * Returns a copy of the list, sorted according to the comparator function, which should accept two values at a
1763 * time and return a negative number if the first value is smaller, a positive number if it's larger, and zero
1764 * if they are equal.
1765 */
1766export function sort<T>(fn: (a: T, b: T) => number, list: readonly T[]): T[];
1767export function sort<T>(fn: (a: T, b: T) => number): (list: readonly T[]) => T[];
1768
1769/**
1770 * Sorts the list according to a key generated by the supplied function.
1771 */
1772export function sortBy<T>(fn: (a: T) => Ord, list: readonly T[]): T[];
1773export function sortBy<T>(fn: (a: T) => Ord): (list: readonly T[]) => T[];
1774export function sortBy(fn: (a: any) => Ord): <T>(list: readonly T[]) => T[];
1775
1776/**
1777 * Sorts a list according to a list of comparators.
1778 */
1779export function sortWith<T>(fns: Array<((a: T, b: T) => number)>, list: readonly T[]): T[];
1780export function sortWith<T>(fns: Array<((a: T, b: T) => number)>): (list: readonly T[]) => T[];
1781
1782/**
1783 * Splits a string into an array of strings based on the given
1784 * separator.
1785 */
1786export function split(sep: string | RegExp): (str: string) => string[];
1787export function split(sep: string | RegExp, str: string): string[];
1788
1789/**
1790 * Splits a given list or string at a given index.
1791 */
1792export function splitAt<T>(index: number, list: readonly T[]): [T[], T[]];
1793export function splitAt(index: number, list: string): [string, string];
1794export function splitAt(index: number): {
1795 <T>(list: readonly T[]): [T[], T[]];
1796 (list: string): [string, string];
1797};
1798
1799/**
1800 * Splits a collection into slices of the specified length.
1801 */
1802export function splitEvery<T>(a: number, list: readonly T[]): T[][];
1803export function splitEvery(a: number, list: string): string[];
1804export function splitEvery(a: number): {
1805 (list: string): string[];
1806 <T>(list: readonly T[]): T[][];
1807};
1808
1809/**
1810 * Takes a list and a predicate and returns a pair of lists with the following properties:
1811 * - the result of concatenating the two output lists is equivalent to the input list;
1812 * - none of the elements of the first output list satisfies the predicate; and
1813 * - if the second output list is non-empty, its first element satisfies the predicate.
1814 */
1815export function splitWhen<T, U>(pred: (val: T) => boolean, list: readonly U[]): U[][];
1816export function splitWhen<T>(pred: (val: T) => boolean): <U>(list: readonly U[]) => U[][];
1817
1818/**
1819 * Checks if a list starts with the provided values
1820 */
1821export function startsWith(a: string, list: string): boolean;
1822export function startsWith(a: string): (list: string) => boolean;
1823export function startsWith<T>(a: T | readonly T[], list: readonly T[]): boolean;
1824export function startsWith<T>(a: T | readonly T[]): (list: readonly T[]) => boolean;
1825
1826/**
1827 * Subtracts two numbers. Equivalent to `a - b` but curried.
1828 */
1829export function subtract(__: Placeholder, b: number): (a: number) => number;
1830export function subtract(__: Placeholder): (b: number, a: number) => number;
1831export function subtract(a: number, b: number): number;
1832export function subtract(a: number): (b: number) => number;
1833
1834/**
1835 * Adds together all the elements of a list.
1836 */
1837export function sum(list: readonly number[]): number;
1838
1839/**
1840 * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.
1841 */
1842export function symmetricDifference<T>(list1: readonly T[], list2: readonly T[]): T[];
1843export function symmetricDifference<T>(list: readonly T[]): <T>(list: readonly T[]) => T[];
1844
1845/**
1846 * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.
1847 * Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
1848 */
1849export function symmetricDifferenceWith<T>(pred: (a: T, b: T) => boolean, list1: readonly T[], list2: readonly T[]): T[];
1850export function symmetricDifferenceWith<T>(pred: (a: T, b: T) => boolean): _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>;
1851
1852/**
1853 * A function that always returns true. Any passed in parameters are ignored.
1854 */
1855export function T(): boolean;
1856
1857/**
1858 * Returns all but the first element of a list or string.
1859 */
1860export function tail(list: string): string;
1861export function tail<T extends any>(list: readonly T[]): T[];
1862
1863/**
1864 * Returns a new list containing the first `n` elements of the given list. If
1865 * `n > * list.length`, returns a list of `list.length` elements.
1866 */
1867export function take<T>(n: number, xs: readonly T[]): T[];
1868export function take(n: number, xs: string): string;
1869export function take(n: number): {
1870 (xs: string): string;
1871 <T>(xs: readonly T[]): T[];
1872};
1873
1874/**
1875 * Returns a new list containing the last n elements of the given list. If n > list.length,
1876 * returns a list of list.length elements.
1877 */
1878export function takeLast<T>(n: number, xs: readonly T[]): T[];
1879export function takeLast(n: number, xs: string): string;
1880export function takeLast(n: number): {
1881 <T>(xs: readonly T[]): T[];
1882 (xs: string): string;
1883};
1884
1885/**
1886 * Returns a new list containing the last n elements of a given list, passing each value
1887 * to the supplied predicate function, and terminating when the predicate function returns
1888 * false. Excludes the element that caused the predicate function to fail. The predicate
1889 * function is passed one argument: (value).
1890 */
1891export function takeLastWhile<T>(pred: (a: T) => boolean, list: readonly T[]): T[];
1892export function takeLastWhile<T>(pred: (a: T) => boolean): <T>(list: readonly T[]) => T[];
1893
1894/**
1895 * Returns a new list containing the first `n` elements of a given list, passing each value
1896 * to the supplied predicate function, and terminating when the predicate function returns
1897 * `false`.
1898 */
1899export function takeWhile<T>(fn: (x: T) => boolean, list: readonly T[]): T[];
1900export function takeWhile<T>(fn: (x: T) => boolean): (list: readonly T[]) => T[];
1901
1902/**
1903 * Runs the given function with the supplied object, then returns the object.
1904 * Acts as a transducer if a transformer is given as second parameter.
1905 */
1906export function tap<T>(fn: (a: T) => any, value: T): T;
1907export function tap<T>(fn: (a: T) => any): (value: T) => T;
1908
1909/**
1910 * Determines whether a given string matches a given regular expression.
1911 */
1912export function test(regexp: RegExp, str: string): boolean;
1913export function test(regexp: RegExp): (str: string) => boolean;
1914
1915/**
1916 * Creates a thunk out of a function.
1917 * A thunk delays a calculation until its result is needed, providing lazy evaluation of arguments.
1918 */
1919export function thunkify<F extends (...args: readonly any[]) => any>(fn: F): _.F.Curry<(...args: Parameters<F>) => (() => ReturnType<F>)>;
1920
1921/**
1922 * Calls an input function `n` times, returning an array containing the results of those
1923 * function calls.
1924 */
1925export function times<T>(fn: (i: number) => T, n: number): T[];
1926export function times<T>(fn: (i: number) => T): (n: number) => T[];
1927
1928/**
1929 * The lower case version of a string.
1930 */
1931export function toLower<S extends string>(str: S): Lowercase<S>;
1932export function toLower(str: string): string;
1933
1934/**
1935 * Converts an object into an array of key, value arrays.
1936 * Only the object's own properties are used.
1937 * Note that the order of the output array is not guaranteed to be
1938 * consistent across different JS platforms.
1939 */
1940export function toPairs<O extends object, K extends Extract<keyof O, string | number>>(obj: O): Array<{ [key in K]: [`${key}`, O[key]] }[K]>;
1941export function toPairs<S>(obj: Record<string | number, S>): Array<[string, S]>;
1942
1943/**
1944 * Converts an object into an array of key, value arrays.
1945 * The object's own properties and prototype properties are used.
1946 * Note that the order of the output array is not guaranteed to be
1947 * consistent across different JS platforms.
1948 */
1949export function toPairsIn<O extends object, K extends Extract<keyof O, string | number>>(obj: O): Array<{ [key in K]: [`${key}`, O[key]] }[K]>;
1950export function toPairsIn<S>(obj: Record<string | number, S>): Array<[string, S]>;
1951
1952/**
1953 * Returns the string representation of the given value. eval'ing the output should
1954 * result in a value equivalent to the input value. Many of the built-in toString
1955 * methods do not satisfy this requirement.
1956 *
1957 * If the given value is an [object Object] with a toString method other than
1958 * Object.prototype.toString, this method is invoked with no arguments to produce the
1959 * return value. This means user-defined constructor functions can provide a suitable
1960 * toString method.
1961 */
1962export function toString<T>(val: T): string;
1963
1964/**
1965 * The upper case version of a string.
1966 */
1967export function toUpper<S extends string>(str: S): Uppercase<S>;
1968export function toUpper(str: string): string;
1969
1970/**
1971 * Initializes a transducer using supplied iterator function. Returns a single item by iterating through the
1972 * list, successively calling the transformed iterator function and passing it an accumulator value and the
1973 * current value from the array, and then passing the result to the next call.
1974 */
1975export function transduce<T, U>(xf: (arg: readonly T[]) => T[], fn: (acc: readonly U[], val: U) => U[], acc: readonly T[], list: readonly T[]): U;
1976export function transduce<T, U>(xf: (arg: readonly T[]) => T[]): (fn: (acc: readonly U[], val: U) => U[], acc: readonly T[], list: readonly T[]) => U;
1977export function transduce<T, U>(xf: (arg: readonly T[]) => T[], fn: (acc: readonly U[], val: U) => U[]): (acc: readonly T[], list: readonly T[]) => U;
1978export function transduce<T, U>(xf: (arg: readonly T[]) => T[], fn: (acc: readonly U[], val: U) => U[], acc: readonly T[]): (list: readonly T[]) => U;
1979
1980/**
1981 * Transposes the rows and columns of a 2D list. When passed a list of n lists of length x, returns a list of x lists of length n.
1982 */
1983export function transpose<T>(list: readonly T[][]): T[][];
1984
1985/**
1986 * Maps an Applicative-returning function over a Traversable, then uses
1987 * sequence to transform the resulting Traversable of Applicative into
1988 * an Applicative of Traversable.
1989 */
1990export function traverse<A, B>(of: (a: B) => B[], fn: (t: A) => B[], list: readonly A[]): B[][];
1991export function traverse<A, B>(of: (a: B) => B[], fn: (t: A) => B[]): (list: readonly A[]) => B[][];
1992export function traverse<A, B>(of: (a: B) => B[]): (fn: (t: A) => B[], list: readonly A[]) => B[][];
1993
1994/**
1995 * Removes (strips) whitespace from both ends of the string.
1996 */
1997export function trim(str: string): string;
1998
1999/**
2000 * tryCatch takes two functions, a tryer and a catcher. The returned function evaluates the tryer; if it does
2001 * not throw, it simply returns the result. If the tryer does throw, the returned function evaluates the catcher
2002 * function and returns its result. Note that for effective composition with this function, both the tryer and
2003 * catcher functions must return the same type of results.
2004 */
2005export function tryCatch<F extends (...args: readonly any[]) => any, RE = ReturnType<F>, E = unknown>(tryer: F, catcher: (error: E, ...args: _.F.Parameters<F>) => RE): (F | (() => RE));
2006export function tryCatch<F extends (...args: readonly any[]) => any>(tryer: F): <RE = ReturnType<F>, E = unknown>(catcher: (error: E, ...args: _.F.Parameters<F>) => RE) => (F | (() => RE));
2007/**
2008 * Gives a single-word string description of the (native) type of a value, returning such answers as 'Object',
2009 * 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them
2010 * all as 'Object'.
2011 */
2012export function type(val: any): 'Object' | 'Number' | 'Boolean' | 'String' | 'Null' | 'Array' | 'RegExp' | 'Function' | 'Undefined' | 'Symbol';
2013
2014/**
2015 * Takes a function fn, which takes a single array argument, and returns a function which:
2016 * - takes any number of positional arguments;
2017 * - passes these arguments to fn as an array; and
2018 * - returns the result.
2019 * In other words, R.unapply derives a variadic function from a function which takes an array.
2020 * R.unapply is the inverse of R.apply.
2021 */
2022export function unapply<T>(fn: (args: readonly any[]) => T): (...args: readonly any[]) => T;
2023
2024/**
2025 * Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter.
2026 * Any extraneous parameters will not be passed to the supplied function.
2027 */
2028export function unary<T, R>(fn: (a: T, ...args: readonly any[]) => R): (a: T) => R;
2029
2030/**
2031 * Returns a function of arity n from a (manually) curried function.
2032 */
2033export function uncurryN<T>(len: number, fn: (a: any) => any): (...a: readonly any[]) => T;
2034
2035/**
2036 * Builds a list from a seed value. Accepts an iterator function, which returns either false
2037 * to stop iteration or an array of length 2 containing the value to add to the resulting
2038 * list and the seed to be used in the next call to the iterator function.
2039 */
2040export function unfold<T, TResult>(fn: (seed: T) => [TResult, T] | false, seed: T): TResult[];
2041export function unfold<T, TResult>(fn: (seed: T) => [TResult, T] | false): (seed: T) => TResult[];
2042
2043/**
2044 * Combines two lists into a set (i.e. no duplicates) composed of the
2045 * elements of each list.
2046 */
2047export function union<T>(as: readonly T[], bs: readonly T[]): T[];
2048export function union<T>(as: readonly T[]): (bs: readonly T[]) => T[];
2049
2050/**
2051 * Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is
2052 * determined according to the value returned by applying the supplied predicate to two list elements.
2053 */
2054export function unionWith<T>(pred: (a: T, b: T) => boolean, list1: readonly T[], list2: readonly T[]): T[];
2055export function unionWith<T>(pred: (a: T, b: T) => boolean): _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>;
2056
2057/**
2058 * Returns a new list containing only one copy of each element in the original list.
2059 */
2060export function uniq<T>(list: readonly T[]): T[];
2061
2062/**
2063 * Returns a new list containing only one copy of each element in the original list,
2064 * based upon the value returned by applying the supplied function to each list element.
2065 * Prefers the first item if the supplied function produces the same value on two items.
2066 * R.equals is used for comparison.
2067 */
2068export function uniqBy<T, U>(fn: (a: T) => U, list: readonly T[]): T[];
2069export function uniqBy<T, U>(fn: (a: T) => U): (list: readonly T[]) => T[];
2070
2071/**
2072 * Returns a new list containing only one copy of each element in the original list, based upon the value
2073 * returned by applying the supplied predicate to two list elements.
2074 */
2075export function uniqWith<T, U>(pred: (x: T, y: T) => boolean, list: readonly T[]): T[];
2076export function uniqWith<T, U>(pred: (x: T, y: T) => boolean): (list: readonly T[]) => T[];
2077
2078/**
2079 * Tests the final argument by passing it to the given predicate function. If the predicate is not satisfied,
2080 * the function will return the result of calling the whenFalseFn function with the same argument. If the
2081 * predicate is satisfied, the argument is returned as is.
2082 */
2083export function unless<T, U>(pred: (a: T) => boolean, whenFalseFn: (a: T) => U, obj: T): U;
2084export function unless<T, U>(pred: (a: T) => boolean, whenFalseFn: (a: T) => U): (obj: T) => U;
2085
2086/**
2087 * Returns a new list by pulling every item at the first level of nesting out, and putting
2088 * them in a new array.
2089 */
2090export function unnest<T extends readonly any[]>(list: T): _.T.UnNest<T>;
2091
2092/**
2093 * Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as
2094 * the initial value. It does so by applying the transformation until the predicate is satisfied, at which point
2095 * it returns the satisfactory value.
2096 */
2097export function until<T, U>(pred: (val: T) => boolean, fn: (val: T) => U, init: U): U;
2098export function until<T, U>(pred: (val: T) => boolean, fn: (val: T) => U): (init: U) => U;
2099
2100/**
2101 * Returns a new copy of the array with the element at the provided index replaced with the given value.
2102 */
2103export function update<T>(index: number, value: T, list: readonly T[]): T[];
2104export function update<T>(index: number, value: T): (list: readonly T[]) => T[];
2105
2106/**
2107 * Accepts a function fn and a list of transformer functions and returns a new curried function.
2108 * When the new function is invoked, it calls the function fn with parameters consisting of the
2109 * result of calling each supplied handler on successive arguments to the new function.
2110 *
2111 * If more arguments are passed to the returned function than transformer functions, those arguments
2112 * are passed directly to fn as additional parameters. If you expect additional arguments that don't
2113 * need to be transformed, although you can ignore them, it's best to pass an identity function so
2114 * that the new function reports the correct arity.
2115 */
2116export function useWith(fn: ((...a: readonly any[]) => any), transformers: Array<((...a: readonly any[]) => any)>): (...a: readonly any[]) => any;
2117
2118/**
2119 * Returns a list of all the enumerable own properties of the supplied object.
2120 * Note that the order of the output array is not guaranteed across
2121 * different JS platforms.
2122 */
2123export function values<T extends object, K extends keyof T>(obj: T): Array<T[K] | ValueOfUnion<T>>;
2124
2125/**
2126 * Returns a list of all the properties, including prototype properties, of the supplied
2127 * object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
2128 */
2129export function valuesIn<T>(obj: any): T[];
2130
2131/**
2132 * Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which
2133 * portion of the data structure is visible.
2134 */
2135export function view<S, A>(lens: Lens<S, A>): (obj: S) => A;
2136export function view<S, A>(lens: Lens<S, A>, obj: S): A;
2137
2138/**
2139 * Tests the final argument by passing it to the given predicate function. If the predicate is satisfied, the function
2140 * will return the result of calling the whenTrueFn function with the same argument. If the predicate is not satisfied,
2141 * the argument is returned as is.
2142 */
2143export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U, obj: T): T | U;
2144export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U): (obj: T) => T | U;
2145
2146/**
2147 * Takes a spec object and a test object and returns true if the test satisfies the spec.
2148 * Any property on the spec that is not a function is interpreted as an equality
2149 * relation.
2150 *
2151 * If the spec has a property mapped to a function, then `where` evaluates the function, passing in
2152 * the test object's value for the property in question, as well as the whole test object.
2153 *
2154 * `where` is well suited to declaratively expressing constraints for other functions, e.g.,
2155 * `filter`, `find`, `pickWith`, etc.
2156 */
2157export function where<T, U>(spec: T, testObj: U): boolean;
2158export function where<T>(spec: T): <U>(testObj: U) => boolean;
2159export function where<ObjFunc2, U>(spec: ObjFunc2, testObj: U): boolean;
2160export function where<ObjFunc2>(spec: ObjFunc2): <U>(testObj: U) => boolean;
2161
2162/**
2163 * Takes a spec object and a test object; returns true if the test satisfies the spec,
2164 * false otherwise. An object satisfies the spec if, for each of the spec's own properties,
2165 * accessing that property of the object gives the same value (in R.eq terms) as accessing
2166 * that property of the spec.
2167 */
2168export function whereEq<T, U>(spec: T, obj: U): boolean;
2169export function whereEq<T>(spec: T): <U>(obj: U) => boolean;
2170
2171/**
2172 * Returns a new list without values in the first argument. R.equals is used to determine equality.
2173 * Acts as a transducer if a transformer is given in list position.
2174 */
2175export function without<T>(list1: readonly T[], list2: readonly T[]): T[];
2176export function without<T>(list1: readonly T[]): (list2: readonly T[]) => T[];
2177
2178/**
2179 * Exclusive disjunction logical operation.
2180 * Returns `true` if one of the arguments is truthy and the other is falsy.
2181 * Otherwise, it returns `false`.
2182 */
2183export function xor(a: any, b: any): boolean;
2184export function xor(a: any): (b: any) => boolean;
2185
2186/**
2187 * Creates a new list out of the two supplied by creating each possible pair from the lists.
2188 */
2189export function xprod<K, V>(as: readonly K[], bs: readonly V[]): Array<KeyValuePair<K, V>>;
2190export function xprod<K>(as: readonly K[]): <V>(bs: readonly V[]) => Array<KeyValuePair<K, V>>;
2191
2192/**
2193 * Creates a new list out of the two supplied by pairing up equally-positioned items from
2194 * both lists. Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`.
2195 */
2196export function zip<K, V>(list1: readonly K[], list2: readonly V[]): Array<KeyValuePair<K, V>>;
2197export function zip<K>(list1: readonly K[]): <V>(list2: readonly V[]) => Array<KeyValuePair<K, V>>;
2198
2199/**
2200 * Creates a new object out of a list of keys and a list of values.
2201 */
2202// TODO: Dictionary<T> as a return value is to specific, any seems to loose
2203export function zipObj<T, K extends string>(keys: readonly K[], values: readonly T[]): { [P in K]: T };
2204export function zipObj<K extends string>(keys: readonly K[]): <T>(values: readonly T[]) => { [P in K]: T };
2205export function zipObj<T, K extends number>(keys: readonly K[], values: readonly T[]): { [P in K]: T };
2206export function zipObj<K extends number>(keys: readonly K[]): <T>(values: readonly T[]) => { [P in K]: T };
2207
2208/**
2209 * Creates a new list out of the two supplied by applying the function to each
2210 * equally-positioned pair in the lists.
2211 */
2212export function zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: readonly T[], list2: readonly U[]): TResult[];
2213export function zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: readonly T[]): (list2: readonly U[]) => TResult[];
2214export function zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult): (list1: readonly T[], list2: readonly U[]) => TResult[];
2215
2216export as namespace R