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); } | number | boolean | string | null>(fn1: T, val2: any): boolean;
119export function and<T extends { and?: ((...a: readonly any[]) => any); } | 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>>): { [index: string]: V };
670export function fromPairs<V>(pairs: Array<KeyValuePair<number, V>>): { [index: number]: V };
671
672/**
673 * Splits a list into sublists stored in an object, based on the result of
674 * calling a String-returning function
675 * on each element, and grouping the results according to values returned.
676 */
677export function groupBy<T, K extends string = string>(fn: (a: T) => K, list: readonly T[]): Record<K, T[]>;
678export function groupBy<T, K extends string = string>(fn: (a: T) => K): (list: readonly T[]) => Record<K, T[]>;
679
680/**
681 * Takes a list and returns a list of lists where each sublist's elements are all "equal" according to the provided equality function
682 */
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: readonly T[]): T[][];
685export function groupWith<T>(fn: (x: T, y: T) => boolean, list: string): string[];
686
687/**
688 * Returns true if the first parameter is greater than the second.
689 */
690export function gt(__: Placeholder, b: number): (a: number) => boolean;
691export function gt(__: Placeholder): (b: number, a: number) => boolean;
692export function gt(a: number, b: number): boolean;
693export function gt(a: string, b: string): boolean;
694export function gt(a: number): (b: number) => boolean;
695
696/**
697 * Returns true if the first parameter is greater than or equal to the second.
698 */
699export function gte(__: Placeholder, b: number): (a: number) => boolean;
700export function gte(__: Placeholder): (b: number, a: number) => boolean;
701export function gte(a: number, b: number): boolean;
702export function gte(a: string, b: string): boolean;
703export function gte(a: number): (b: number) => boolean;
704
705/**
706 * Returns whether or not an object has an own property with the specified name.
707 */
708export function has(__: Placeholder, obj: unknown): (s: string) => boolean;
709export function has(__: Placeholder): <P extends string>(obj: unknown, s: P) => obj is ObjectHavingSome<P>;
710export function has<P extends string>(s: P, obj: unknown): obj is ObjectHavingSome<P>;
711export function has<P extends string>(s: P): (obj: unknown) => obj is ObjectHavingSome<P>;
712
713/**
714 * Returns whether or not an object or its prototype chain has a property with the specified name
715 */
716export function hasIn<T>(s: string, obj: T): boolean;
717export function hasIn(s: string): <T>(obj: T) => boolean;
718
719/**
720 * Returns whether or not a path exists in an object. Only the object's own properties are checked.
721 */
722export function hasPath<T>(list: readonly string[], obj: T): boolean;
723export function hasPath(list: readonly string[]): <T>(obj: T) => boolean;
724
725/**
726 * Returns the first element in a list.
727 * In some libraries this function is named `first`.
728 */
729export function head(str: string): string;
730export function head(list: readonly []): undefined;
731export function head<T extends any>(list: readonly T[]): T | undefined;
732
733/**
734 * Returns true if its arguments are identical, false otherwise. Values are identical if they reference the
735 * same memory. NaN is identical to NaN; 0 and -0 are not identical.
736 */
737export function identical<T>(a: T, b: T): boolean;
738export function identical<T>(a: T): (b: T) => boolean;
739
740/**
741 * A function that does nothing but return the parameter supplied to it. Good as a default
742 * or placeholder function.
743 */
744export function identity<T>(a: T): T;
745
746/**
747 * Creates a function that will process either the onTrue or the onFalse function depending upon the result
748 * of the condition predicate.
749 */
750export function ifElse(fn: Pred, onTrue: Arity1Fn, onFalse: Arity1Fn): Arity1Fn;
751export function ifElse(fn: Pred, onTrue: Arity2Fn, onFalse: Arity2Fn): Arity2Fn;
752
753/**
754 * Increments its argument.
755 */
756export function inc(n: number): number;
757
758/**
759 * Given a target, this function checks a list for the target and returns a boolean.
760 * Given a string, this function checks for the string in another string or list and returns
761 * a boolean.
762 */
763export function includes(__: Placeholder, list: readonly string[] | string): (s: string) => boolean;
764export function includes<T>(__: Placeholder, list: readonly T[]): (target: T) => boolean;
765export function includes(__: Placeholder): (list: readonly string[] | string, s: string) => boolean;
766export function includes<T>(__: Placeholder): (list: readonly T[], target: T) => boolean;
767export function includes(s: string, list: readonly string[] | string): boolean;
768export function includes(s: string): (list: readonly string[] | string) => boolean;
769export function includes<T>(target: T, list: readonly T[]): boolean;
770export function includes<T>(target: T): (list: readonly T[]) => boolean;
771
772/**
773 * Given a function that generates a key, turns a list of objects into an object indexing the objects
774 * by the given key.
775 */
776export function indexBy<T, K extends string | number = string>(fn: (a: T) => K, list: readonly T[]): { [key in K]: T };
777export function indexBy<T, K extends string | number | undefined = string>(fn: (a: T) => K, list: readonly T[]): { [key in NonNullable<K>]?: T };
778export function indexBy<T, K extends string | number = string>(fn: (a: T) => K): (list: readonly T[]) => { [key in K]: T };
779export function indexBy<T, K extends string | number | undefined = string>(fn: (a: T) => K | undefined): (list: readonly T[]) => { [key in NonNullable<K>]?: T };
780
781/**
782 * Returns the position of the first occurrence of an item in an array
783 * (by strict equality),
784 * or -1 if the item is not included in the array.
785 */
786export function indexOf<T>(target: T, list: readonly T[]): number;
787export function indexOf<T>(target: T): (list: readonly T[]) => number;
788
789/**
790 * Returns all but the last element of a list or string.
791 */
792export function init<T>(list: readonly T[]): T[];
793export function init(list: string): string;
794
795/**
796 * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list
797 * `xs'` comprising each of the elements of `xs` which is equal to one or more
798 * elements of `ys` according to `pred`.
799 *
800 * `pred` must be a binary function expecting an element from each list.
801 *
802 * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should
803 * not be significant, but since `xs'` is ordered the implementation guarantees
804 * that its values are in the same order as they appear in `xs`. Duplicates are
805 * not removed, so `xs'` may contain duplicates if `xs` contains duplicates.
806 */
807
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[];
810export function innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[]): (list2: readonly T2[]) => T1[];
811
812/**
813 * Inserts the supplied element into the list, at index index. Note that
814 * this is not destructive: it returns a copy of the list with the changes.
815 */
816export function insert<T>(index: number, elt: T, list: readonly T[]): T[];
817export function insert<T>(index: number, elt: T): (list: readonly T[]) => T[];
818export function insert(index: number): <T>(elt: T, list: readonly T[]) => T[];
819
820/**
821 * Inserts the sub-list into the list, at index `index`. _Note that this
822 * is not destructive_: it returns a copy of the list with the changes.
823 */
824export function insertAll<T>(index: number, elts: readonly T[], list: readonly T[]): T[];
825export function insertAll<T>(index: number, elts: readonly T[]): (list: readonly T[]) => T[];
826export function insertAll(index: number): <T>(elts: readonly T[], list: readonly T[]) => T[];
827
828/**
829 * Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.
830 */
831export function intersection<T>(list1: readonly T[], list2: readonly T[]): T[];
832export function intersection<T>(list1: readonly T[]): (list2: readonly T[]) => T[];
833
834/**
835 * Creates a new list with the separator interposed between elements.
836 */
837export function intersperse<T>(separator: T, list: readonly T[]): T[];
838export function intersperse<T>(separator: T): (list: readonly T[]) => T[];
839
840/**
841 * Transforms the items of the list with the transducer and appends the transformed items to the accumulator
842 * using an appropriate iterator function based on the accumulator type.
843 */
844export function into<T>(acc: any, xf: (...a: readonly any[]) => any, list: readonly T[]): T[];
845export function into<T, R>(acc: any, xf: (...a: readonly any[]) => R[], list: readonly T[]): R[];
846export function into(acc: any, xf: (...a: readonly any[]) => any): <T>(list: readonly T[]) => T[];
847export function into(acc: any): <T>(xf: (...a: readonly any[]) => any, list: readonly T[]) => T[];
848
849/**
850 * Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array.
851 */
852export function invert<T>(obj: T): { [index: string]: string[] };
853
854/**
855 * Returns a new object with the keys of the given object as values, and the values of the given object as keys.
856 */
857export function invertObj(obj: { [index: string]: string } | { [index: number]: string }): { [index: string]: string };
858
859/**
860 * Turns a named method with a specified arity into a function that can be called directly
861 * supplied with arguments and a target object.
862 *
863 * The returned function is curried and accepts `arity + 1` parameters where the final
864 * parameter is the target object.
865 */
866export function invoker(arity: number, method: string): (...a: readonly any[]) => any;
867
868/**
869 * See if an object (`val`) is an instance of the supplied constructor.
870 * This function will check up the inheritance chain, if any.
871 */
872export function is(ctor: any, val: any): boolean;
873export function is(ctor: any): (val: any) => boolean;
874
875/**
876 * Reports whether the list has zero elements.
877 */
878export function isEmpty(value: any): boolean;
879
880/**
881 * Checks if the input value is null or undefined.
882 */
883export function isNil(value: any): value is null | undefined;
884
885/**
886 * Returns a string made by inserting the `separator` between each
887 * element and concatenating all the elements into a single string.
888 */
889export function join(x: string, xs: readonly any[]): string;
890export function join(x: string): (xs: readonly any[]) => string;
891
892/**
893 * Applies a list of functions to a list of values.
894 */
895export function juxt<A extends any[], R1, R2>(fns: [(...a: A) => R1, (...a: A) => R2]): (...a: A) => [R1, R2];
896export function juxt<A extends any[], R1, R2, R3>(fns: [(...a: A) => R1, (...a: A) => R2, (...a: A) => R3]): (...a: A) => [R1, R2, R3];
897export 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];
898export 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];
899export function juxt<A extends any[], U>(fns: Array<(...args: A) => U>): (...args: A) => U[];
900
901/**
902 * Returns a list containing the names of all the enumerable own
903 * properties of the supplied object.
904 */
905export function keys<T extends object>(x: T): Array<keyof T>;
906export function keys<T>(x: T): string[];
907
908/**
909 * Returns a list containing the names of all the
910 * properties of the supplied object, including prototype properties.
911 */
912export function keysIn<T>(obj: T): string[];
913
914/**
915 * Returns the last element from a list.
916 */
917export function last(str: string): string;
918export function last(list: readonly []): undefined;
919export function last<T extends any>(list: readonly T[]): T | undefined;
920
921/**
922 * Returns the position of the last occurrence of an item (by strict equality) in
923 * an array, or -1 if the item is not included in the array.
924 */
925export function lastIndexOf<T>(target: T, list: readonly T[]): number;
926
927/**
928 * Returns the number of elements in the array by returning list.length.
929 */
930export function length<T>(list: readonly T[]): number;
931
932/**
933 * Returns a lens for the given getter and setter functions. The getter
934 * "gets" the value of the focus; the setter "sets" the value of the focus.
935 * The setter should not mutate the data structure.
936 */
937export function lens<S, A>(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens<S, A>;
938
939/**
940 * Creates a lens that will focus on index n of the source array.
941 */
942export function lensIndex<A>(n: number): Lens<A[], A>;
943export function lensIndex<A extends any[], N extends number>(n: N): Lens<A, A[N]>;
944
945/**
946 * Returns a lens whose focus is the specified path.
947 * See also view, set, over.
948 */
949export function lensPath<S, K0 extends keyof S = keyof S>(path: [K0]): Lens<S, S[K0]>;
950export 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]>;
951export function lensPath<
952 S,
953 K0 extends keyof S = keyof S,
954 K1 extends keyof S[K0] = keyof S[K0],
955 K2 extends keyof S[K0][K1] = keyof S[K0][K1]
956>(
957 path: [K0, K1, K2]
958): Lens<S, S[K0][K1][K2]>;
959export function lensPath<
960 S,
961 K0 extends keyof S = keyof S,
962 K1 extends keyof S[K0] = keyof S[K0],
963 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
964 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
965>(
966 path: [K0, K1, K2, K3]
967): Lens<S, S[K0][K1][K2][K3]>;
968export function lensPath<
969 S,
970 K0 extends keyof S = keyof S,
971 K1 extends keyof S[K0] = keyof S[K0],
972 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
973 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
974 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
975>(
976 path: [K0, K1, K2, K3, K4]
977): Lens<S, S[K0][K1][K2][K3][K4]>;
978export function lensPath<
979 S,
980 K0 extends keyof S = keyof S,
981 K1 extends keyof S[K0] = keyof S[K0],
982 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
983 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
984 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
985 K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4],
986>(
987 path: [K0, K1, K2, K3, K4, K5]
988): Lens<S, S[K0][K1][K2][K3][K4][K5]>;
989
990export function lensPath<S = any, A = any>(path: Path): Lens<S, A>;
991
992/**
993 * lensProp creates a lens that will focus on property k of the source object.
994 */
995export function lensProp<S, K extends keyof S = keyof S>(prop: K): Lens<S, S[K]>;
996
997/**
998 * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other object that satisfies
999 * the FantasyLand Apply spec.
1000 */
1001export function lift(fn: ((...a: readonly any[]) => any), ...args: readonly any[]): any;
1002
1003/**
1004 * "lifts" a function to be the specified arity, so that it may "map over" that many lists, Functions or other
1005 * objects that satisfy the FantasyLand Apply spec.
1006 */
1007export function liftN(n: number, fn: ((...a: readonly any[]) => any), ...args: readonly any[]): any;
1008
1009/**
1010 * Returns true if the first parameter is less than the second.
1011 */
1012export function lt(__: Placeholder, b: number): (a: number) => boolean;
1013export function lt(__: Placeholder): (b: number, a: number) => boolean;
1014export function lt(a: number, b: number): boolean;
1015export function lt(a: string, b: string): boolean;
1016export function lt(a: number): (b: number) => boolean;
1017
1018/**
1019 * Returns true if the first parameter is less than or equal to the second.
1020 */
1021export function lte(__: Placeholder, b: number): (a: number) => boolean;
1022export function lte(__: Placeholder): (b: number, a: number) => boolean;
1023export function lte(a: number, b: number): boolean;
1024export function lte(a: string, b: string): boolean;
1025export function lte(a: number): (b: number) => boolean;
1026
1027/**
1028 * Returns a new list, constructed by applying the supplied function to every element of the supplied list.
1029 */
1030export function map<T, U>(fn: (x: T) => U, list: readonly T[]): U[];
1031export function map<T, U>(fn: (x: T) => U): (list: readonly 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[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U]): (list: T) => U;
1034export function map<T, U>(fn: (x: T) => U, obj: Functor<T>): Functor<U>; // used in functors
1035export function map<T, U>(fn: (x: T) => U): (obj: Functor<T>) => Functor<U>; // used in functors
1036
1037/**
1038 * The mapAccum function behaves like a combination of map and reduce.
1039 */
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[]];
1042export function mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: readonly T[]) => [U, TResult[]];
1043
1044/**
1045 * The mapAccumRight function behaves like a combination of map and reduce.
1046 */
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[]];
1049export function mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: readonly T[]) => [U, TResult[]];
1050
1051/**
1052 * Like mapObj, but but passes additional arguments to the predicate function.
1053 */
1054type PartialRecord<K extends keyof any, T> = {
1055 [P in K]?: T;
1056};
1057export function mapObjIndexed<T, TResult, TKey extends string>(
1058 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult,
1059 obj: Record<TKey, T>
1060): Record<TKey, TResult>;
1061export function mapObjIndexed<T, TResult, TKey extends string>(
1062 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult,
1063 obj: PartialRecord<TKey, T>
1064): PartialRecord<TKey, TResult>;
1065export function mapObjIndexed<T, TResult, TKey extends string>(
1066 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult
1067): (obj: Record<TKey, T>) => Record<TKey, TResult>;
1068export function mapObjIndexed<T, TResult, TKey extends string>(
1069 fn: (value: T, key: TKey, obj?: PartialRecord<TKey, T>) => TResult
1070): (obj: Record<TKey, T>) => PartialRecord<TKey, TResult>;
1071export function mapObjIndexed<T, TResult>(
1072 fn: (value: T, key: string, obj?: {
1073 [key: string]: T
1074 }) => TResult,
1075 obj: {
1076 [key: string]: T
1077 }
1078): {
1079 [key: string]: TResult
1080};
1081/**
1082 * Tests a regular expression agains a String
1083 */
1084export function match(regexp: RegExp, str: string): string[];
1085export function match(regexp: RegExp): (str: string) => string[];
1086
1087/**
1088 * mathMod behaves like the modulo operator should mathematically, unlike the `%`
1089 * operator (and by extension, R.modulo). So while "-17 % 5" is -2,
1090 * mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN
1091 * when the modulus is zero or negative.
1092 */
1093export function mathMod(__: Placeholder, b: number): (a: number) => number;
1094export function mathMod(__: Placeholder): (b: number, a: number) => number;
1095export function mathMod(a: number, b: number): number;
1096export function mathMod(a: number): (b: number) => number;
1097
1098/**
1099 * Returns the larger of its two arguments.
1100 */
1101export function max<T extends Ord>(a: T, b: T): T;
1102export function max<T extends Ord>(a: T): (b: T) => T;
1103
1104/**
1105 * Takes a function and two values, and returns whichever value produces
1106 * the larger result when passed to the provided function.
1107 */
1108export function maxBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T;
1109export function maxBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T;
1110export function maxBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>;
1111
1112/**
1113 * Returns the mean of the given list of numbers.
1114 */
1115export function mean(list: readonly number[]): number;
1116
1117/**
1118 * Returns the median of the given list of numbers.
1119 */
1120export function median(list: readonly number[]): number;
1121
1122/**
1123 * Creates a new function that, when invoked, caches the result of calling fn for a given argument set and returns the result.
1124 * 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.
1125 */
1126export function memoizeWith<T extends (...args: readonly any[]) => any>(keyFn: (...v: Parameters<T>) => string, fn: T): T;
1127
1128/**
1129 * Create a new object with the own properties of a
1130 * merged with the own properties of object b.
1131 * This function will *not* mutate passed-in objects.
1132 *
1133 * @deprecated since 0.26 in favor of mergeRight
1134 */
1135export function merge<O2 extends object>(__: Placeholder, b: O2): <O1 extends object>(a: O1) => Merge<O2, O1, 'flat'>;
1136export function merge(__: Placeholder): <O1 extends object, O2 extends object>(b: O2, a: O1) => Merge<O2, O1, 'flat'>;
1137export function merge<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O2, O1, 'flat'>;
1138export function merge<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O2, O1, 'flat'>;
1139
1140/**
1141 * Merges a list of objects together into one object.
1142 */
1143export function mergeAll<Os extends readonly object[]>(list: Os): MergeAll<Os>;
1144/**
1145 * Creates a new object with the own properties of the first object merged with the own properties of the second object.
1146 * If a key exists in both objects:
1147 * and both values are objects, the two values will be recursively merged
1148 * otherwise the value from the first object will be used.
1149 */
1150export function mergeDeepLeft<O1 extends object, O2 extends object>(o1: O1, o2: O2): Merge<O1, O2, 'deep'>;
1151export function mergeDeepLeft<O1 extends object>(o1: O1): <O2 extends object>(o2: O2) => Merge<O1, O2, 'deep'>;
1152
1153/**
1154 * Creates a new object with the own properties of the first object merged with the own properties of the second object.
1155 * If a key exists in both objects:
1156 * and both values are objects, the two values will be recursively merged
1157 * otherwise the value from the second object will be used.
1158 */
1159export function mergeDeepRight<O1 extends object, O2 extends object>(o1: O1, o2: O2): Merge<O2, O1, 'deep'>;
1160export function mergeDeepRight<O1 extends object>(a: O1): <O2 extends object>(o2: O2) => Merge<O2, O1, 'deep'>;
1161
1162/**
1163 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects:
1164 * and both associated values are also objects then the values will be recursively merged.
1165 * otherwise the provided function is applied to associated values using the resulting value as the new value
1166 * associated with the key. If a key only exists in one object, the value will be associated with the key of the resulting object.
1167 */
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;
1170export function mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any): (a: T1, b: T2) => any;
1171
1172/**
1173 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects:
1174 * and both associated values are also objects then the values will be recursively merged.
1175 * otherwise the provided function is applied to the key and associated values using the resulting value as
1176 * the new value associated with the key. If a key only exists in one object, the value will be associated with
1177 * the key of the resulting object.
1178 */
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;
1181export function mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any): (a: T1, b: T2) => any;
1182
1183/**
1184 * Create a new object with the own properties of the first object merged with the own properties of the second object.
1185 * If a key exists in both objects, the value from the first object will be used.
1186 */
1187export function mergeLeft<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O1, O2, 'flat'>;
1188export function mergeLeft<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O1, O2, 'flat'>;
1189
1190/**
1191 * Create a new object with the own properties of the first object merged with the own properties of the second object.
1192 * If a key exists in both objects, the value from the second object will be used.
1193 */
1194export function mergeRight<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O2, O1, 'flat'>;
1195export function mergeRight<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O2, O1, 'flat'>;
1196
1197/**
1198 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects,
1199 * the provided function is applied to the values associated with the key in each object, with the result being used as
1200 * the value associated with the key in the returned object. The key will be excluded from the returned object if the
1201 * resulting value is undefined.
1202 */
1203export function mergeWith<U, V>(fn: (x: any, z: any) => any, a: U, b: V): any;
1204export function mergeWith<U>(fn: (x: any, z: any) => any, a: U): <V>(b: V) => any;
1205export function mergeWith(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => any;
1206
1207/**
1208 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects,
1209 * the provided function is applied to the key and the values associated with the key in each object, with the
1210 * result being used as the value associated with the key in the returned object. The key will be excluded from
1211 * the returned object if the resulting value is undefined.
1212 */
1213export function mergeWithKey<U, V>(fn: (str: string, x: any, z: any) => any, a: U, b: V): any;
1214export function mergeWithKey<U>(fn: (str: string, x: any, z: any) => any, a: U): <V>(b: V) => any;
1215export function mergeWithKey(fn: (str: string, x: any, z: any) => any): <U, V>(a: U, b: V) => any;
1216
1217/**
1218 * Returns the smaller of its two arguments.
1219 */
1220export function min<T extends Ord>(a: T, b: T): T;
1221export function min<T extends Ord>(a: T): (b: T) => T;
1222
1223/**
1224 * Takes a function and two values, and returns whichever value produces
1225 * the smaller result when passed to the provided function.
1226 */
1227export function minBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T;
1228export function minBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T;
1229export function minBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>;
1230
1231/**
1232 * Divides the second parameter by the first and returns the remainder.
1233 * The flipped version (`moduloBy`) may be more useful curried.
1234 * Note that this functions preserves the JavaScript-style behavior for
1235 * modulo. For mathematical modulo see `mathMod`
1236 */
1237export function modulo(__: Placeholder, b: number): (a: number) => number;
1238export function modulo(__: Placeholder): (b: number, a: number) => number;
1239export function modulo(a: number, b: number): number;
1240export function modulo(a: number): (b: number) => number;
1241
1242/**
1243 * Multiplies two numbers. Equivalent to a * b but curried.
1244 */
1245export function multiply(a: number, b: number): number;
1246export function multiply(a: number): (b: number) => number;
1247
1248/**
1249 * Moves an item, at index `from`, to index `to`, in a `list` of elements.
1250 * A new list will be created containing the new elements order.
1251 */
1252export function move<T>(from: number, to: number, list: readonly T[]): T[];
1253export function move(from: number, to: number): <T>(list: readonly T[]) => T[];
1254export function move(from: number): {
1255 <T>(to: number, list: readonly T[]): T[];
1256 (to: number): <T>(list: readonly T[]) => T[];
1257};
1258
1259/**
1260 * Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters.
1261 * Any extraneous parameters will not be passed to the supplied function.
1262 */
1263export function nAry<N extends number, T extends (...arg: any) => any>(n: N, fn: T): (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>;
1264export function nAry<N extends number>(n: N): <T extends (...arg: any) => any>(fn: T) => (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>;
1265
1266/**
1267 * Negates its argument.
1268 */
1269export function negate(n: number): number;
1270
1271/**
1272 * Returns true if no elements of the list match the predicate, false otherwise.
1273 */
1274export function none<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
1275export function none<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
1276
1277/**
1278 * A function wrapping a call to the given function in a `!` operation. It will return `true` when the
1279 * underlying function would return a false-y value, and `false` when it would return a truth-y one.
1280 */
1281export function not(value: any): boolean;
1282
1283/**
1284 * Returns the nth element in a list.
1285 */
1286export function nth<T>(n: number, list: readonly T[]): T | undefined;
1287export function nth(n: number): <T>(list: readonly T[]) => T | undefined;
1288
1289/**
1290 * Returns a function which returns its nth argument.
1291 */
1292export function nthArg(n: number): (...a: readonly any[]) => any;
1293
1294/**
1295 * o is a curried composition function that returns a unary function. Like compose, o performs right-to-left function composition.
1296 * Unlike compose, the rightmost function passed to o will be invoked with only one argument.
1297 * Also, unlike compose, o is limited to accepting only 2 unary functions.
1298 * The name o was chosen because of its similarity to the mathematical composition operator ∘.
1299 */
1300export function o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2, v: T1): R;
1301export function o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2): (v: T1) => R;
1302export function o<T2, R>(
1303 f: (x: T2) => R,
1304): {
1305 <T1>(g: (x: T1) => T2, v: T1): R;
1306 <T1>(g: (x: T1) => T2): (v: T1) => R;
1307};
1308
1309/**
1310 * Creates an object containing a single key:value pair.
1311 */
1312export function objOf<T, K extends string>(key: K, value: T): Record<K, T>;
1313export function objOf<K extends string>(key: K): <T>(value: T) => Record<K, T>;
1314
1315/**
1316 * Returns a singleton array containing the value provided.
1317 */
1318export function of<T>(x: T): T[];
1319
1320/**
1321 * Returns a partial copy of an object omitting the keys specified.
1322 */
1323export function omit<T, K extends string>(names: readonly K[], obj: T): Omit<T, K>;
1324export function omit<K extends string>(names: readonly K[]): <T>(obj: T) => Omit<T, K>;
1325
1326/**
1327 * Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be
1328 * called once, no matter how many times the returned function is invoked. The first value calculated is
1329 * returned in subsequent invocations.
1330 */
1331export function once<F extends (...a: readonly any[]) => any>(fn: F): F;
1332
1333/**
1334 * A function that returns the first truthy of two arguments otherwise the last argument. Note that this is
1335 * NOT short-circuited, meaning that if expressions are passed they are both evaluated.
1336 * Dispatches to the or method of the first argument if applicable.
1337 */
1338export function or<T, U>(a: T, b: U): T | U;
1339export function or<T>(a: T): <U>(b: U) => T | U;
1340export function or<T extends { or?: ((...a: readonly any[]) => any); }, U>(fn1: T, val2: U): T | U;
1341export function or<T extends { or?: ((...a: readonly any[]) => any); }>(fn1: T): <U>(val2: U) => T | U;
1342
1343/**
1344 * Returns the result of applying the onFailure function to the value inside a failed promise.
1345 * This is useful for handling rejected promises inside function compositions.
1346 */
1347export function otherwise<A, B>(onError: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<B>;
1348export function otherwise<A, B>(onError: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<B>;
1349
1350/**
1351 * Returns the result of "setting" the portion of the given data structure
1352 * focused by the given lens to the given value.
1353 */
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;
1356export function over<S, A>(lens: Lens<S, A>): (fn: (a: A) => A, value: S) => S;
1357
1358/**
1359 * Takes two arguments, fst and snd, and returns [fst, snd].
1360 */
1361export function pair<F, S>(fst: F, snd: S): [F, S];
1362export function pair<F>(fst: F): <S>(snd: S) => [F, S];
1363
1364/**
1365 * Takes a function `f` and a list of arguments, and returns a function `g`.
1366 * When applied, `g` returns the result of applying `f` to the arguments
1367 * provided initially followed by the arguments provided to `g`.
1368 */
1369export function partial<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T;
1370
1371export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0, V1]): (x2: V2) => T;
1372export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0]): (x1: V1, x2: V2) => T;
1373
1374export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1, V2]): (x2: V3) => T;
1375export 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;
1376export 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;
1377
1378export function partial<T>(fn: (...a: readonly any[]) => T, args: readonly any[]): (...a: readonly any[]) => T;
1379
1380/**
1381 * Takes a function `f` and a list of arguments, and returns a function `g`.
1382 * When applied, `g` returns the result of applying `f` to the arguments
1383 * provided to `g` followed by the arguments provided initially.
1384 */
1385export function partialRight<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V1]): (x1: V0) => T;
1386
1387export function partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V1, V2]): (x2: V0) => T;
1388export function partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V2]): (x1: V0, x2: V1) => T;
1389
1390export function partialRight<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V1, V2, V3]): (x0: V0) => T;
1391export 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;
1392export 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;
1393
1394export function partialRight<T>(fn: (...a: readonly any[]) => T, args: readonly any[]): (...a: readonly any[]) => T;
1395
1396/**
1397 * Takes a predicate and a list and returns the pair of lists of elements
1398 * which do and do not satisfy the predicate, respectively.
1399 */
1400export function partition(fn: (a: string) => boolean, list: readonly string[]): [string[], string[]];
1401export function partition<T>(fn: (a: T) => boolean, list: readonly T[]): [T[], T[]];
1402export function partition<T>(fn: (a: T) => boolean): (list: readonly T[]) => [T[], T[]];
1403export function partition(fn: (a: string) => boolean): (list: readonly string[]) => [string[], string[]];
1404
1405/**
1406 * Retrieve the value at a given path.
1407 */
1408export function path<T>(path: Path, obj: any): T | undefined;
1409export function path<T>(path: Path): (obj: any) => T | undefined;
1410
1411/**
1412 * Determines whether a nested path on an object has a specific value,
1413 * in `R.equals` terms. Most likely used to filter a list.
1414 */
1415export function pathEq(path: Path, val: any, obj: any): boolean;
1416export function pathEq(path: Path, val: any): (obj: any) => boolean;
1417export function pathEq(path: Path): _.F.Curry<(a: any, b: any) => boolean>;
1418
1419/**
1420 * If the given, non-null object has a value at the given path, returns the value at that path.
1421 * Otherwise returns the provided default value.
1422 */
1423export function pathOr<T>(defaultValue: T, path: Path, obj: any): T;
1424export function pathOr<T>(defaultValue: T, path: Path): (obj: any) => T;
1425export function pathOr<T>(defaultValue: T): _.F.Curry<(a: Path, b: any) => T>;
1426
1427/**
1428 * Retrieves the values at given paths of an object.
1429 */
1430export function paths<T>(paths: Path[], obj: any): Array<T | undefined>;
1431export function paths<T>(paths: Path[]): (obj: any) => Array<T | undefined>;
1432
1433/**
1434 * Returns true if the specified object property at given path satisfies the given predicate; false otherwise.
1435 */
1436export function pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path, obj: U): boolean;
1437export function pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path): (obj: U) => boolean;
1438export function pathSatisfies<T, U>(pred: (val: T) => boolean): _.F.Curry<(a: Path, b: U) => boolean>;
1439
1440/**
1441 * Returns a partial copy of an object containing only the keys specified. If the key does not exist, the
1442 * property is ignored.
1443 */
1444export function pick<T, K extends string | number | symbol>(names: readonly K[], obj: T): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
1445export function pick<K extends string | number | symbol>(names: readonly K[]): <T>(obj: T) => Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
1446
1447/**
1448 * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist.
1449 */
1450export function pickAll<T, U>(names: readonly string[], obj: T): U;
1451export function pickAll(names: readonly string[]): <T, U>(obj: T) => U;
1452
1453/**
1454 * Returns a partial copy of an object containing only the keys that satisfy the supplied predicate.
1455 */
1456export function pickBy<T, U>(pred: ObjPred<T>, obj: T): U;
1457export function pickBy<T>(pred: ObjPred<T>): <U, V extends T>(obj: V) => U;
1458
1459/**
1460 * Creates a new function that runs each of the functions supplied as parameters in turn,
1461 * passing the return value of each function invocation to the next function invocation,
1462 * beginning with whatever arguments were passed to the initial invocation.
1463 */
1464// tslint:disable:max-line-length
1465export function pipe<T1>(fn0: () => T1): () => T1;
1466export function pipe<V0, T1>(fn0: (x0: V0) => T1): (x0: V0) => T1;
1467export function pipe<V0, V1, T1>(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1;
1468export function pipe<V0, V1, V2, T1>(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1;
1469
1470export function pipe<T1, T2>(fn0: () => T1, fn1: (x: T1) => T2): () => T2;
1471export function pipe<V0, T1, T2>(fn0: (x0: V0) => T1, fn1: (x: T1) => T2): (x0: V0) => T2;
1472export function pipe<V0, V1, T1, T2>(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1) => T2;
1473export 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;
1474
1475export function pipe<T1, T2, T3>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): () => T3;
1476export function pipe<V0, T1, T2, T3>(fn0: (x: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x: V0) => T3;
1477export 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;
1478export 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;
1479
1480export function pipe<T1, T2, T3, T4>(fn0: () => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): () => T4;
1481export 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;
1482export 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;
1483export 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;
1484
1485export 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;
1486export 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;
1487export 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;
1488export 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;
1489
1490export 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;
1491export 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;
1492export 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;
1493export 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;
1494
1495export 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;
1496export 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;
1497export 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;
1498export 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;
1499
1500export 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;
1501export 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;
1502export 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;
1503export 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;
1504
1505export 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;
1506export 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;
1507export 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;
1508export 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;
1509
1510export 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;
1511export 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;
1512export 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;
1513export 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;
1514// tslint:enable:max-line-length
1515
1516/**
1517 * Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain.
1518 * The typings currently support arrays only as return values.
1519 * All functions need to be unary.
1520 * R.pipeK(f, g, h) is equivalent to R.pipe(f, R.chain(g), R.chain(h)).
1521 *
1522 * @deprecated since 0.26 in favor of pipeWith(chain)
1523 */
1524// tslint:disable:max-line-length
1525export function pipeK<V0, T1>(fn0: (x0: V0) => T1[]): (x0: V0) => T1[];
1526export function pipeK<V0, T1, T2>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[]): (x0: V0) => T2[];
1527export function pipeK<V0, T1, T2, T3>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[]): (x: V0) => T3[];
1528export 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[];
1529export 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[];
1530export 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[];
1531export 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[];
1532export 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[];
1533export 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[];
1534export 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[];
1535// tslint:enable:max-line-length
1536
1537/**
1538 * Performs left-to-right composition of one or more Promise-returning functions.
1539 * All functions need to be unary.
1540 *
1541 * @deprecated since 0.26 in favor of pipeWith(then)
1542 */
1543// tslint:disable:max-line-length
1544export function pipeP<V0, T1>(fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T1>;
1545export function pipeP<V0, T1, T2>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>): (x0: V0) => Promise<T2>;
1546export 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>;
1547export 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>;
1548export 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>;
1549export 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>;
1550export 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>;
1551export 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>;
1552export 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>;
1553export 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>;
1554// tslint:enable:max-line-length
1555
1556/*
1557 * Performs left-to-right function composition using transforming function.
1558 * With the current typings, all functions must be unary.
1559 */
1560export function pipeWith<V0, T>(composer: (f: (value: any) => any, res: any) => any, fns: PipeWithFns<V0, T>): (x0: V0) => T;
1561export function pipeWith(composer: (f: (value: any) => any, res: any) => any): <V0, T>(fns: PipeWithFns<V0, T>) => (x0: V0) => T;
1562
1563/**
1564 * Returns a new list by plucking the same named property off all objects in the list supplied.
1565 */
1566export function pluck<K extends keyof T, T>(p: K, list: readonly T[]): Array<T[K]>;
1567export function pluck<T>(p: number, list: Array<{ [k: number]: T }>): T[];
1568export function pluck<P extends string>(p: P): <T>(list: Array<Record<P, T>>) => T[];
1569export function pluck(p: number): <T>(list: Array<{ [k: number]: T }>) => T[];
1570
1571/**
1572 * Returns a new list with the given element at the front, followed by the contents of the
1573 * list.
1574 */
1575export function prepend<T>(el: T, list: readonly T[]): T[];
1576export function prepend<T>(el: T): (list: readonly T[]) => T[];
1577
1578/**
1579 * Multiplies together all the elements of a list.
1580 */
1581export function product(list: readonly number[]): number;
1582
1583/**
1584 * Reasonable analog to SQL `select` statement.
1585 */
1586export function project<T, U>(props: readonly string[], objs: readonly T[]): U[];
1587export function project<T, U>(props: readonly string[]): (objs: readonly T[]) => U[];
1588
1589/**
1590 * Returns a function that when supplied an object returns the indicated property of that object, if it exists.
1591 */
1592export function prop<T>(__: Placeholder, obj: T): <P extends keyof T>(p: P) => T[P];
1593export function prop<P extends keyof T, T>(p: P, obj: T): T[P];
1594export function prop<P extends string>(p: P): <T>(obj: Record<P, T>) => T;
1595export function prop<P extends string, T>(p: P): (obj: Record<P, T>) => T;
1596
1597/**
1598 * Determines whether the given property of an object has a specific
1599 * value according to strict equality (`===`). Most likely used to
1600 * filter a list.
1601 */
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, val: any): (obj: Record<K, any>) => boolean;
1604export function propEq<K extends string | number>(name: K): {
1605 (val: any, obj: Record<K, any>): boolean;
1606 (val: any): (obj: Record<K, any>) => boolean;
1607};
1608
1609/**
1610 * Returns true if the specified object property is of the given type; false otherwise.
1611 */
1612export function propIs(type: any, name: string, obj: any): boolean;
1613export function propIs(type: any, name: string): (obj: any) => boolean;
1614export function propIs(type: any): {
1615 (name: string, obj: any): boolean;
1616 (name: string): (obj: any) => boolean;
1617};
1618
1619/**
1620 * If the given, non-null object has an own property with the specified name, returns the value of that property.
1621 * Otherwise returns the provided default value.
1622 */
1623export function propOr<T, U>(val: T, __: Placeholder, obj: U): <V>(p: string) => V;
1624export function propOr<U>(__: Placeholder, p: string, obj: U): <T, V>(val: T) => V;
1625export function propOr<T, U, V>(val: T, p: string, obj: U): V;
1626export function propOr<T>(val: T, p: string): <U, V>(obj: U) => V;
1627export function propOr<T>(val: T): <U, V>(p: string, obj: U) => V;
1628
1629/**
1630 * Returns the value at the specified property.
1631 * The only difference from `prop` is the parameter order.
1632 * Note: TS1.9 # replace any by dictionary
1633 */
1634export function props<P extends string, T>(ps: readonly P[], obj: Record<P, T>): T[];
1635export function props<P extends string>(ps: readonly P[]): <T>(obj: Record<P, T>) => T[];
1636export function props<P extends string, T>(ps: readonly P[]): (obj: Record<P, T>) => T[];
1637
1638/**
1639 * Returns true if the specified object property satisfies the given predicate; false otherwise.
1640 */
1641export function propSatisfies<T, U>(pred: (val: T) => boolean, name: string, obj: U): boolean;
1642export function propSatisfies<T, U>(pred: (val: T) => boolean, name: string): (obj: U) => boolean;
1643export function propSatisfies<T, U>(pred: (val: T) => boolean): _.F.Curry<(a: string, b: U) => boolean>;
1644
1645/**
1646 * Returns a list of numbers from `from` (inclusive) to `to`
1647 * (exclusive). In mathematical terms, `range(a, b)` is equivalent to
1648 * the half-open interval `[a, b)`.
1649 */
1650export function range(from: number, to: number): number[];
1651export function range(from: number): (to: number) => number[];
1652
1653/**
1654 * Returns a single item by iterating through the list, successively calling the iterator
1655 * function and passing it an accumulator value and the current value from the array, and
1656 * then passing the result to the next call.
1657 */
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;
1660export function reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>, acc: TResult): (list: readonly T[]) => TResult;
1661
1662/**
1663 * Groups the elements of the list according to the result of calling the String-returning function keyFn on each
1664 * element and reduces the elements of each group to a single value via the reducer function valueFn.
1665 */
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, keyFn: (elem: T) => string): (list: readonly T[]) => { [index: string]: TResult };
1668export function reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult): _.F.Curry<(a: (elem: T) => string, b: readonly T[]) => { [index: string]: TResult }>;
1669export function reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult): _.F.Curry<(a: TResult, b: (elem: T) => string, c: readonly T[]) => { [index: string]: TResult }>;
1670
1671/**
1672 * Returns a value wrapped to indicate that it is the final value of the reduce and
1673 * transduce functions. The returned value should be considered a black box: the internal
1674 * structure is not guaranteed to be stable.
1675 */
1676export function reduced<T>(elem: T): Reduced<T>;
1677
1678/**
1679 * Returns a single item by iterating through the list, successively calling the iterator
1680 * function and passing it an accumulator value and the current value from the array, and
1681 * then passing the result to the next call.
1682 */
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;
1685export function reduceRight<T, TResult>(fn: (elem: T, acc: TResult) => TResult, acc: TResult): (list: readonly T[]) => TResult;
1686
1687/**
1688 * Like reduce, reduceWhile returns a single item by iterating through the list, successively
1689 * calling the iterator function. reduceWhile also takes a predicate that is evaluated before
1690 * each step. If the predicate returns false, it "short-circuits" the iteration and returns
1691 * the current value of the accumulator.
1692 */
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, acc: TResult): (list: readonly T[]) => TResult;
1695export function reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult): _.F.Curry<(a: TResult, b: readonly T[]) => TResult>;
1696export function reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean): _.F.Curry<(a: (acc: TResult, elem: T) => TResult, b: TResult, c: readonly T[]) => TResult>;
1697
1698/**
1699 * Similar to `filter`, except that it keeps only values for which the given predicate
1700 * function returns falsy.
1701 */
1702export const reject: Filter;
1703
1704/**
1705 * Removes the sub-list of `list` starting at index `start` and containing `count` elements.
1706 */
1707export function remove<T>(start: number, count: number, list: readonly T[]): T[];
1708export function remove<T>(start: number): (count: number, list: readonly T[]) => T[];
1709export function remove<T>(start: number, count: number): (list: readonly T[]) => T[];
1710
1711/**
1712 * Returns a fixed list of size n containing a specified identical value.
1713 */
1714export function repeat<T>(a: T, n: number): T[];
1715export function repeat<T>(a: T): (n: number) => T[];
1716
1717/**
1718 * Replace a substring or regex match in a string with a replacement.
1719 */
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;
1722export function replace(pattern: RegExp | string): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => (str: string) => string;
1723
1724/**
1725 * Returns a new list with the same elements as the original list, just in the reverse order.
1726 */
1727export function reverse<T>(list: readonly T[]): T[];
1728/**
1729 * Returns a new string with the characters in reverse order.
1730 */
1731export function reverse(str: string): string;
1732
1733/**
1734 * Scan is similar to reduce, but returns a list of successively reduced values from the left.
1735 */
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[];
1738export function scan<T, TResult>(fn: (acc: TResult, elem: T) => any): (acc: TResult, list: readonly T[]) => TResult[];
1739
1740/**
1741 * Returns the result of "setting" the portion of the given data structure focused by the given lens to the
1742 * given value.
1743 */
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;
1746export function set<S, A>(lens: Lens<S, A>): (a: A, obj: S) => S;
1747
1748/**
1749 * Returns the elements from `xs` starting at `a` and ending at `b - 1`.
1750 */
1751export function slice(a: number, b: number, list: string): string;
1752export function slice<T>(a: number, b: number, list: readonly T[]): T[];
1753export function slice(a: number, b: number): {
1754 (list: string): string;
1755 <T>(list: readonly T[]): T[];
1756};
1757export function slice(a: number): {
1758 (b: number, list: string): string;
1759 <T>(b: number, list: readonly T[]): T[];
1760};
1761
1762/**
1763 * Returns a copy of the list, sorted according to the comparator function, which should accept two values at a
1764 * time and return a negative number if the first value is smaller, a positive number if it's larger, and zero
1765 * if they are equal.
1766 */
1767export function sort<T>(fn: (a: T, b: T) => number, list: readonly T[]): T[];
1768export function sort<T>(fn: (a: T, b: T) => number): (list: readonly T[]) => T[];
1769
1770/**
1771 * Sorts the list according to a key generated by the supplied function.
1772 */
1773export function sortBy<T>(fn: (a: T) => Ord, list: readonly T[]): T[];
1774export function sortBy<T>(fn: (a: T) => Ord): (list: readonly T[]) => T[];
1775export function sortBy(fn: (a: any) => Ord): <T>(list: readonly T[]) => T[];
1776
1777/**
1778 * Sorts a list according to a list of comparators.
1779 */
1780export function sortWith<T>(fns: Array<((a: T, b: T) => number)>, list: readonly T[]): T[];
1781export function sortWith<T>(fns: Array<((a: T, b: T) => number)>): (list: readonly T[]) => T[];
1782
1783/**
1784 * Splits a string into an array of strings based on the given
1785 * separator.
1786 */
1787export function split(sep: string | RegExp): (str: string) => string[];
1788export function split(sep: string | RegExp, str: string): string[];
1789
1790/**
1791 * Splits a given list or string at a given index.
1792 */
1793export function splitAt<T>(index: number, list: readonly T[]): [T[], T[]];
1794export function splitAt(index: number, list: string): [string, string];
1795export function splitAt(index: number): {
1796 <T>(list: readonly T[]): [T[], T[]];
1797 (list: string): [string, string];
1798};
1799
1800/**
1801 * Splits a collection into slices of the specified length.
1802 */
1803export function splitEvery<T>(a: number, list: readonly T[]): T[][];
1804export function splitEvery(a: number, list: string): string[];
1805export function splitEvery(a: number): {
1806 (list: string): string[];
1807 <T>(list: readonly T[]): T[][];
1808};
1809
1810/**
1811 * Takes a list and a predicate and returns a pair of lists with the following properties:
1812 * - the result of concatenating the two output lists is equivalent to the input list;
1813 * - none of the elements of the first output list satisfies the predicate; and
1814 * - if the second output list is non-empty, its first element satisfies the predicate.
1815 */
1816export function splitWhen<T, U>(pred: (val: T) => boolean, list: readonly U[]): U[][];
1817export function splitWhen<T>(pred: (val: T) => boolean): <U>(list: readonly U[]) => U[][];
1818
1819/**
1820 * Checks if a list starts with the provided values
1821 */
1822export function startsWith(a: string, list: string): boolean;
1823export function startsWith(a: string): (list: string) => boolean;
1824export function startsWith<T>(a: T | readonly T[], list: readonly T[]): boolean;
1825export function startsWith<T>(a: T | readonly T[]): (list: readonly T[]) => boolean;
1826
1827/**
1828 * Subtracts two numbers. Equivalent to `a - b` but curried.
1829 */
1830export function subtract(__: Placeholder, b: number): (a: number) => number;
1831export function subtract(__: Placeholder): (b: number, a: number) => number;
1832export function subtract(a: number, b: number): number;
1833export function subtract(a: number): (b: number) => number;
1834
1835/**
1836 * Adds together all the elements of a list.
1837 */
1838export function sum(list: readonly number[]): number;
1839
1840/**
1841 * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.
1842 */
1843export function symmetricDifference<T>(list1: readonly T[], list2: readonly T[]): T[];
1844export function symmetricDifference<T>(list: readonly T[]): <T>(list: readonly T[]) => T[];
1845
1846/**
1847 * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.
1848 * Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
1849 */
1850export function symmetricDifferenceWith<T>(pred: (a: T, b: T) => boolean, list1: readonly T[], list2: readonly T[]): T[];
1851export function symmetricDifferenceWith<T>(pred: (a: T, b: T) => boolean): _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>;
1852
1853/**
1854 * A function that always returns true. Any passed in parameters are ignored.
1855 */
1856export function T(): boolean;
1857
1858/**
1859 * Returns all but the first element of a list or string.
1860 */
1861export function tail(list: string): string;
1862export function tail<T extends any>(list: readonly T[]): T[];
1863
1864/**
1865 * Returns a new list containing the first `n` elements of the given list. If
1866 * `n > * list.length`, returns a list of `list.length` elements.
1867 */
1868export function take<T>(n: number, xs: readonly T[]): T[];
1869export function take(n: number, xs: string): string;
1870export function take(n: number): {
1871 (xs: string): string;
1872 <T>(xs: readonly T[]): T[];
1873};
1874
1875/**
1876 * Returns a new list containing the last n elements of the given list. If n > list.length,
1877 * returns a list of list.length elements.
1878 */
1879export function takeLast<T>(n: number, xs: readonly T[]): T[];
1880export function takeLast(n: number, xs: string): string;
1881export function takeLast(n: number): {
1882 <T>(xs: readonly T[]): T[];
1883 (xs: string): string;
1884};
1885
1886/**
1887 * Returns a new list containing the last n elements of a given list, passing each value
1888 * to the supplied predicate function, and terminating when the predicate function returns
1889 * false. Excludes the element that caused the predicate function to fail. The predicate
1890 * function is passed one argument: (value).
1891 */
1892export function takeLastWhile<T>(pred: (a: T) => boolean, list: readonly T[]): T[];
1893export function takeLastWhile<T>(pred: (a: T) => boolean): <T>(list: readonly T[]) => T[];
1894
1895/**
1896 * Returns a new list containing the first `n` elements of a given list, passing each value
1897 * to the supplied predicate function, and terminating when the predicate function returns
1898 * `false`.
1899 */
1900export function takeWhile<T>(fn: (x: T) => boolean, list: readonly T[]): T[];
1901export function takeWhile<T>(fn: (x: T) => boolean): (list: readonly T[]) => T[];
1902
1903/**
1904 * The function to call with x. The return value of fn will be thrown away.
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