UNPKG

215 kBTypeScriptView Raw
1// Type definitions for ramda 0.28
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// Simon Højberg <https://github.com/hojberg>
10// Samson Keung <https://github.com/samsonkeung>
11// Angelo Ocana <https://github.com/angeloocana>
12// Rayner Pupo <https://github.com/raynerd>
13// Nikita Moshensky <https://github.com/moshensky>
14// Ethan Resnick <https://github.com/ethanresnick>
15// Tomas Szabo <https://github.com/deftomat>
16// Maciek Blim <https://github.com/blimusiek>
17// Marcin Biernat <https://github.com/biern>
18// Rayhaneh Banyassady <https://github.com/rayhaneh>
19// Ryan McCuaig <https://github.com/rgm>
20// Drew Wyatt <https://github.com/drewwyatt>
21// John Ottenlips <https://github.com/jottenlips>
22// Nitesh Phadatare <https://github.com/minitesh>
23// Krantisinh Deshmukh <https://github.com/krantisinh>
24// Aram Kharazyan <https://github.com/nemo108>
25// Jituan Lin <https://github.com/jituanlin>
26// Philippe Mills <https://github.com/Philippe-mills>
27// Saul Mirone <https://github.com/Saul-Mirone>
28// Nicholai Nissen <https://github.com/Nicholaiii>
29// Jorge Santana <https://github.com/LORDBABUINO>
30// Mikael Couzic <https://github.com/couzic>
31// Nikita Balikhin <https://github.com/NEWESTERS>
32// Wang Zengdi <https://github.com/adispring>
33// Marcus Blättermann <https://github.com/essenmitsosse>
34// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
35// TypeScript Version: 4.2
36
37import * as _ from 'ts-toolbelt';
38import {
39 AnyConstructor,
40 AnyFunction,
41 AtLeastOneFunctionsFlow,
42 AtLeastOneFunctionsFlowFromRightToLeft,
43 AssocPartialOne,
44 CondPair,
45 CondPairTypeguard,
46 Dictionary,
47 Evolvable,
48 Evolve,
49 Evolver,
50 Falsy,
51 Find,
52 Functor,
53 InputTypesOfFns,
54 KeyValuePair,
55 Lens,
56 Merge,
57 MergeAll,
58 ObjectHavingSome,
59 ObjPred,
60 Ord,
61 Ordering,
62 Path,
63 Placeholder,
64 Pred,
65 PredTypeguard,
66 Reduced,
67 ReturnTypesOfFns,
68 ValueOfUnion,
69 Take,
70 ToTupleOfArray,
71 ToTupleOfFunction,
72 Tuple,
73 Fn,
74 IfFunctionsArgumentsDoNotOverlap,
75 LargestArgumentsList,
76 mergeArrWithLeft,
77 Prop,
78} from './tools';
79
80export * from './tools';
81
82// NOTE: Example doesn't work with current level of support
83/**
84 * A special placeholder value used to specify "gaps" within curried functions,
85 * allowing partial application of any combination of arguments, regardless of their positions.
86 *
87 * If `g` is a curried ternary function and `_` is `R.__`, the following are equivalent:
88 * - `g(1, 2, 3)`
89 * - `g(_, 2, 3)(1)`
90 * - `g(_, _, 3)(1)(2)`
91 * - `g(_, _, 3)(1, 2)`
92 * - `g(_, 2, _)(1, 3)`
93 * - `g(_, 2)(1)(3)`
94 * - `g(_, 2)(1, 3)`
95 * - `g(_, 2)(_, 3)(1)`
96 *
97 * @example
98 * ```typescript
99 * const greet = R.replace('{name}', R.__, 'Hello, {name}!');
100 * greet('Alice'); //=> 'Hello, Alice!'
101 * ```
102 */
103export const __: Placeholder;
104
105/**
106 * Adds two values. Equivalent to `a + b` but curried.
107 *
108 * @example
109 * ```typescript
110 * R.add(2, 3); //=> 5
111 * R.add(7)(10); //=> 17
112 * ```
113 */
114export function add(a: number, b: number): number;
115export function add(a: number): (b: number) => number;
116
117/**
118 * Creates a new list iteration function from an existing one by adding two new parameters to its callback
119 * function: the current index, and the entire list.
120 *
121 * This would turn, for instance, {@link map `R.map`} function into one that more closely resembles `Array.prototype.map`.
122 *
123 * @note This will only work for functions in which the iteration callback function is the first parameter,
124 * and where the list is the last parameter.
125 * (This latter might be unimportant if the list parameter is not used.)
126 *
127 * See also {@link subtract}.
128 *
129 * @example
130 * ```typescript
131 * const mapIndexed = R.addIndex(R.map);
132 * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
133 * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']
134 * ```
135 */
136/* Special case for forEach */
137export function addIndex<T>(
138 fn: (f: (item: T) => void, list: readonly T[]) => T[],
139): _.F.Curry<(a: (item: T, idx: number, list: T[]) => void, b: readonly T[]) => T[]>;
140/* Special case for filter */
141export function addIndex<T>(
142 fn: (f: (item: T) => boolean, list: readonly T[]) => T[],
143): _.F.Curry<(a: (item: T, idx: number, list: T[]) => boolean, b: readonly T[]) => T[]>;
144/* Special case for map */
145export function addIndex<T, U>(
146 fn: (f: (item: T) => U, list: readonly T[]) => U[],
147): _.F.Curry<(a: (item: T, idx: number, list: T[]) => U, b: readonly T[]) => U[]>;
148/* Special case for reduce */
149export function addIndex<T, U>(
150 fn: (f: (acc: U, item: T) => U, aci: U, list: readonly T[]) => U,
151): _.F.Curry<(a: (acc: U, item: T, idx: number, list: T[]) => U, b: U, c: readonly T[]) => U>;
152
153/**
154 * Applies a function to the value at the given index of an array, returning a new copy of the array with the
155 * element at the given index replaced with the result of the function application.
156 *
157 * See also {@link update}.
158 *
159 * @example
160 * ```typescript
161 * R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'B', 'c', 'd']
162 * R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D']
163 * ```
164 */
165export function adjust<T>(index: number, fn: (a: T) => T, list: readonly T[]): T[];
166export function adjust<T>(index: number, fn: (a: T) => T): (list: readonly T[]) => T[];
167
168/**
169 * Returns `true` if all elements of the list match the predicate, `false` if there are any that don't.
170 *
171 * Dispatches to the `all` method of the second argument, if present.
172 *
173 * Acts as a transducer if a transformer is given in list position.
174 *
175 * See also {@link any}, {@link none}, {@link transduce}.
176 *
177 * @example
178 * ```typescript
179 * const equals3 = R.equals(3);
180 * R.all(equals3)([3, 3, 3, 3]); //=> true
181 * R.all(equals3)([3, 3, 1, 3]); //=> false
182 * ```
183 */
184export function all<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
185export function all<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
186
187/**
188 * Takes a list of predicates and returns a predicate that returns true for a given list of arguments
189 * if every one of the provided predicates is satisfied by those arguments.
190 *
191 * The function returned is a curried function whose arity matches that of the highest-arity predicate.
192 *
193 * See also {@link anyPass}.
194 *
195 * @example
196 * ```typescript
197 * type Card = { rank: string; suit: string; };
198 *
199 * const isQueen = R.propEq('rank', 'Q');
200 * const isSpade = R.propEq('suit', '♠︎');
201 * const isQueenOfSpades = R.allPass<R.Pred<[Card]>>([isQueen, isSpade]);
202 *
203 * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
204 * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true
205 * ```
206 */
207export function allPass<T, TF1 extends T, TF2 extends T>(
208 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>],
209): (a: T) => a is TF1 & TF2;
210export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
211 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
212): (a: T) => a is TF1 & TF2 & TF3;
213export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
214 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
215): (a: T) => a is TF1 & TF2 & TF3;
216export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T>(
217 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>, PredTypeguard<T, TF4>],
218): (a: T) => a is TF1 & TF2 & TF3 & TF4;
219export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T>(
220 preds: [
221 PredTypeguard<T, TF1>,
222 PredTypeguard<T, TF2>,
223 PredTypeguard<T, TF3>,
224 PredTypeguard<T, TF4>,
225 PredTypeguard<T, TF5>,
226 ],
227): PredTypeguard<T, TF1 & TF2 & TF3 & TF4 & TF5>;
228export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, TF6 extends T>(
229 preds: [
230 PredTypeguard<T, TF1>,
231 PredTypeguard<T, TF2>,
232 PredTypeguard<T, TF3>,
233 PredTypeguard<T, TF4>,
234 PredTypeguard<T, TF5>,
235 PredTypeguard<T, TF6>,
236 ],
237): PredTypeguard<T, TF1 & TF2 & TF3 & TF4 & TF5 & TF6>;
238export function allPass<F extends Pred>(preds: readonly F[]): F;
239
240/**
241 * Returns a function that always returns the given value.
242 *
243 * @note For non-primitives the value returned is a reference to the original value.
244 *
245 * This function is known as `const`, `constant`, or `K` (for K combinator) in other languages and libraries.
246 *
247 * @example
248 * ```typescript
249 * const t = R.always('Tee');
250 * t(); //=> 'Tee'
251 * ```
252 */
253export function always<T>(val: T): (...args: unknown[]) => T;
254
255/**
256 * A function that returns the first argument if it's falsy otherwise the second argument.
257 *
258 * See also {@link both}, {@link or}, {@link xor}.
259 *
260 * @note This is **not** short-circuited, meaning that if expressions are passed they are both evaluated.
261 *
262 * @example
263 * ```typescript
264 * R.and(true, true); //=> true
265 * R.and(true, false); //=> false
266 * R.and(false, true); //=> false
267 * R.and(false, false); //=> false
268 * ```
269 */
270export function and<T, U>(a: T, b: U): T | U;
271export function and<T>(a: T): <U>(b: U) => T | U;
272
273/**
274 * Returns the result of applying the `onSuccess` function to the value inside a successfully resolved `Promise`.
275 * This is useful for working with `Promise`s inside function compositions.
276 *
277 * See also {@link otherwise}.
278 *
279 * @example
280 * ```typescript
281 * type Query = { query: { email: string; }; };
282 *
283 * const makeQuery = (email: string) => ({ query: { email }});
284 * const fetchMember = (request: Query) =>
285 * Promise.resolve({ firstName: 'Bob', lastName: 'Loblaw', id: 42 });
286 *
287 * //getMemberName :: String -> Promise ({ firstName, lastName })
288 * const getMemberName = R.pipe(
289 * makeQuery,
290 * fetchMember,
291 * R.andThen(R.pick(['firstName', 'lastName']))
292 * );
293 *
294 * getMemberName('bob@gmail.com').then(console.log);
295 * ```
296 */
297export function andThen<A, B>(onSuccess: (a: A) => B | Promise<B>, promise: Promise<A>): Promise<B>;
298export function andThen<A, B>(onSuccess: (a: A) => B | Promise<B>): (promise: Promise<A>) => Promise<B>;
299
300/**
301 * Returns `true` if at least one of elements of the list match the predicate, `false` otherwise.
302 *
303 * Dispatches to the `any` method of the second argument, if present.
304 *
305 * Acts as a transducer if a transformer is given in list position.
306 *
307 * See also {@link all}, {@link none}, {@link transduce}.
308 *
309 * @example
310 * ```typescript
311 * const lessThan0 = R.flip(R.lt)(0);
312 * const lessThan2 = R.flip(R.lt)(2);
313 * R.any(lessThan0)([1, 2]); //=> false
314 * R.any(lessThan2)([1, 2]); //=> true
315 * ```
316 */
317export function any<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
318export function any<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
319
320/**
321 * Takes a list of predicates and returns a predicate that returns true for a
322 * given list of arguments if at least one of the provided predicates is
323 * satisfied by those arguments.
324 *
325 * The function returned is a curried function whose arity matches that of the
326 * highest-arity predicate.
327 *
328 * See also {@link allPass}.
329 *
330 * @example
331 * ```typescript
332 * type Card = { rank: string; suit: string; };
333 *
334 * const isClub = R.propEq('suit', '♣');
335 * const isSpade = R.propEq('suit', '♠');
336 * const isBlackCard = R.anyPass<R.Pred<[Card]>>([isClub, isSpade]);
337 *
338 * isBlackCard({rank: '10', suit: '♣'}); //=> true
339 * isBlackCard({rank: 'Q', suit: '♠'}); //=> true
340 * isBlackCard({rank: 'Q', suit: '♦'}); //=> false
341 * ```
342 */
343export function anyPass<T, TF1 extends T, TF2 extends T>(
344 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>],
345): (a: T) => a is TF1 | TF2;
346export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
347 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
348): (a: T) => a is TF1 | TF2 | TF3;
349export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
350 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
351): (a: T) => a is TF1 | TF2 | TF3;
352export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T>(
353 preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>, PredTypeguard<T, TF4>],
354): (a: T) => a is TF1 | TF2 | TF3 | TF4;
355export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T>(
356 preds: [
357 PredTypeguard<T, TF1>,
358 PredTypeguard<T, TF2>,
359 PredTypeguard<T, TF3>,
360 PredTypeguard<T, TF4>,
361 PredTypeguard<T, TF5>,
362 ],
363): PredTypeguard<T, TF1 | TF2 | TF3 | TF4 | TF5>;
364export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, TF6 extends T>(
365 preds: [
366 PredTypeguard<T, TF1>,
367 PredTypeguard<T, TF2>,
368 PredTypeguard<T, TF3>,
369 PredTypeguard<T, TF4>,
370 PredTypeguard<T, TF5>,
371 PredTypeguard<T, TF6>,
372 ],
373): PredTypeguard<T, TF1 | TF2 | TF3 | TF4 | TF5 | TF6>;
374export function anyPass<F extends Pred>(preds: readonly F[]): F;
375
376/**
377 * `ap` applies a list of functions to a list of values.
378 *
379 * Dispatches to the `ap` method of the first argument, if present.
380 * Also treats curried functions as applicatives.
381 *
382 * @example
383 * ```typescript
384 * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6]
385 * R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"]
386 *
387 * // R.ap can also be used as S combinator
388 * // when only two functions are passed
389 * R.ap((s, s2) => R.concat(s, s2), R.toUpper)('Ramda') //=> 'RamdaRAMDA'
390 * ```
391 */
392export function ap<T, U>(fns: ReadonlyArray<(a: T) => U>, vs: readonly T[]): U[];
393export function ap<T, U>(fns: ReadonlyArray<(a: T) => U>): (vs: readonly T[]) => U[];
394export function ap<R, A, B>(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B;
395
396/**
397 * Returns a new list, composed of n-tuples of consecutive elements.
398 * If `n` is greater than the length of the list, an empty list is returned.
399 *
400 * Acts as a transducer if a transformer is given in list position.
401 *
402 * See also {@link transduce}.
403 *
404 * @example
405 * ```typescript
406 * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
407 * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
408 * R.aperture(7, [1, 2, 3, 4, 5]); //=> []
409 * ```
410 */
411export function aperture<N extends number, T>(n: N, list: readonly T[]): Array<Tuple<T, N>> | [];
412export function aperture<N extends number>(n: N): <T>(list: readonly T[]) => Array<Tuple<T, N>> | [];
413
414/**
415 * Returns a new list containing the contents of the given list, followed by the given element.
416 *
417 * See also {@link prepend}.
418 *
419 * @example
420 * ```typescript
421 * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
422 * R.append('tests', []); //=> ['tests']
423 * R.append<string | string[]>(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]
424 * ```
425 */
426export function append<T>(el: T, list: readonly T[]): T[];
427export function append<T>(el: T): (list: readonly T[]) => T[];
428
429/**
430 * Applies function `fn` to the argument list `args`.
431 * This is useful for creating a fixed-arity function from a variadic function.
432 * `fn` should be a bound function if context is significant.
433 *
434 * See also {@link call}, {@link unapply}.
435 */
436export function apply<F extends AnyFunction>(fn: F, args: Parameters<F>): ReturnType<F>;
437export function apply<F extends AnyFunction>(fn: F): (args: Parameters<F>) => ReturnType<F>;
438
439/**
440 * Given a spec object recursively mapping properties to functions,
441 * creates a function producing an object of the same structure,
442 * by mapping each property to the result of calling its associated function with the supplied arguments.
443 *
444 * See also {@link converge}, {@link juxt}.
445 *
446 * @example
447 * ```typescript
448 * const getMetrics = R.applySpec({
449 * sum: R.add,
450 * nested: { mul: R.multiply }
451 * });
452 * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }
453 * ```
454 */
455export function applySpec<Obj extends Record<string, AnyFunction>>(
456 obj: Obj,
457): (...args: Parameters<Obj[keyof Obj]>) => { [Key in keyof Obj]: ReturnType<Obj[Key]> };
458export function applySpec<T>(obj: any): (...args: unknown[]) => T;
459
460/**
461 * Takes a value and applies a function to it.
462 *
463 * This function is also known as the `thrush` combinator.
464 *
465 * @example
466 * ```typescript
467 * const t42 = R.applyTo(42);
468 * t42(R.identity); //=> 42
469 * t42(R.add(1)); //=> 43
470 * ```
471 */
472export function applyTo<T, U>(el: T, fn: (t: T) => U): U;
473export function applyTo<T>(el: T): <U>(fn: (t: T) => U) => U;
474
475/**
476 * Makes an ascending comparator function out of a function that returns a value that can be compared with `<` and `>`.
477 *
478 * See also {@link descend}.
479 *
480 * @example
481 * ```typescript
482 * const byAge = R.ascend(R.prop<number>('age'));
483 * const people = [
484 * { name: 'Emma', age: 70 },
485 * { name: 'Peter', age: 78 },
486 * { name: 'Mikhail', age: 62 },
487 * ];
488 * const peopleByYoungestFirst = R.sort(byAge, people);
489 * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
490 * ```
491 */
492export function ascend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
493export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
494
495/**
496 * Makes a shallow clone of an object, setting or overriding the specified property with the given value.
497 *
498 * @note This copies and flattens prototype properties onto the new object as well.
499 * All non-primitive properties are copied by reference.
500 *
501 * See also {@link dissoc}, {@link pick}.
502 *
503 * @example
504 * ```typescript
505 * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
506 * ```
507 */
508export function assoc<T, U>(__: Placeholder, val: T, obj: U): <K extends string>(prop: K) => K extends keyof U ? T extends U[K] ? U : Record<K, T> & Omit<U, K> : Record<K, T> & Omit<U, K>;
509export function assoc<U, K extends keyof U>(prop: K, __: Placeholder, obj: U): <T>(val: T) => T extends U[K] ? U : Record<K, T> & Omit<U, K>;
510export function assoc<U, K extends string>(prop: K, __: Placeholder, obj: U): <T>(val: T) => Record<K, T> & Omit<U, K>;
511export function assoc<K extends keyof U, U>(prop: K, val: U[K], obj: U): U;
512export function assoc<T, U, K extends string>(prop: K, val: T, obj: U): Record<K, T> & Omit<U, K>;
513export function assoc<T, K extends string>(prop: K, val: T): <U>(obj: U) => Record<K, T> & Omit<U, K>;
514export function assoc<K extends string>(prop: K): AssocPartialOne<K>;
515
516/**
517 * Makes a shallow clone of an object,
518 * setting or overriding the nodes required to create the given path,
519 * and placing the specific value at the tail end of that path.
520 *
521 * @note This copies and flattens prototype properties onto the new object as well.
522 * All non-primitive properties are copied by reference.
523 *
524 * See also {@link dissocPath}.
525 *
526 * @example
527 * ```typescript
528 * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}}
529 *
530 * // Any missing or non-object keys in path will be overridden
531 * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}
532 * ```
533 */
534export function assocPath<T, U>(__: Placeholder, val: T, obj: U): (path: Path) => U;
535export function assocPath<T, U>(path: Path, __: Placeholder, obj: U): (val: T) => U;
536export function assocPath<T, U>(path: Path, val: T, obj: U): U;
537export function assocPath<T, U>(path: Path, val: T): (obj: U) => U;
538export function assocPath<T, U>(path: Path): _.F.Curry<(a: T, b: U) => U>;
539
540/**
541 * Wraps a function of any arity (including nullary) in a function that accepts exactly 2
542 * parameters. Any extraneous parameters will not be passed to the supplied function.
543 *
544 * See also {@link nAry}, {@link unary}.
545 *
546 * @example
547 * ```typescript
548 * const takesThreeArgs = function(a: number, b: number, c: number) {
549 * return [a, b, c];
550 * };
551 * takesThreeArgs.length; //=> 3
552 * takesThreeArgs(1, 2, 3); //=> [1, 2, 3]
553 *
554 * const takesTwoArgs = R.binary(takesThreeArgs);
555 * takesTwoArgs.length; //=> 2
556 * // Only 2 arguments are passed to the wrapped function
557 * // @ts-expect-error TypeScript is designed to not let you do this
558 * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
559 * ```
560 */
561export function binary<T extends AnyFunction>(fn: T): (...arg: _.T.Take<Parameters<T>, '2'>) => ReturnType<T>;
562
563/**
564 * Creates a function that is bound to a context.
565 *
566 * @note `R.bind` does not provide the additional argument-binding capabilities of `Function.prototype.bind`.
567 *
568 * @example
569 * ```typescript
570 * const log = R.bind(console.log, console);
571 * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
572 * // logs {a: 2}
573 * ```
574 */
575export function bind<F extends AnyFunction, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
576export function bind<F extends AnyFunction, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>;
577
578/**
579 * A function which calls the two provided functions and returns the `&&` of the
580 * results. It returns the result of the first function if it is falsy and
581 * the result of the second function otherwise.
582 *
583 * @note This is short-circuited,
584 * meaning that the second function will not be invoked if the first returns a falsy value.
585 *
586 * In addition to functions, `R.both` also accepts any fantasy-land compatible applicative functor.
587 *
588 * See also {@link either}, {@link and}.
589 *
590 * @example
591 * ```typescript
592 * const gt10 = R.gt(R.__, 10)
593 * const lt20 = R.lt(R.__, 20)
594 * const f = R.both(gt10, lt20);
595 * f(15); //=> true
596 * f(30); //=> false
597 * ```
598 */
599export function both<T, TF1 extends T, TF2 extends T>(
600 pred1: PredTypeguard<T, TF1>,
601 pred2: PredTypeguard<T, TF2>,
602): (a: T) => a is TF1 & TF2;
603export function both<T extends Pred>(pred1: T, pred2: T): T;
604export function both<T extends Pred>(pred1: T): (pred2: T) => T;
605
606// NOTE: It is currently difficult to use it as a converging function for `R.converge`
607/**
608 * Returns the result of calling its first argument with the remaining arguments.
609 * This is occasionally useful as a converging function for {@link converge `R.converge`}:
610 * the first branch can produce a function
611 * while the remaining branches produce values to be passed to that function as its arguments.
612 *
613 * See also {@link apply}.
614 *
615 * @example
616 * ```typescript
617 * R.call<(a: number, b: number) => number>(R.add, 1, 2); //=> 3
618 *
619 * const indentN = R.pipe(
620 * R.repeat(' '),
621 * R.join(''),
622 * R.replace(/^(?!$)/gm)
623 * );
624 * ```
625 */
626export function call<T extends AnyFunction>(fn: T, ...args: Parameters<T>): ReturnType<T>;
627
628/**
629 * `chain` maps a function over a list and concatenates the results. `chain` is also known as `flatMap` in some libraries.
630 *
631 * Dispatches to the `chain` method of the second argument, if present, according to the FantasyLand Chain spec.
632 *
633 * If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`.
634 *
635 * Acts as a transducer if a transformer is given in list position.
636 *
637 * See also {@link transduce}.
638 *
639 * @example
640 * ```typescript
641 * const duplicate = <T>(n: T) => [n, n];
642 * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3]
643 *
644 * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1]
645 * ```
646 */
647export function chain<A, B, T = never>(fn: (n: A) => readonly B[], list: readonly A[]): B[];
648export function chain<A, B, T = never>(fn: (n: A) => readonly B[]): (list: readonly A[]) => B[];
649
650export function chain<A, Ma extends { chain: (fn: (a: A) => Mb) => Mb }, Mb>(fn: (a: A) => Mb, monad: Ma): Mb;
651export function chain<A, Ma extends { chain: (fn: (a: A) => Mb) => Mb }, Mb>(fn: (a: A) => Mb): (monad: Ma) => Mb;
652
653export function chain<A, B, R>(aToMb: (a: A, r: R) => B, Ma: (r: R) => A): (r: R) => B;
654export function chain<A, B, R>(aToMb: (a: A, r: R) => B): (Ma: (r: R) => A) => (r: R) => B;
655
656/**
657 * Restricts a number to be within a range.
658 * Also works for other ordered types such as strings and `Date`s.
659 *
660 * @example
661 * ```typescript
662 * R.clamp(1, 10, -5) // => 1
663 * R.clamp(1, 10, 15) // => 10
664 * R.clamp(1, 10, 4) // => 4
665 * ```
666 */
667export function clamp<T>(min: T, max: T, value: T): T;
668export function clamp<T>(min: T, max: T): (value: T) => T;
669export function clamp<T>(min: T): (max: T, value: T) => T;
670export function clamp<T>(min: T): (max: T) => (value: T) => T;
671
672/**
673 * Creates a deep copy of the source that can be used in place of the source object without retaining any references to it.
674 * The source object may contain (nested) `Array`s and `Object`s, numbers, strings, booleans and `Date`s.
675 * `Functions` are assigned by reference rather than copied.
676 *
677 * Dispatches to a `clone` method if present.
678 *
679 * Note that if the source object has multiple nodes that share a reference,
680 * the returned object will have the same structure,
681 * but the references will be pointed to the location within the cloned value.
682 *
683 * @example
684 * ```typescript
685 * const objects = [{}, {}, {}];
686 * const objectsClone = R.clone(objects);
687 * objects === objectsClone; //=> false
688 * objects[0] === objectsClone[0]; //=> false
689 * ```
690 */
691export function clone<T>(value: T): T;
692export function clone<T>(value: readonly T[]): T[];
693
694/**
695 * Splits a list into sub-lists,
696 * based on the result of calling a key-returning function on each element,
697 * and grouping the results according to values returned.
698 *
699 * See also {@link groupBy}, {@link partition}.
700 *
701 * @example
702 * ```typescript
703 * R.collectBy(R.prop('type'), [
704 * {type: 'breakfast', item: '☕️'},
705 * {type: 'lunch', item: '🌯'},
706 * {type: 'dinner', item: '🍝'},
707 * {type: 'breakfast', item: '🥐'},
708 * {type: 'lunch', item: '🍕'}
709 * ]);
710 *
711 * // [ [ {type: 'breakfast', item: '☕️'},
712 * // {type: 'breakfast', item: '🥐'} ],
713 * // [ {type: 'lunch', item: '🌯'},
714 * // {type: 'lunch', item: '🍕'} ],
715 * // [ {type: 'dinner', item: '🍝'} ] ]
716 * ```
717 */
718export function collectBy<T, K extends PropertyKey>(keyFn: (value: T) => K, list: readonly T[]): T[][];
719export function collectBy<T, K extends PropertyKey>(keyFn: (value: T) => K): (list: readonly T[]) => T[][];
720
721/**
722 * Makes a comparator function out of a function that reports whether the first element is less than the second.
723 *
724 * @example
725 * ```typescript
726 * type Person = { name: string; age: number; };
727 *
728 * const byAge = R.comparator<Person>((a, b) => a.age < b.age);
729 * const people = [
730 * { name: 'Emma', age: 70 },
731 * { name: 'Peter', age: 78 },
732 * { name: 'Mikhail', age: 62 },
733 * ];
734 * const peopleByIncreasingAge = R.sort(byAge, people);
735 * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
736 * ```
737 */
738export function comparator<T>(pred: (a: T, b: T) => boolean): (x: T, y: T) => Ordering;
739
740/**
741 * Takes a function `f` and returns a function `g` such that
742 * if called with the same arguments
743 * when `f` returns a truthy value, `g` returns `false`
744 * and when `f` returns a falsy value `g` returns `true`.
745 *
746 * `R.complement` may be applied to any functor.
747 *
748 * See also {@link not}.
749 *
750 * @example
751 * ```typescript
752 * const isNotNil = R.complement(R.isNil);
753 * R.isNil(null); //=> true
754 * isNotNil(null); //=> false
755 * R.isNil(7); //=> false
756 * isNotNil(7); //=> true
757 * ```
758 */
759export function complement<T, TFiltered extends T>(
760 pred: (value: T) => value is TFiltered,
761): (value: T) => value is Exclude<T, TFiltered>;
762export function complement<TArgs extends any[]>(pred: (...args: TArgs) => unknown): (...args: TArgs) => boolean;
763
764/**
765 * Performs right-to-left function composition.
766 * The rightmost function may have any arity;
767 * the remaining functions must be unary.
768 *
769 * @note The result of `R.compose` is not automatically curried.
770 *
771 * See also {@link pipe}.
772 *
773 * @example
774 * ```typescript
775 * const classyGreeting = (firstName: string, lastName: string) => "The name's " + lastName + ", " + firstName + " " + lastName
776 * const yellGreeting = R.compose(R.toUpper, classyGreeting);
777 * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND"
778 *
779 * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7
780 * ```
781 */
782export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7, TResult>(
783 ...func: [
784 fnLast: (a: any) => TResult,
785 ...func: Array<(a: any) => any>,
786 f7: (a: R6) => R7,
787 f6: (a: R5) => R6,
788 f5: (a: R4) => R5,
789 f4: (a: R3) => R4,
790 f3: (a: R2) => R3,
791 f2: (a: R1) => R2,
792 f1: (...args: TArgs) => R1,
793 ]
794): (...args: TArgs) => TResult; // fallback overload if number of composed functions greater than 7
795export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7>(
796 f7: (a: R6) => R7,
797 f6: (a: R5) => R6,
798 f5: (a: R4) => R5,
799 f4: (a: R3) => R4,
800 f3: (a: R2) => R3,
801 f2: (a: R1) => R2,
802 f1: (...args: TArgs) => R1,
803): (...args: TArgs) => R7;
804export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7>(
805 f7: (a: R6) => R7,
806 f6: (a: R5) => R6,
807 f5: (a: R4) => R5,
808 f4: (a: R3) => R4,
809 f3: (a: R2) => R3,
810 f2: (a: R1) => R2,
811 f1: (...args: TArgs) => R1,
812): (...args: TArgs) => R7;
813export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6>(
814 f6: (a: R5) => R6,
815 f5: (a: R4) => R5,
816 f4: (a: R3) => R4,
817 f3: (a: R2) => R3,
818 f2: (a: R1) => R2,
819 f1: (...args: TArgs) => R1,
820): (...args: TArgs) => R6;
821export function compose<TArgs extends any[], R1, R2, R3, R4, R5>(
822 f5: (a: R4) => R5,
823 f4: (a: R3) => R4,
824 f3: (a: R2) => R3,
825 f2: (a: R1) => R2,
826 f1: (...args: TArgs) => R1,
827): (...args: TArgs) => R5;
828export function compose<TArgs extends any[], R1, R2, R3, R4>(
829 f4: (a: R3) => R4,
830 f3: (a: R2) => R3,
831 f2: (a: R1) => R2,
832 f1: (...args: TArgs) => R1,
833): (...args: TArgs) => R4;
834export function compose<TArgs extends any[], R1, R2, R3>(
835 f3: (a: R2) => R3,
836 f2: (a: R1) => R2,
837 f1: (...args: TArgs) => R1,
838): (...args: TArgs) => R3;
839export function compose<TArgs extends any[], R1, R2>(
840 f2: (a: R1) => R2,
841 f1: (...args: TArgs) => R1,
842): (...args: TArgs) => R2;
843export function compose<TArgs extends any[], R1>(f1: (...args: TArgs) => R1): (...args: TArgs) => R1;
844
845/**
846 * Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain.
847 * The typings only support arrays for now.
848 * All functions must be unary.
849 * R.composeK(h, g, f) is equivalent to R.compose(R.chain(h), R.chain(g), f).
850 *
851 * @deprecated since 0.26 in favor of composeWith(chain)
852 */
853export function composeK<V0, T1>(fn0: (x0: V0) => T1[]): (x0: V0) => T1[];
854export function composeK<V0, T1, T2>(fn1: (x: T1) => T2[], fn0: (x0: V0) => T1[]): (x0: V0) => T2[];
855export function composeK<V0, T1, T2, T3>(
856 fn2: (x: T2) => T3[],
857 fn1: (x: T1) => T2[],
858 fn0: (x: V0) => T1[],
859): (x: V0) => T3[];
860export function composeK<V0, T1, T2, T3, T4>(
861 fn3: (x: T3) => T4[],
862 fn2: (x: T2) => T3[],
863 fn1: (x: T1) => T2[],
864 fn0: (x: V0) => T1[],
865): (x: V0) => T4[];
866export function composeK<V0, T1, T2, T3, T4, T5>(
867 fn4: (x: T4) => T5[],
868 fn3: (x: T3) => T4[],
869 fn2: (x: T2) => T3[],
870 fn1: (x: T1) => T2[],
871 fn0: (x: V0) => T1[],
872): (x: V0) => T5[];
873export function composeK<V0, T1, T2, T3, T4, T5, T6>(
874 fn5: (x: T5) => T6[],
875 fn4: (x: T4) => T5[],
876 fn3: (x: T3) => T4[],
877 fn2: (x: T2) => T3[],
878 fn1: (x: T1) => T2[],
879 fn0: (x: V0) => T1[],
880): (x: V0) => T6[];
881
882/**
883 * Performs right-to-left composition of one or more Promise-returning functions.
884 * All functions must be unary.
885 *
886 * @deprecated since 0.26 in favor of composeWith(then)
887 */
888export function composeP<V0, T1>(fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T1>;
889export function composeP<V0, T1, T2>(
890 fn1: (x: T1) => Promise<T2>,
891 fn0: (x0: V0) => Promise<T1>,
892): (x0: V0) => Promise<T2>;
893export function composeP<V0, T1, T2, T3>(
894 fn2: (x: T2) => Promise<T3>,
895 fn1: (x: T1) => Promise<T2>,
896 fn0: (x: V0) => Promise<T1>,
897): (x: V0) => Promise<T3>;
898export function composeP<V0, T1, T2, T3, T4>(
899 fn3: (x: T3) => Promise<T4>,
900 fn2: (x: T2) => Promise<T3>,
901 fn1: (x: T1) => Promise<T2>,
902 fn0: (x: V0) => Promise<T1>,
903): (x: V0) => Promise<T4>;
904export function composeP<V0, T1, T2, T3, T4, T5>(
905 fn4: (x: T4) => Promise<T5>,
906 fn3: (x: T3) => Promise<T4>,
907 fn2: (x: T2) => Promise<T3>,
908 fn1: (x: T1) => Promise<T2>,
909 fn0: (x: V0) => Promise<T1>,
910): (x: V0) => Promise<T5>;
911export function composeP<V0, T1, T2, T3, T4, T5, T6>(
912 fn5: (x: T5) => Promise<T6>,
913 fn4: (x: T4) => Promise<T5>,
914 fn3: (x: T3) => Promise<T4>,
915 fn2: (x: T2) => Promise<T3>,
916 fn1: (x: T1) => Promise<T2>,
917 fn0: (x: V0) => Promise<T1>,
918): (x: V0) => Promise<T6>;
919
920/**
921 * Performs right-to-left function composition using transforming function.
922 * The last function may have any arity; the remaining functions must be unary.
923 *
924 * @note The result of `R.composeWith` is not automatically curried.
925 * The transforming function is not used on the last argument.
926 *
927 * See also {@link compose}, {@link pipeWith}.
928 *
929 * @example
930 * ```typescript
931 * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res));
932 *
933 * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2
934 * ```
935 */
936export function composeWith<TArgs extends any[], TResult>(
937 transformer: (fn: AnyFunction, intermediatResult: any) => any,
938 fns: AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>,
939): (...args: TArgs) => TResult;
940export function composeWith(
941 transformer: (fn: AnyFunction, intermediatResult: any) => any,
942): <TArgs extends any[], TResult>(
943 fns: AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>,
944) => (...args: TArgs) => TResult;
945
946/**
947 * Returns the result of concatenating the given lists or strings.
948 *
949 * @note `R.concat` expects both arguments to be of the same type,
950 * unlike the native `Array.prototype.concat` method.
951 * It will throw an error if you concat an `Array` with a non-`Array` value.
952 *
953 * Dispatches to the `concat` method of the first argument, if present.
954 * Can also concatenate two members of a fantasy-land compatible semigroup.
955 *
956 * @example
957 * ```typescript
958 * R.concat('ABC', 'DEF'); // 'ABCDEF'
959 * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
960 * R.concat([], []); //=> []
961 * ```
962 */
963export function concat(
964 placeholder: Placeholder,
965): (<L1 extends any[], L2 extends any[]>(list1: L1, list2: L2) => [...L1, ...L2]) &
966 (<S1 extends string, S2 extends string>(s1: S1, s2: S2) => `${S1}${S2}`);
967export function concat<L2 extends any[]>(
968 placeholder: Placeholder,
969 list2: L2,
970): <L1 extends any[]>(list1: L1) => [...L1, ...L2];
971export function concat<S2 extends string>(
972 placeholder: Placeholder,
973 s2: S2,
974): <S1 extends string>(s1: S1) => `${S1}${S2}`;
975export function concat<L1 extends any[]>(list1: L1): <L2 extends any[]>(list2: L2) => [...L1, ...L2];
976export function concat<S1 extends string>(s1: S1): <S2 extends string>(s2: S2) => `${S1}${S2}`;
977export function concat<L1 extends any[], L2 extends any[]>(list1: L1, list2: L2): [...L1, ...L2];
978export function concat<S1 extends string, S2 extends string>(s1: S1, s2: S2): `${S1}${S2}`;
979export function concat(s1: string, s2: string): string;
980export function concat(s1: string): (s2: string) => string;
981
982/**
983 * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic.
984 * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments
985 * to `fn` are applied to each of the predicates in turn until one returns a
986 * "truthy" value, at which point `fn` returns the result of applying its
987 * arguments to the corresponding transformer. If none of the predicates
988 * matches, `fn` returns undefined.
989 *
990 * @note This is not a direct substitute for a `switch` statement.
991 * Remember that both elements of every pair passed to `cond` are *functions*,
992 * and `cond` returns a function.
993 *
994 * @note When using this function with a typeguard as predicate,
995 * **all** predicates in all pairs must be typeguards.
996 *
997 * See also {@link ifElse}, {@link unless}, {@link when}.
998 *
999 * @example
1000 * ```typescript
1001 * const fn = R.cond([
1002 * [R.equals(0), R.always('water freezes at 0°C')],
1003 * [R.equals(100), R.always('water boils at 100°C')],
1004 * [R.T, temp => 'nothing special happens at ' + temp + '°C']
1005 * ]);
1006 * fn(0); //=> 'water freezes at 0°C'
1007 * fn(50); //=> 'nothing special happens at 50°C'
1008 * fn(100); //=> 'water boils at 100°C'
1009 * ```
1010 */
1011export function cond<T, TF1 extends T, R>(pairs: [CondPairTypeguard<T, TF1, R>]): (value: T) => R;
1012export function cond<T, TF1 extends T, TF2 extends T, R>(
1013 pairs: [CondPairTypeguard<T, TF1, R>, CondPairTypeguard<T, TF2, R>],
1014): (value: T) => R;
1015export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, R>(
1016 pairs: [CondPairTypeguard<T, TF1, R>, CondPairTypeguard<T, TF2, R>, CondPairTypeguard<T, TF3, R>],
1017): (value: T) => R;
1018export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, R>(
1019 pairs: [
1020 CondPairTypeguard<T, TF1, R>,
1021 CondPairTypeguard<T, TF2, R>,
1022 CondPairTypeguard<T, TF3, R>,
1023 CondPairTypeguard<T, TF4, R>,
1024 ],
1025): (value: T) => R;
1026export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, R>(
1027 pairs: [
1028 CondPairTypeguard<T, TF1, R>,
1029 CondPairTypeguard<T, TF2, R>,
1030 CondPairTypeguard<T, TF3, R>,
1031 CondPairTypeguard<T, TF4, R>,
1032 CondPairTypeguard<T, TF5, R>,
1033 ],
1034): (value: T) => R;
1035export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, TF6 extends T, R>(
1036 pairs: [
1037 CondPairTypeguard<T, TF1, R>,
1038 CondPairTypeguard<T, TF2, R>,
1039 CondPairTypeguard<T, TF3, R>,
1040 CondPairTypeguard<T, TF4, R>,
1041 CondPairTypeguard<T, TF5, R>,
1042 CondPairTypeguard<T, TF6, R>,
1043 ],
1044): (value: T) => R;
1045export function cond<
1046 T,
1047 TF1 extends T,
1048 TF2 extends T,
1049 TF3 extends T,
1050 TF4 extends T,
1051 TF5 extends T,
1052 TF6 extends T,
1053 TF7 extends T,
1054 R,
1055>(
1056 pairs: [
1057 CondPairTypeguard<T, TF1, R>,
1058 CondPairTypeguard<T, TF2, R>,
1059 CondPairTypeguard<T, TF3, R>,
1060 CondPairTypeguard<T, TF4, R>,
1061 CondPairTypeguard<T, TF5, R>,
1062 CondPairTypeguard<T, TF6, R>,
1063 CondPairTypeguard<T, TF7, R>,
1064 ],
1065): (value: T) => R;
1066export function cond<
1067 T,
1068 TF1 extends T,
1069 TF2 extends T,
1070 TF3 extends T,
1071 TF4 extends T,
1072 TF5 extends T,
1073 TF6 extends T,
1074 TF7 extends T,
1075 TF8 extends T,
1076 R,
1077>(
1078 pairs: [
1079 CondPairTypeguard<T, TF1, R>,
1080 CondPairTypeguard<T, TF2, R>,
1081 CondPairTypeguard<T, TF3, R>,
1082 CondPairTypeguard<T, TF4, R>,
1083 CondPairTypeguard<T, TF5, R>,
1084 CondPairTypeguard<T, TF6, R>,
1085 CondPairTypeguard<T, TF7, R>,
1086 CondPairTypeguard<T, TF8, R>,
1087 ],
1088): (value: T) => R;
1089export function cond<
1090 T,
1091 TF1 extends T,
1092 TF2 extends T,
1093 TF3 extends T,
1094 TF4 extends T,
1095 TF5 extends T,
1096 TF6 extends T,
1097 TF7 extends T,
1098 TF8 extends T,
1099 TF9 extends T,
1100 R,
1101>(
1102 pairs: [
1103 CondPairTypeguard<T, TF1, R>,
1104 CondPairTypeguard<T, TF2, R>,
1105 CondPairTypeguard<T, TF3, R>,
1106 CondPairTypeguard<T, TF4, R>,
1107 CondPairTypeguard<T, TF5, R>,
1108 CondPairTypeguard<T, TF6, R>,
1109 CondPairTypeguard<T, TF7, R>,
1110 CondPairTypeguard<T, TF8, R>,
1111 CondPairTypeguard<T, TF9, R>,
1112 ],
1113): (value: T) => R;
1114export function cond<
1115 T,
1116 TF1 extends T,
1117 TF2 extends T,
1118 TF3 extends T,
1119 TF4 extends T,
1120 TF5 extends T,
1121 TF6 extends T,
1122 TF7 extends T,
1123 TF8 extends T,
1124 TF9 extends T,
1125 TF10 extends T,
1126 R,
1127>(
1128 pairs: [
1129 CondPairTypeguard<T, TF1, R>,
1130 CondPairTypeguard<T, TF2, R>,
1131 CondPairTypeguard<T, TF3, R>,
1132 CondPairTypeguard<T, TF4, R>,
1133 CondPairTypeguard<T, TF5, R>,
1134 CondPairTypeguard<T, TF6, R>,
1135 CondPairTypeguard<T, TF7, R>,
1136 CondPairTypeguard<T, TF8, R>,
1137 CondPairTypeguard<T, TF9, R>,
1138 CondPairTypeguard<T, TF10, R>,
1139 ],
1140): (value: T) => R;
1141export function cond<T extends any[], R>(pairs: ReadonlyArray<CondPair<T, R>>): (...args: T) => R;
1142
1143/**
1144 * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
1145 *
1146 * See also {@link invoker}.
1147 *
1148 * @example
1149 * ```typescript
1150 * // Constructor function
1151 * class Animal {
1152 * constructor(public kind: string) {}
1153 *
1154 * sighting() {
1155 * return "It's a " + this.kind + "!";
1156 * }
1157 * }
1158 *
1159 * const AnimalConstructor = R.construct(Animal)
1160 *
1161 * // Notice we no longer need the 'new' keyword:
1162 * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}};
1163 *
1164 * const animalTypes = ["Lion", "Tiger", "Bear"];
1165 * const animalSighting = R.invoker(0, 'sighting');
1166 * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor);
1167 * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"]
1168 * ```
1169 */
1170export function construct<A extends any[], T>(
1171 constructor: { new (...args: A): T } | ((...args: A) => T),
1172): _.F.Curry<(...args: A) => T>;
1173
1174// NOTE: Example doesn't work with this typing
1175/**
1176 * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
1177 * The arity of the function returned is specified to allow using variadic constructor functions.
1178 */
1179export function constructN<A extends any[], T, N extends number>(
1180 n: N,
1181 constructor: { new (...args: A): T } | ((...args: A) => T),
1182): _.F.Curry<(...args: mergeArrWithLeft<Tuple<any, N>, A>) => T>;
1183
1184/**
1185 * Returns `true` if the specified item is somewhere in the list, `false` otherwise.
1186 * Equivalent to `indexOf(a)(list) > -1`. Uses strict (`===`) equality checking.
1187 *
1188 * @deprecated since 0.26 in favor of includes
1189 */
1190export function contains(__: Placeholder, list: string): (a: string) => boolean;
1191export function contains<T>(__: Placeholder, list: readonly T[]): (a: T) => boolean;
1192export function contains(__: Placeholder): (list: string, a: string) => boolean;
1193export function contains<T>(__: Placeholder): (list: readonly T[], a: T) => boolean;
1194export function contains(a: string, list: string): boolean;
1195export function contains<T>(a: T, list: readonly T[]): boolean;
1196export function contains(a: string): (list: string) => boolean;
1197export function contains<T>(a: T): (list: readonly T[]) => boolean;
1198
1199// NOTE: Example doesn't work with this typing
1200/**
1201 * Accepts a converging function and a list of branching functions and returns a new function.
1202 * When invoked, this new function is applied to some arguments,
1203 * each branching function is applied to those same arguments.
1204 * The results of each branching function are passed as arguments to the converging function
1205 * to produce the return value.
1206 *
1207 * See also {@link useWith}.
1208 */
1209export function converge<
1210 TResult,
1211 FunctionsList extends ReadonlyArray<Fn> &
1212 IfFunctionsArgumentsDoNotOverlap<_Fns, 'Functions arguments types must overlap'>,
1213 _Fns extends ReadonlyArray<Fn> = FunctionsList,
1214>(
1215 converging: (...args: ReturnTypesOfFns<FunctionsList>) => TResult,
1216 branches: FunctionsList,
1217): _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>;
1218export function converge<
1219 CArgs extends ReadonlyArray<any>,
1220 TResult,
1221 FunctionsList extends readonly [
1222 ...{
1223 [Index in keyof CArgs]: (...args: ReadonlyArray<any>) => CArgs[Index];
1224 },
1225 ] &
1226 IfFunctionsArgumentsDoNotOverlap<_Fns, 'Functions arguments types must overlap'>,
1227 _Fns extends ReadonlyArray<Fn> = FunctionsList,
1228>(
1229 converging: (...args: CArgs) => TResult,
1230 branches: FunctionsList,
1231): _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>;
1232
1233/**
1234 * Returns the number of items in a given `list` matching the predicate `f`.
1235 *
1236 * @example
1237 * ```typescript
1238 * const even = (x: number) => x % 2 == 0;
1239 *
1240 * R.count(even, [1, 2, 3, 4, 5]); // => 2
1241 * R.map(R.count(even), [[1, 1, 1], [2, 3, 4, 5], [6]]); // => [0, 2, 1]
1242 * ```
1243 */
1244export function count<T>(fn: (a: T) => boolean, list: readonly T[]): number;
1245export function count<T>(fn: (a: T) => boolean): (list: readonly T[]) => number;
1246
1247/**
1248 * Counts the elements of a list according to how many match each value of a key generated by the supplied function.
1249 * Returns an object mapping the keys produced by `fn` to the number of occurrences in the list.
1250 * Note that all keys are coerced to strings because of how JavaScript objects work.
1251 *
1252 * Acts as a transducer if a transformer is given in list position.
1253 *
1254 * See also {@link transduce}.
1255 *
1256 * @example
1257 * ```typescript
1258 * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2];
1259 * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1}
1260 *
1261 * const letters = ['a', 'b', 'A', 'a', 'B', 'c'];
1262 * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1}
1263 * ```
1264 */
1265export function countBy<T>(fn: (a: T) => string | number, list: readonly T[]): { [index: string]: number };
1266export function countBy<T>(fn: (a: T) => string | number): (list: readonly T[]) => { [index: string]: number };
1267
1268/**
1269 * Returns a curried equivalent of the provided function.
1270 *
1271 * See also {@link curryN}, {@link partial}.
1272 *
1273 * The curried function has two unusual capabilities.
1274 *
1275 * First, its arguments needn't be provided one at a time.
1276 * If `f` is a ternary function and `g` is `R.curry(f)`, the following are equivalent:
1277 * - `g(1)(2)(3)`
1278 * - `g(1)(2, 3)`
1279 * - `g(1, 2)(3)`
1280 * - `g(1, 2, 3)`
1281 *
1282 * Secondly, the special placeholder value `R.__` may be used to specify "gaps",
1283 * allowing partial application of any combination of arguments,
1284 * regardless of their positions.
1285 * If `g` is as above and `_` is `R.__`, the following are equivalent:
1286 * - `g(1, 2, 3)`
1287 * - `g(_, 2, 3)(1)`
1288 * - `g(_, _, 3)(1)(2)`
1289 * - `g(_, _, 3)(1, 2)`
1290 * - `g(_, 2)(1)(3)`
1291 * - `g(_, 2)(1, 3)`
1292 * - `g(_, 2)(_, 3)(1)`
1293 *
1294 * @example
1295 * ```typescript
1296 * const addFourNumbers = (a: number, b: number, c: number, d: number) => a + b + c + d;
1297 *
1298 * const curriedAddFourNumbers = R.curry(addFourNumbers);
1299 * const f = curriedAddFourNumbers(1, 2);
1300 * const g = f(3);
1301 * g(4); //=> 10
1302 * ```
1303 */
1304export function curry<F extends AnyFunction>(f: F): _.F.Curry<F>;
1305
1306/**
1307 * Returns a curried equivalent of the provided function, with the specified arity.
1308 *
1309 * See also {@link curry}.
1310 *
1311 * The curried function has two unusual capabilities.
1312 *
1313 * First, its arguments needn't be provided one at a time.
1314 * If `f` is a ternary function and `g` is `R.curry(f)`, the following are equivalent:
1315 * - `g(1)(2)(3)`
1316 * - `g(1)(2, 3)`
1317 * - `g(1, 2)(3)`
1318 * - `g(1, 2, 3)`
1319 *
1320 * Secondly, the special placeholder value `R.__` may be used to specify "gaps",
1321 * allowing partial application of any combination of arguments,
1322 * regardless of their positions.
1323 * If `g` is as above and `_` is `R.__`, the following are equivalent:
1324 * - `g(1, 2, 3)`
1325 * - `g(_, 2, 3)(1)`
1326 * - `g(_, _, 3)(1)(2)`
1327 * - `g(_, _, 3)(1, 2)`
1328 * - `g(_, 2)(1)(3)`
1329 * - `g(_, 2)(1, 3)`
1330 * - `g(_, 2)(_, 3)(1)`
1331 *
1332 * @example
1333 * ```typescript
1334 * const sumArgs = (...args: number[]) => R.sum(args);
1335 *
1336 * const curriedAddFourNumbers = R.curryN(4, sumArgs);
1337 * const f = curriedAddFourNumbers(1, 2);
1338 * const g = f(3);
1339 * g(4); //=> 10
1340 * ```
1341 */
1342export function curryN<N extends number, F extends AnyFunction>(
1343 length: N,
1344 fn: F,
1345): _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>;
1346export function curryN<N extends number>(
1347 length: N,
1348): <F extends AnyFunction>(fn: F) => _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>;
1349
1350/**
1351 * Decrements its argument.
1352 *
1353 * See also {@link inc}.
1354 *
1355 * @example
1356 * ```typescript
1357 * R.dec(42); //=> 41
1358 * ```
1359 */
1360export function dec(n: number): number;
1361
1362/**
1363 * Returns the second argument if it is not `null`, `undefined` or `NaN`; otherwise the first argument is returned.
1364 *
1365 * @example
1366 * ```typescript
1367 * const defaultTo42 = R.defaultTo(42);
1368 *
1369 * defaultTo42(null); //=> 42
1370 * defaultTo42(undefined); //=> 42
1371 * defaultTo42(false); //=> false
1372 * defaultTo42('Ramda'); //=> 'Ramda'
1373 * // parseInt('string') results in NaN
1374 * defaultTo42(parseInt('string')); //=> 42
1375 * ```
1376 */
1377export function defaultTo<T, U>(a: T, b: U | null | undefined): T | U;
1378export function defaultTo<T>(a: T): <U>(b: U | null | undefined) => T | U;
1379
1380/**
1381 * Makes a descending comparator function out of a function that returns a value that can be compared with `<` and `>`.
1382 *
1383 * See also {@link ascend}.
1384 *
1385 * @example
1386 * ```typescript
1387 * type Person = { name: string; age: number; };
1388 *
1389 * const byAge = R.descend<Person>(R.prop('age'));
1390 * const people = [
1391 * { name: 'Emma', age: 70 },
1392 * { name: 'Peter', age: 78 },
1393 * { name: 'Mikhail', age: 62 },
1394 * ];
1395 * const peopleByOldestFirst = R.sort(byAge, people);
1396 * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }]
1397 * ```
1398 */
1399export function descend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
1400export function descend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
1401
1402/**
1403 * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
1404 * `Object`s and `Array`s are compared in terms of value equality, not reference equality.
1405 *
1406 * See also {@link differenceWith}, {@link symmetricDifference}, {@link symmetricDifferenceWith}, {@link without}.
1407 *
1408 * @example
1409 * ```typescript
1410 * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2]
1411 * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5]
1412 * R.difference<{ a: number; } | { b: number; } | { c: number; }>([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}]
1413 * ```
1414 */
1415export function difference<T>(list1: readonly T[], list2: readonly T[]): T[];
1416export function difference<T>(list1: readonly T[]): (list2: readonly T[]) => T[];
1417
1418/**
1419 * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
1420 * Duplication is determined according to the value returned
1421 * by applying the supplied predicate to two list elements.
1422 *
1423 * See also See also {@link difference}, {@link symmetricDifference}, {@link symmetricDifferenceWith}.
1424 *
1425 * @example
1426 * ```typescript
1427 * const cmp = (x: { a: number; }, y: { a: number; }) => x.a === y.a;
1428 * const l1 = [{a: 1}, {a: 2}, {a: 3}];
1429 * const l2 = [{a: 3}, {a: 4}];
1430 * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}]
1431 * ```
1432 */
1433export function differenceWith<T1, T2>(
1434 pred: (a: T1, b: T2) => boolean,
1435 list1: readonly T1[],
1436 list2: readonly T2[],
1437): T1[];
1438export function differenceWith<T1, T2>(
1439 pred: (a: T1, b: T2) => boolean,
1440): (list1: readonly T1[], list2: readonly T2[]) => T1[];
1441export function differenceWith<T1, T2>(
1442 pred: (a: T1, b: T2) => boolean,
1443 list1: readonly T1[],
1444): (list2: readonly T2[]) => T1[];
1445
1446/**
1447 * Returns a new object that does not contain the given property.
1448 *
1449 * See also {@link assoc}, {@link omit}.
1450 *
1451 * @example
1452 * ```typescript
1453 * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3}
1454 * ```
1455 */
1456export function dissoc<T extends object, K extends keyof T>(prop: K, obj: T): Omit<T, K>;
1457export function dissoc<K extends string | number>(prop: K): <T extends object>(obj: T) => Omit<T, K>;
1458
1459/**
1460 * Makes a shallow clone of an object, omitting the property at the given path.
1461 *
1462 * @note This copies and flattens prototype properties onto the new object as well.
1463 * All non-primitive properties are copied by reference.
1464 *
1465 * @example
1466 * ```typescript
1467 * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}}
1468 * ```
1469 */
1470export function dissocPath<T>(path: Path, obj: any): T;
1471export function dissocPath<T>(path: Path): (obj: any) => T;
1472
1473/**
1474 * Divides two numbers. Equivalent to `a / b` but curried.
1475 *
1476 * See also {@link multiply}.
1477 *
1478 * @example
1479 * ```typescript
1480 * R.divide(71, 100); //=> 0.71
1481 *
1482 * const half = R.divide(R.__, 2);
1483 * half(42); //=> 21
1484 *
1485 * const reciprocal = R.divide(1);
1486 * reciprocal(4); //=> 0.25
1487 * ```
1488 */
1489export function divide(__: Placeholder, b: number): (a: number) => number;
1490export function divide(__: Placeholder): (b: number, a: number) => number;
1491export function divide(a: number, b: number): number;
1492export function divide(a: number): (b: number) => number;
1493
1494/**
1495 * Returns all but the first `n` elements of the given list, string, or transducer/transformer.
1496 *
1497 * Dispatches to the `drop` method of the second argument, if present.
1498 *
1499 * See also {@link take}, {@link transduce}, {@link dropLast}, {@link dropWhile}.
1500 *
1501 * @example
1502 * ```typescript
1503 * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
1504 * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz']
1505 * R.drop(3, ['foo', 'bar', 'baz']); //=> []
1506 * R.drop(4, ['foo', 'bar', 'baz']); //=> []
1507 * R.drop(3, 'ramda'); //=> 'da'
1508 * ```
1509 */
1510export function drop<T>(n: number, xs: readonly T[]): T[];
1511export function drop(n: number, xs: string): string;
1512export function drop<T>(n: number): {
1513 (xs: string): string;
1514 (xs: readonly T[]): T[];
1515};
1516
1517/**
1518 * Returns a list containing all but the last `n` elements of the given list.
1519 *
1520 * Acts as a transducer if a transformer is given in list position.
1521 *
1522 * See also {@link takeLast}, {@link drop}, {@link dropWhile}, {@link dropLastWhile}, {@link transduce}.
1523 *
1524 * @example
1525 * ```typescript
1526 * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
1527 * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo']
1528 * R.dropLast(3, ['foo', 'bar', 'baz']); //=> []
1529 * R.dropLast(4, ['foo', 'bar', 'baz']); //=> []
1530 * R.dropLast(3, 'ramda'); //=> 'ra'
1531 * ```
1532 */
1533export function dropLast<T>(n: number, xs: readonly T[]): T[];
1534export function dropLast(n: number, xs: string): string;
1535export function dropLast<T>(n: number): {
1536 (xs: readonly T[]): T[];
1537 (xs: string): string;
1538};
1539
1540/**
1541 * Returns a new list excluding all the tailing elements of a given list which satisfy the supplied predicate function.
1542 * It passes each value from the right to the supplied predicate function,
1543 * skipping elements until the predicate function returns a falsy value.
1544 *
1545 * Acts as a transducer if a transformer is given in list position.
1546 *
1547 * See also {@link takeLastWhile}, {@link addIndex}, {@link drop}, {@link dropWhile}, {@link transduce}.
1548 *
1549 * @example
1550 * ```typescript
1551 * const lteThree = (x: number) => x <= 3;
1552 *
1553 * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]
1554 *
1555 * R.dropLastWhile(x => x !== 'd', 'Ramda'); //=> 'Ramd'
1556 * ```
1557 */
1558export function dropLastWhile<T>(fn: (a: T) => boolean, list: readonly T[]): T[];
1559export function dropLastWhile<T>(fn: (a: T) => boolean): (list: readonly T[]) => T[];
1560
1561/**
1562 * Returns a new list without any consecutively repeating elements.
1563 * {@link equals `R.equals`} is used to determine equality.
1564 *
1565 * Acts as a transducer if a transformer is given in list position.
1566 *
1567 * See also {@link transduce}.
1568 *
1569 * @example
1570 * ```typescript
1571 * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2]
1572 * ```
1573 */
1574export function dropRepeats<T>(list: readonly T[]): T[];
1575
1576/**
1577 * Returns a new list without any consecutively repeating elements.
1578 * Equality is determined by applying the supplied predicate to each pair of consecutive elements.
1579 * The first element in a series of equal elements will be preserved.
1580 *
1581 * Acts as a transducer if a transformer is given in list position.
1582 *
1583 * See also {@link transduce}.
1584 *
1585 * @example
1586 * ```typescript
1587 * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3];
1588 * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3]
1589 * ```
1590 */
1591export function dropRepeatsWith<T>(predicate: (left: T, right: T) => boolean, list: readonly T[]): T[];
1592export function dropRepeatsWith<T>(predicate: (left: T, right: T) => boolean): (list: readonly T[]) => T[];
1593
1594/**
1595 * Returns a new list excluding the leading elements of a given list
1596 * which satisfy the supplied predicate function.
1597 * It passes each value to the supplied predicate function,
1598 * skipping elements while the predicate function returns a truthy value.
1599 *
1600 * Dispatches to the `dropWhile` method of the second argument, if present.
1601 *
1602 * Acts as a transducer if a transformer is given in list position.
1603 *
1604 * See also {@link takeWhile}, {@link addIndex}, {@link transduce}.
1605 *
1606 * @example
1607 * ```typescript
1608 * const lteTwo = (x: number) => x <= 2;
1609 *
1610 * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]
1611 *
1612 * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da'
1613 * ```
1614 */
1615export function dropWhile<T>(fn: (a: T) => boolean, list: readonly T[]): T[];
1616export function dropWhile<T>(fn: (a: T) => boolean): (list: readonly T[]) => T[];
1617
1618/**
1619 * A function wrapping calls to the two functions in an `||` operation,
1620 * returning the result of the first function if it is truthy
1621 * and the result of the second function otherwise.
1622 *
1623 * @note This is short-circuited, meaning that the second function will not be invoked if the first returns a truthy value.
1624 *
1625 * See also {@link both}, {@link or}.
1626 *
1627 * @example
1628 * ```typescript
1629 * const gt10 = (x: number) => x > 10;
1630 * const even = (x: number) => x % 2 === 0;
1631 * const f = R.either(gt10, even);
1632 * f(101); //=> true
1633 * f(8); //=> true
1634 * ```
1635 */
1636export function either<T extends Pred>(pred1: T, pred2: T): T;
1637export function either<T extends Pred>(pred1: T): (pred2: T) => T;
1638
1639/**
1640 * Returns the empty value of its argument's type.
1641 * Ramda defines the empty value of `Array` (`[]`), `Object` (`{}`), string (`''`),
1642 * `TypedArray` (`Uint8Array []`, `Float32Array []`, etc) and arguments.
1643 *
1644 * Other types are supported if they define `<Type>.empty`, `<Type>.prototype.empty`
1645 * or implement the FantasyLand Monoid spec.
1646 *
1647 * Dispatches to the `empty` method of the first argument, if present.
1648 *
1649 * @example
1650 * ```typescript
1651 * R.empty([1, 2, 3]); //=> []
1652 * R.empty('unicorns'); //=> ''
1653 * R.empty({x: 1, y: 2}); //=> {}
1654 * R.empty(Uint8Array.from([1, 2, 3])); //=> Uint8Array []
1655 * ```
1656 */
1657export function empty<T>(x: T): T;
1658
1659/**
1660 * Checks if a list ends with the provided sublist.
1661 *
1662 * Similarly, checks if a string ends with the provided substring.
1663 *
1664 * See also {@link startsWith}.
1665 *
1666 * @example
1667 * ```typescript
1668 * R.endsWith('c', 'abc') //=> true
1669 * R.endsWith('b', 'abc') //=> false
1670 * R.endsWith(['c'], ['a', 'b', 'c']) //=> true
1671 * R.endsWith(['b'], ['a', 'b', 'c']) //=> false
1672 * ```
1673 */
1674export function endsWith(substr: string, str: string): boolean;
1675export function endsWith(substr: string): (str: string) => boolean;
1676export function endsWith<T>(subList: readonly T[], list: readonly T[]): boolean;
1677export function endsWith<T>(subList: readonly T[]): (list: readonly T[]) => boolean;
1678
1679/**
1680 * Takes a function and two values in its domain and returns `true` if the values map to the same value in the codomain;
1681 * `false` otherwise.
1682 *
1683 * @example
1684 * ```typescript
1685 * R.eqBy(Math.abs, 5, -5); //=> true
1686 * ```
1687 */
1688export function eqBy<T>(fn: (a: T) => unknown, a: T, b: T): boolean;
1689export function eqBy<T>(fn: (a: T) => unknown, a: T): (b: T) => boolean;
1690export function eqBy<T>(fn: (a: T) => unknown): {
1691 (a: T, b: T): boolean;
1692 (a: T): (b: T) => boolean;
1693};
1694
1695/**
1696 * Reports whether two objects have the same value, in {@link equals `R.equals`} terms, for the specified property.
1697 * Useful as a curried predicate.
1698 *
1699 * @example
1700 * ```typescript
1701 * const o1 = { a: 1, b: 2, c: 3, d: 4 };
1702 * const o2 = { a: 10, b: 20, c: 3, d: 40 };
1703 * R.eqProps('a', o1, o2); //=> false
1704 * R.eqProps('c', o1, o2); //=> true
1705 * ```
1706 */
1707export function eqProps<T, U>(prop: string, obj1: T, obj2: U): boolean;
1708export function eqProps<P extends string>(prop: P): <T, U>(obj1: Record<P, T>, obj2: Record<P, U>) => boolean;
1709export function eqProps<T>(prop: string, obj1: T): <U>(obj2: U) => boolean;
1710
1711/**
1712 * Returns `true` if its arguments are equivalent, `false` otherwise.
1713 * Handles cyclical data structures.
1714 *
1715 * Dispatches symmetrically to the `equals` methods of both arguments, if present.
1716 *
1717 * @example
1718 * ```typescript
1719 * R.equals(1, 1); //=> true
1720 * R.equals([1, 2, 3], [1, 2, 3]); //=> true
1721 *
1722 * type Recursive = { v: Recursive; };
1723 *
1724 * const a: Recursive = {} as Recursive; a.v = a;
1725 * const b: Recursive = {} as Recursive; b.v = b;
1726 * R.equals(a, b); //=> true
1727 * ```
1728 */
1729export function equals<T>(__: Placeholder, b: T): (a: T) => boolean;
1730export function equals<T>(a: T, b: T): boolean;
1731export function equals<T>(a: T): (b: T) => boolean;
1732
1733/**
1734 * Creates a new object by evolving a shallow copy of the `object`,
1735 * according to the functions in `transformations`.
1736 * All non-primitive properties are copied by reference.
1737 *
1738 * A function in `transformations` will not be invoked if its corresponding key does not exist in the evolved object.
1739 *
1740 * @example
1741 * ```typescript
1742 * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
1743 * const transformations = {
1744 * firstName: R.trim,
1745 * lastName: R.trim, // Will not get invoked.
1746 * data: {elapsed: R.add(1), remaining: R.add(-1)}
1747 * };
1748 * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123}
1749 * ```
1750 */
1751export function evolve<E extends Evolver, V extends Evolvable<E>>(transformations: E, obj: V): Evolve<V, E>;
1752export function evolve<E extends Evolver>(transformations: E): <V extends Evolvable<E>>(obj: V) => Evolve<V, E>;
1753
1754/**
1755 * A function that always returns `false`.
1756 * Any passed in parameters are ignored.
1757 *
1758 * See also {@link T}.
1759 *
1760 * @example
1761 * ```typescript
1762 * R.F(); //=> false
1763 * ```
1764 */
1765export function F(...args: unknown[]): false;
1766
1767/**
1768 * Takes a predicate and a `Filterable`,
1769 * and returns a new `Filterable` of the same type
1770 * containing the members of the given `Filterable` which satisfy the given predicate.
1771 * Filterable objects include plain objects or any object that has a filter method such as Array.
1772 *
1773 * Dispatches to the `filter` method of the second argument, if present.
1774 *
1775 * Acts as a transducer if a transformer is given in list position.
1776 *
1777 * See also {@link reject}, {@link transduce}, {@link addIndex}.
1778 *
1779 * @example
1780 * ```typescript
1781 * const isEven = (n: number) => n % 2 === 0;
1782 *
1783 * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
1784 *
1785 * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
1786 * ```
1787 */
1788export function filter<A, P extends A>(
1789 pred: (val: A) => val is P,
1790): {
1791 <B extends A>(list: readonly B[]): P[];
1792 <B extends A>(dict: Dictionary<B>): Dictionary<P>;
1793};
1794export function filter<T>(
1795 pred: (value: T) => boolean,
1796): <P extends T, C extends readonly P[] | Dictionary<P>>(collection: C) => C;
1797export function filter<T, P extends T>(pred: (val: T) => val is P, list: readonly T[]): P[];
1798export function filter<T, P extends T>(pred: (val: T) => val is P, dict: Dictionary<T>): Dictionary<P>;
1799export function filter<T, C extends readonly T[] | Dictionary<T>>(pred: (value: T) => boolean, collection: C): C;
1800
1801/**
1802 * Returns the first element of the list which matches the predicate,
1803 * or `undefined` if no element matches.
1804 *
1805 * Dispatches to the `find` method of the second argument, if present.
1806 *
1807 * Acts as a transducer if a transformer is given in list position.
1808 *
1809 * See also {@link transduce}.
1810 *
1811 * @example
1812 * ```typescript
1813 * const xs = [{a: 1}, {a: 2}, {a: 3}];
1814 * R.find(R.propEq('a', 2))(xs); //=> {a: 2}
1815 * R.find(R.propEq('a', 4))(xs); //=> undefined
1816 * ```
1817 */
1818export function find<T, P extends T>(pred: (val: T) => val is P, list: readonly T[]): P | undefined;
1819export function find<T>(pred: (val: T) => boolean, list: readonly T[]): T | undefined;
1820export function find<T, P extends T>(pred: (val: T) => val is P): (list: readonly T[]) => P | undefined;
1821export function find<T>(pred: (val: T) => boolean): (list: readonly T[]) => T | undefined;
1822
1823/**
1824 * Returns the index of the first element of the list which matches the predicate,
1825 * or `-1` if no element matches.
1826 *
1827 * Acts as a transducer if a transformer is given in list position.
1828 *
1829 * See also {@link indexOf}, {@link transduce}.
1830 *
1831 * @example
1832 * ```typescript
1833 * const xs = [{a: 1}, {a: 2}, {a: 3}];
1834 * R.findIndex(R.propEq('a', 2))(xs); //=> 1
1835 * R.findIndex(R.propEq('a', 4))(xs); //=> -1
1836 * ```
1837 */
1838export function findIndex<T>(fn: (a: T) => boolean, list: readonly T[]): number;
1839export function findIndex<T>(fn: (a: T) => boolean): (list: readonly T[]) => number;
1840
1841/**
1842 * Returns the last element of the list which matches the predicate, or `undefined` if no element matches.
1843 *
1844 * Acts as a transducer if a transformer is given in list position.
1845 *
1846 * See also {@link transduce}.
1847 *
1848 * @example
1849 * ```typescript
1850 * const xs = [{a: 1, b: 0}, {a:1, b: 1}];
1851 * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1}
1852 * R.findLast(R.propEq('a', 4))(xs); //=> undefined
1853 * ```
1854 */
1855export function findLast<T, P extends T>(pred: (val: T) => val is P, list: readonly T[]): P | undefined;
1856export function findLast<T>(pred: (val: T) => boolean, list: readonly T[]): T | undefined;
1857export function findLast<T, P extends T>(pred: (val: T) => val is P): (list: readonly T[]) => P | undefined;
1858export function findLast<T>(pred: (val: T) => boolean): (list: readonly T[]) => T | undefined;
1859
1860/**
1861 * Returns the index of the last element of the list which matches the predicate,
1862 * or `-1` if no element matches.
1863 *
1864 * Acts as a transducer if a transformer is given in list position.
1865 *
1866 * See also {@link lastIndexOf}, {@link transduce}.
1867 *
1868 * @example
1869 * ```typescript
1870 * const xs = [{a: 1, b: 0}, {a:1, b: 1}];
1871 * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1
1872 * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1
1873 * ```
1874 */
1875export function findLastIndex<T>(fn: (a: T) => boolean, list: readonly T[]): number;
1876export function findLastIndex<T>(fn: (a: T) => boolean): (list: readonly T[]) => number;
1877
1878/**
1879 * Returns a new list by pulling every item out of it (and all its sub-arrays)
1880 * and putting them in a new array, depth-first.
1881 *
1882 * See also {@link unnest}.
1883 *
1884 * @example
1885 * ```typescript
1886 * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]);
1887 * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
1888 * ```
1889 */
1890export function flatten<T extends readonly any[]>(list: T): _.T.Flatten<T>;
1891
1892/**
1893 * Flips the order of the first two arguments to the given function.
1894 *
1895 * @example
1896 * ```typescript
1897 * const mergeThree = <T>(a: T, b: T, c: T) => ([] as T[]).concat(a, b, c);
1898 *
1899 * mergeThree(1, 2, 3); //=> [1, 2, 3]
1900 *
1901 * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]
1902 * ```
1903 */
1904export function flip<T, U, TResult>(fn: (arg0: T, arg1: U) => TResult): (arg1: U, arg0?: T) => TResult;
1905export function flip<F extends AnyFunction, P extends _.F.Parameters<F>>(
1906 fn: F,
1907): _.F.Curry<(...args: _.T.Merge<[P[1], P[0]], P>) => _.F.Return<F>>;
1908
1909/**
1910 * Iterate over the given list, calling the given function for each element in the list.
1911 *
1912 * @note `R.forEach` does not skip deleted or unassigned indices (sparse arrays),
1913 * unlike the native `Array.prototype.forEach` method.
1914 *
1915 * Also note that, unlike `Array.prototype.forEach`, `R.forEach` returns the original array.
1916 * In some libraries this function is named `each`.
1917 *
1918 * Dispatches to the `forEach` method of the second argument, if present.
1919 *
1920 * @example
1921 * ```typescript
1922 * const printXPlusFive = (x: number) => console.log(x + 5);
1923 * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3]
1924 * // logs 6
1925 * // logs 7
1926 * // logs 8
1927 * ```
1928 */
1929export function forEach<T>(fn: (x: T) => void, list: readonly T[]): T[];
1930export function forEach<T>(fn: (x: T) => void): (list: readonly T[]) => T[];
1931export function forEach<T>(fn: (x: T) => void, list: readonly T[]): T[];
1932export function forEach<T>(fn: (x: T) => void): (list: readonly T[]) => T[];
1933
1934/**
1935 * Iterate over the given object, calling the given function for each key and value in the object.
1936 *
1937 * @example
1938 * ```typescript
1939 * const printKeyConcatValue = (value: unknown, key: string) => console.log(key + ':' + value);
1940 * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
1941 * // logs x:1
1942 * // logs y:2
1943 * ```
1944 */
1945export function forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void, obj: T): T;
1946export function forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void): (obj: T) => T;
1947
1948/**
1949 * Creates a new object from a list key-value pairs.
1950 * If a key appears in multiple pairs,
1951 * the rightmost pair is included in the object.
1952 *
1953 * See also {@link toPairs}, {@link pair}.
1954 *
1955 * @example
1956 * ```typescript
1957 * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
1958 * ```
1959 */
1960export function fromPairs<V>(
1961 pairs: ReadonlyArray<Readonly<KeyValuePair<string, V>>> | ReadonlyArray<Readonly<KeyValuePair<number, V>>>,
1962): { [index: string]: V };
1963
1964/**
1965 * Splits a list into sub-lists stored in an object,
1966 * based on the result of calling a key-returning function on each element,
1967 * and grouping the results according to values returned.
1968 *
1969 * Dispatches to the `groupBy` method of the second argument, if present.
1970 *
1971 * Acts as a transducer if a transformer is given in list position.
1972 *
1973 * See also {@link reduceBy}, {@link indexBy}, {@link transduce}.
1974 *
1975 * @example
1976 * ```typescript
1977 * type Student = { name: string; score: number; }
1978 *
1979 * const byGrade = R.groupBy((student: Student) => {
1980 * const score = student.score;
1981 * return score < 65 ? 'F' :
1982 * score < 70 ? 'D' :
1983 * score < 80 ? 'C' :
1984 * score < 90 ? 'B' : 'A';
1985 * });
1986 * const students = [{name: 'Abby', score: 84},
1987 * {name: 'Eddy', score: 58},
1988 * // ...
1989 * {name: 'Jack', score: 69}];
1990 * byGrade(students);
1991 * // {
1992 * // 'A': [{name: 'Dianne', score: 99}],
1993 * // 'B': [{name: 'Abby', score: 84}]
1994 * // // ...,
1995 * // 'F': [{name: 'Eddy', score: 58}]
1996 * // }
1997 * ```
1998 */
1999export function groupBy<T, K extends string = string>(fn: (a: T) => K, list: readonly T[]): Record<K, T[]>;
2000export function groupBy<T, K extends string = string>(fn: (a: T) => K): (list: readonly T[]) => Record<K, T[]>;
2001
2002/**
2003 * Takes a list and returns a list of lists
2004 * where every adjacent element of each sublist satisfies the given predicate.
2005 *
2006 * @example
2007 * ```typescript
2008 * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21])
2009 * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]]
2010 *
2011 * R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21])
2012 * //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]]
2013 *
2014 * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21])
2015 * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]]
2016 *
2017 * const isVowel = R.test(/^[aeiou]$/i);
2018 * R.groupWith(R.eqBy(isVowel), 'aestiou')
2019 * //=> ['ae', 'st', 'iou']
2020 * ```
2021 */
2022export function groupWith<T>(fn: (x: T, y: T) => boolean): (list: readonly T[]) => T[][];
2023export function groupWith<T>(fn: (x: T, y: T) => boolean, list: readonly T[]): T[][];
2024export function groupWith<T>(fn: (x: T, y: T) => boolean, list: string): string[];
2025
2026/**
2027 * Returns `true` if the first parameter is greater than the second; `false` otherwise.
2028 *
2029 * See also {@link gte}, {@link lt}, {@link lte}.
2030 *
2031 * @example
2032 * ```typescript
2033 * R.gt(2, 1); //=> true
2034 * R.gt(2, 2); //=> false
2035 * R.gt(2, 3); //=> false
2036 * R.gt('a', 'z'); //=> false
2037 * R.gt('z', 'a'); //=> true
2038 * ```
2039 */
2040export function gt(__: Placeholder, b: number): (a: number) => boolean;
2041export function gt(__: Placeholder): (b: number, a: number) => boolean;
2042export function gt(a: number, b: number): boolean;
2043export function gt(a: string, b: string): boolean;
2044export function gt(a: number): (b: number) => boolean;
2045
2046/**
2047 * Returns `true` if the first parameter is greater than or equal to the second; `false` otherwise.
2048 *
2049 * See also {@link gt}, {@link lt}, {@link lte}.
2050 *
2051 * @example
2052 * ```typescript
2053 * R.gte(2, 1); //=> true
2054 * R.gte(2, 2); //=> true
2055 * R.gte(2, 3); //=> false
2056 * R.gte('a', 'z'); //=> false
2057 * R.gte('z', 'a'); //=> true
2058 * ```
2059 */
2060export function gte(__: Placeholder, b: number): (a: number) => boolean;
2061export function gte(__: Placeholder): (b: number, a: number) => boolean;
2062export function gte(a: number, b: number): boolean;
2063export function gte(a: string, b: string): boolean;
2064export function gte(a: number): (b: number) => boolean;
2065
2066/**
2067 * Returns whether or not an object has an own property with the specified name.
2068 *
2069 * @example
2070 * ```typescript
2071 * const hasName = R.has('name');
2072 * hasName({name: 'alice'}); //=> true
2073 * hasName({name: 'bob'}); //=> true
2074 * hasName({}); //=> false
2075 *
2076 * const point = {x: 0, y: 0};
2077 * const pointHas = R.has(R.__, point);
2078 * pointHas('x'); //=> true
2079 * pointHas('y'); //=> true
2080 * pointHas('z'); //=> false
2081 * ```
2082 */
2083export function has(__: Placeholder, obj: unknown): (s: string) => boolean;
2084export function has(__: Placeholder): <P extends string>(obj: unknown, s: P) => obj is ObjectHavingSome<P>;
2085export function has<P extends string>(s: P, obj: unknown): obj is ObjectHavingSome<P>;
2086export function has<P extends string>(s: P): (obj: unknown) => obj is ObjectHavingSome<P>;
2087
2088/**
2089 * Returns whether or not an object or its prototype chain has a property with the specified name.
2090 *
2091 * @example
2092 * ```typescript
2093 * class Rectangle {
2094 * constructor(public width: number, public height: number) {}
2095 *
2096 * area() {
2097 * return this.width * this.height;
2098 * }
2099 * }
2100 *
2101 * const square = new Rectangle(2, 2);
2102 * R.hasIn('width', square); //=> true
2103 * R.hasIn('area', square); //=> true
2104 * ```
2105 */
2106export function hasIn<T>(s: string, obj: T): boolean;
2107export function hasIn(s: string): <T>(obj: T) => boolean;
2108
2109/**
2110 * Returns whether or not a path exists in an object. Only the object's own properties are checked.
2111 *
2112 * See also {@link has}.
2113 *
2114 * @example
2115 * ```typescript
2116 * R.hasPath(['a', 'b'], {a: {b: 2}}); // => true
2117 * R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true
2118 * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false
2119 * R.hasPath(['a', 'b'], {}); // => false
2120 * ```
2121 */
2122export function hasPath<T>(list: readonly string[], obj: T): boolean;
2123export function hasPath(list: readonly string[]): <T>(obj: T) => boolean;
2124
2125/**
2126 * Returns the first element in a list.
2127 * In some libraries this function is named `first`.
2128 *
2129 * See also {@link tail}, {@link init}, {@link last}.
2130 *
2131 * @example
2132 * ```typescript
2133 * R.head(['fi', 'fo', 'fum']); //=> 'fi'
2134 * R.head([]); //=> undefined
2135 *
2136 * R.head('abc'); //=> 'a'
2137 * R.head(''); //=> ''
2138 * ```
2139 */
2140export function head(str: string): string;
2141export function head(list: readonly []): undefined;
2142export function head<T>(list: readonly T[]): T | undefined;
2143
2144/**
2145 * Returns `true` if its arguments are identical, `false` otherwise.
2146 * Values are identical if they reference the same memory.
2147 * `NaN` is identical to `NaN`; `0` and `-0` are not identical.
2148 *
2149 * @note This is merely a curried version of ES6 `Object.is`.
2150 *
2151 * @example
2152 * ```typescript
2153 * const o = {};
2154 * R.identical(o, o); //=> true
2155 * R.identical(1, 1); //=> true
2156 * R.identical<string | number>(1, '1'); //=> false
2157 * R.identical([], []); //=> false
2158 * R.identical(0, -0); //=> false
2159 * R.identical(NaN, NaN); //=> true
2160 * ```
2161 */
2162export function identical<T>(a: T, b: T): boolean;
2163export function identical<T>(a: T): (b: T) => boolean;
2164
2165/**
2166 * A function that returns its argument.
2167 * Good as a default or placeholder function.
2168 *
2169 * @example
2170 * ```typescript
2171 * R.identity(1); //=> 1
2172 *
2173 * const obj = {};
2174 * R.identity(obj) === obj; //=> true
2175 * ```
2176 */
2177export function identity<T>(a: T): T;
2178
2179/**
2180 * Creates a function that will process either the onTrue or the onFalse function depending upon the result
2181 * of the condition predicate.
2182 *
2183 * See also {@link unless}, {@link when}, {@link cond}.
2184 *
2185 * @example
2186 * ```typescript
2187 * const incCount = R.ifElse(
2188 * R.has('count'),
2189 * R.over(R.lensProp<{ count: number; }>('count'), R.inc),
2190 * R.assoc('count', 1)
2191 * );
2192 * incCount({ count: 1 }); //=> { count: 2 }
2193 * ```
2194 */
2195export function ifElse<T, TF extends T, TOnTrueResult, TOnFalseResult>(
2196 pred: PredTypeguard<T, TF>,
2197 onTrue: (a: TF) => TOnTrueResult,
2198 onFalse: (a: Exclude<T, TF>) => TOnFalseResult,
2199): (a: T) => TOnTrueResult | TOnFalseResult;
2200export function ifElse<TArgs extends any[], TOnTrueResult, TOnFalseResult>(
2201 fn: Pred<TArgs>,
2202 onTrue: (...args: TArgs) => TOnTrueResult,
2203 onFalse: (...args: TArgs) => TOnFalseResult,
2204): (...args: TArgs) => TOnTrueResult | TOnFalseResult;
2205
2206/**
2207 * Increments its argument.
2208 *
2209 * See also {@link dec}.
2210 *
2211 * @example
2212 * ```typescript
2213 * R.inc(42); //=> 43
2214 * ```
2215 */
2216export function inc(n: number): number;
2217
2218/**
2219 * Returns `true` if the specified value is equal, in `R.equals` terms,
2220 * to at least one element of the given list; `false` otherwise.
2221 * Also works with strings.
2222 *
2223 * See also {@link any}.
2224 *
2225 * @example
2226 * ```typescript
2227 * R.includes(3, [1, 2, 3]); //=> true
2228 * R.includes(4, [1, 2, 3]); //=> false
2229 * R.includes([42], [[42]]); //=> true
2230 * R.includes('ba', 'banana'); //=> true
2231 * R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
2232 * ```
2233 */
2234export function includes(__: Placeholder, list: readonly string[] | string): (s: string) => boolean;
2235export function includes<T>(__: Placeholder, list: readonly T[]): (target: T) => boolean;
2236export function includes(__: Placeholder): (list: readonly string[] | string, s: string) => boolean;
2237export function includes<T>(__: Placeholder): (list: readonly T[], target: T) => boolean;
2238export function includes(s: string, list: readonly string[] | string): boolean;
2239export function includes(s: string): (list: readonly string[] | string) => boolean;
2240export function includes<T>(target: T, list: readonly T[]): boolean;
2241export function includes<T>(target: T): (list: readonly T[]) => boolean;
2242
2243/**
2244 * Given a function that generates a key,
2245 * turns a list of objects into an object indexing the objects by the given key.
2246 *
2247 * @note If multiple objects generate the same value for the indexing key
2248 * only the last value will be included in the generated object.
2249 *
2250 * Acts as a transducer if a transformer is given in list position.
2251 *
2252 * See also {@link groupBy}, {@link transduce}.
2253 *
2254 * @example
2255 * ```typescript
2256 * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}];
2257 * R.indexBy(R.prop('id'), list);
2258 * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
2259 * ```
2260 */
2261export function indexBy<T, K extends string | number = string>(fn: (a: T) => K, list: readonly T[]): { [key in K]: T };
2262export function indexBy<T, K extends string | number | undefined = string>(
2263 fn: (a: T) => K,
2264 list: readonly T[],
2265): { [key in NonNullable<K>]?: T };
2266export function indexBy<T, K extends string | number = string>(
2267 fn: (a: T) => K,
2268): (list: readonly T[]) => { [key in K]: T };
2269export function indexBy<T, K extends string | number | undefined = string>(
2270 fn: (a: T) => K | undefined,
2271): (list: readonly T[]) => { [key in NonNullable<K>]?: T };
2272
2273/**
2274 * Returns the position of the first occurrence of an item in an array,
2275 * or -1 if the item is not included in the array.
2276 * {@link equals `R.equals`} is used to determine equality.
2277 *
2278 * See also {@link lastIndexOf}, {@link findIndex}.
2279 *
2280 * @example
2281 * ```typescript
2282 * R.indexOf(3, [1,2,3,4]); //=> 2
2283 * R.indexOf(10, [1,2,3,4]); //=> -1
2284 * ```
2285 */
2286export function indexOf(target: string, list: readonly string[] | string): number;
2287export function indexOf(target: string): (list: readonly string[] | string) => number;
2288export function indexOf<T>(target: T, list: readonly T[]): number;
2289export function indexOf<T>(target: T): (list: readonly T[]) => number;
2290
2291/**
2292 * Returns all but the last element of the given list or string.
2293 *
2294 * See also {@link last}, {@link head}, {@link tail}.
2295 *
2296 * @example
2297 * ```typescript
2298 * R.init([1, 2, 3]); //=> [1, 2]
2299 * R.init([1, 2]); //=> [1]
2300 * R.init([1]); //=> []
2301 * R.init([]); //=> []
2302 *
2303 * R.init('abc'); //=> 'ab'
2304 * R.init('ab'); //=> 'a'
2305 * R.init('a'); //=> ''
2306 * R.init(''); //=> ''
2307 * ```
2308 */
2309export function init<T>(list: readonly T[]): T[];
2310export function init(list: string): string;
2311
2312/**
2313 * Takes a predicate `pred`, a list `xs`, and a list `ys`,
2314 * and returns a list `xs'` comprising each of the elements of `xs`
2315 * which is equal to one or more elements of `ys` according to `pred`.
2316 *
2317 * `pred` must be a binary function expecting an element from each list.
2318 *
2319 * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should not be significant,
2320 * but since `xs'` is ordered the implementation guarantees
2321 * that its values are in the same order as they appear in `xs`.
2322 * Duplicates are not removed, so `xs'` may contain duplicates if `xs` contains duplicates.
2323 *
2324 * See also {@link intersection}.
2325 *
2326 * @example
2327 * ```typescript
2328 * R.innerJoin(
2329 * (record, id) => record.id === id,
2330 * [{id: 824, name: 'Richie Furay'},
2331 * {id: 956, name: 'Dewey Martin'},
2332 * {id: 313, name: 'Bruce Palmer'},
2333 * {id: 456, name: 'Stephen Stills'},
2334 * {id: 177, name: 'Neil Young'}],
2335 * [177, 456, 999]
2336 * );
2337 * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]
2338 * ```
2339 */
2340export function innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[], list2: readonly T2[]): T1[];
2341export function innerJoin<T1, T2>(
2342 pred: (a: T1, b: T2) => boolean,
2343): (list1: readonly T1[], list2: readonly T2[]) => T1[];
2344export function innerJoin<T1, T2>(
2345 pred: (a: T1, b: T2) => boolean,
2346 list1: readonly T1[],
2347): (list2: readonly T2[]) => T1[];
2348
2349/**
2350 * Returns a copy of the list with the element inserted at the index.
2351 *
2352 * @example
2353 * ```typescript
2354 * R.insert<string | number>(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4]
2355 * ```
2356 */
2357export function insert<T>(index: number, elt: T, list: readonly T[]): T[];
2358export function insert<T>(index: number, elt: T): (list: readonly T[]) => T[];
2359export function insert(index: number): <T>(elt: T, list: readonly T[]) => T[];
2360
2361/**
2362 * Returns a copy of the list with the elements inserted at the index.
2363 *
2364 * @example
2365 * ```typescript
2366 * R.insertAll<string | number>(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4]
2367 * ```
2368 */
2369export function insertAll<T>(index: number, elts: readonly T[], list: readonly T[]): T[];
2370export function insertAll<T>(index: number, elts: readonly T[]): (list: readonly T[]) => T[];
2371export function insertAll(index: number): <T>(elts: readonly T[], list: readonly T[]) => T[];
2372
2373/**
2374 * Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.
2375 *
2376 * See also {@link innerJoin}.
2377 *
2378 * @example
2379 * ```typescript
2380 * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3]
2381 * ```
2382 */
2383export function intersection<T>(list1: readonly T[], list2: readonly T[]): T[];
2384export function intersection<T>(list1: readonly T[]): (list2: readonly T[]) => T[];
2385
2386/**
2387 * Creates a new list with the separator interposed between elements.
2388 *
2389 * Dispatches to the `intersperse` method of the second argument, if present.
2390 *
2391 * @example
2392 * ```typescript
2393 * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's']
2394 * ```
2395 */
2396export function intersperse<T>(separator: T, list: readonly T[]): T[];
2397export function intersperse<T>(separator: T): (list: readonly T[]) => T[];
2398
2399/**
2400 * Transforms the items of the list with the transducer
2401 * and appends the transformed items to the accumulator
2402 * using an appropriate iterator function based on the accumulator type.
2403 *
2404 * The accumulator can be an array, string, object or a transformer.
2405 * Iterated items will be appended to arrays and concatenated to strings.
2406 * Objects will be merged directly or 2-item tuples will be merged as key, value pairs.
2407 *
2408 * The accumulator can also be a transformer object that provides:
2409 * - A 2-arity iterator function, which is passed directly to reduce.
2410 * - A 0-arity initial value function, which is used to provide the initial accumulator.
2411 * - A 1-arity result extraction function, which is used to convert the final accumulator into the return type.
2412 * In most cases is it is {@link identity `R.identity`}.
2413 *
2414 * The iteration is performed with {@link reduce `R.reduce`} after initializing the transducer.
2415 *
2416 * See also {@link transduce}.
2417 *
2418 * @example
2419 * ```typescript
2420 * const numbers = [1, 2, 3, 4];
2421 * const transducer = R.compose(R.map(R.add(1)), R.take(2));
2422 *
2423 * R.into([], transducer, numbers); //=> [2, 3]
2424 *
2425 * const intoArray = R.into([]);
2426 * intoArray(transducer, numbers); //=> [2, 3]
2427 * ```
2428 */
2429export function into<T>(acc: any, xf: AnyFunction, list: readonly T[]): T[];
2430export function into<T, R>(acc: any, xf: (...args: any[]) => R[], list: readonly T[]): R[];
2431export function into(acc: any, xf: AnyFunction): <T>(list: readonly T[]) => T[];
2432export function into(acc: any): <T>(xf: AnyFunction, list: readonly T[]) => T[];
2433
2434/**
2435 * Same as `R.invertObj`,
2436 * however this accounts for objects with duplicate values by putting the values into an array.
2437 *
2438 * See also {@link invertObj}.
2439 *
2440 * @example
2441 * ```typescript
2442 * const raceResultsByFirstName = {
2443 * first: 'alice',
2444 * second: 'jake',
2445 * third: 'alice',
2446 * };
2447 * R.invert(raceResultsByFirstName);
2448 * //=> { 'alice': ['first', 'third'], 'jake': ['second'] }
2449 * ```
2450 */
2451export function invert<T>(obj: T): { [index: string]: string[] };
2452
2453/**
2454 * Returns a new object with the keys of the given object as values, and the values of the given object as keys.
2455 *
2456 * @note If multiple objects generate the same value for the indexing key
2457 * only the last value will be included in the generated object.
2458 *
2459 * See also {@link invert}.
2460 *
2461 * @example
2462 * ```typescript
2463 * const raceResults = {
2464 * first: 'alice',
2465 * second: 'jake'
2466 * };
2467 * R.invertObj(raceResults);
2468 * //=> { 'alice': 'first', 'jake':'second' }
2469 *
2470 * // Alternatively:
2471 * const raceResults = ['alice', 'jake'];
2472 * R.invertObj(raceResults);
2473 * //=> { 'alice': '0', 'jake':'1' }
2474 * ```
2475 */
2476export function invertObj(obj: { [index: string]: string } | { [index: number]: string }): { [index: string]: string };
2477
2478/**
2479 * Turns a named method with a specified arity into a function that can be called directly
2480 * supplied with arguments and a target object.
2481 *
2482 * The returned function is curried and accepts `arity + 1` parameters
2483 * where the final parameter is the target object.
2484 *
2485 * @example
2486 * ```typescript
2487 * const sliceFrom = R.invoker<(start: number, s: string) => string>(1, 'slice');
2488 * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm'
2489 * const sliceFrom6 = R.invoker<(start: number, end: number, s: string) => string>(2, 'slice')(6);
2490 * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh'
2491 *
2492 * const dog = {
2493 * speak: async () => 'Woof!'
2494 * };
2495 * const speak = R.invoker<(speaker: { speak: () => Promise<string> }) => Promise<string>>(0, 'speak');
2496 * speak(dog).then(console.log) //~> 'Woof!'
2497 * ```
2498 */
2499export function invoker(arity: number, method: string): (...args: unknown[]) => any;
2500
2501/**
2502 * See if an object (`val`) is an instance of the supplied constructor.
2503 * This function will check up the inheritance chain, if any.
2504 * If `val` was created using `Object.create`, `R.is(Object, val) === true`.
2505 *
2506 * See also {@link propIs}.
2507 */
2508export function is<C extends AnyFunction>(ctor: C, val: any): val is ReturnType<C>;
2509export function is<C extends AnyConstructor>(ctor: C, val: any): val is InstanceType<C>;
2510export function is<C extends AnyFunction>(ctor: C): (val: any) => val is ReturnType<C>;
2511export function is<C extends AnyConstructor>(ctor: C): (val: any) => val is InstanceType<C>;
2512
2513/**
2514 * Returns `true` if the given value is its type's empty value; `false` otherwise.
2515 *
2516 * See also {@link empty}.
2517 *
2518 * @example
2519 * ```typescript
2520 * R.isEmpty([1, 2, 3]); //=> false
2521 * R.isEmpty([]); //=> true
2522 * R.isEmpty(''); //=> true
2523 * R.isEmpty(null); //=> false
2524 * R.isEmpty({}); //=> true
2525 * R.isEmpty({length: 0}); //=> false
2526 * R.isEmpty(Uint8Array.from([])); //=> true
2527 * ```
2528 */
2529export function isEmpty(value: any): boolean;
2530
2531/**
2532 * Checks if the input value is `null` or `undefined`.
2533 *
2534 * @example
2535 * ```typescript
2536 * R.isNil(null); //=> true
2537 * R.isNil(undefined); //=> true
2538 * R.isNil(0); //=> false
2539 * R.isNil([]); //=> false
2540 * ```
2541 */
2542export function isNil(value: any): value is null | undefined;
2543
2544/**
2545 * Returns a string made by inserting the given separator between each element
2546 * and concatenating all the elements into a single string.
2547 *
2548 * See also {@link split}.
2549 *
2550 * @example
2551 * ```typescript
2552 * const spacer = R.join(' ');
2553 * spacer(['a', 2, 3.4]); //=> 'a 2 3.4'
2554 * R.join('|', [1, 2, 3]); //=> '1|2|3'
2555 * ```
2556 */
2557export function join(x: string, xs: readonly any[]): string;
2558export function join(x: string): (xs: readonly any[]) => string;
2559
2560/**
2561 * Applies a list of functions to a list of values.
2562 *
2563 * See also {@link applySpec}.
2564 *
2565 * @example
2566 * ```typescript
2567 * const getRange = R.juxt([Math.min, Math.max]);
2568 * getRange(3, 4, 9, -3); //=> [-3, 9]
2569 * ```
2570 */
2571export function juxt<A extends any[], R1>(fns: [(...args: A) => R1]): (...args: A) => [R1];
2572export function juxt<A extends any[], R1, R2>(fns: [(...args: A) => R1, (...args: A) => R2]): (...args: A) => [R1, R2];
2573export function juxt<A extends any[], R1, R2, R3>(
2574 fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3],
2575): (...args: A) => [R1, R2, R3];
2576export function juxt<A extends any[], R1, R2, R3, R4>(
2577 fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3, (...args: A) => R4],
2578): (...args: A) => [R1, R2, R3, R4];
2579export function juxt<A extends any[], R1, R2, R3, R4, R5>(
2580 fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3, (...args: A) => R4, (...args: A) => R5],
2581): (...args: A) => [R1, R2, R3, R4, R5];
2582export function juxt<A extends any[], U>(fns: ReadonlyArray<(...args: A) => U>): (...args: A) => U[];
2583
2584/**
2585 * Returns a list containing the names of all the enumerable own properties of the supplied object.
2586 *
2587 * @note The order of the output array is not guaranteed to be consistent across different JS platforms.
2588 *
2589 * See also {@link keysIn}, {@link values}, {@link toPairs}.
2590 *
2591 * @example
2592 * ```typescript
2593 * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
2594 * ```
2595 */
2596export function keys<T extends object>(x: T): Array<keyof T>;
2597export function keys<T>(x: T): string[];
2598
2599/**
2600 * Returns a list containing the names of all the properties of the supplied object,
2601 * including prototype properties.
2602 *
2603 * @note The order of the output array is not guaranteed to be consistent across different JS platforms.
2604 *
2605 * See also {@link keys}, {@link valuesIn}.
2606 *
2607 * @example
2608 * ```typescript
2609 * class F {
2610 * y = 'Y';
2611 * constructor(public x: string = 'X') {}
2612 * }
2613 *
2614 * const f = new F();
2615 * R.keysIn(f); //=> ['x', 'y']
2616 * ```
2617 */
2618export function keysIn<T>(obj: T): string[];
2619
2620/**
2621 * Returns the last element of the given list or string.
2622 *
2623 * See also {@link init}, {@link head}, {@link tail}.
2624 *
2625 * @example
2626 * ```typescript
2627 * R.last(['fi', 'fo', 'fum']); //=> 'fum'
2628 * R.last([]); //=> undefined
2629 *
2630 * R.last('abc'); //=> 'c'
2631 * R.last(''); //=> ''
2632 * ```
2633 */
2634export function last(str: string): string;
2635export function last(list: readonly []): undefined;
2636export function last<T>(list: readonly T[]): T | undefined;
2637
2638/**
2639 * Returns the position of the last occurrence of an item in an array,
2640 * or `-1` if the item is not included in the array.
2641 * {@link equals `R.equals`} is used to determine equality.
2642 *
2643 * See also {@link indexOf}, {@link findLastIndex}.
2644 *
2645 * @example
2646 * ```typescript
2647 * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6
2648 * R.lastIndexOf(10, [1,2,3,4]); //=> -1
2649 * ```
2650 */
2651export function lastIndexOf(target: string, list: readonly string[] | string): number;
2652export function lastIndexOf(target: string): (list: readonly string[] | string) => number;
2653export function lastIndexOf<T>(target: T, list: readonly T[]): number;
2654export function lastIndexOf<T>(target: T): (list: readonly T[]) => number;
2655
2656/**
2657 * Returns the number of elements in the array by returning `list.length`.
2658 *
2659 * @example
2660 * ```typescript
2661 * R.length([]); //=> 0
2662 * R.length([1, 2, 3]); //=> 3
2663 * ```
2664 */
2665export function length<T extends ArrayLike<unknown>>(list: T): number;
2666
2667/**
2668 * Returns a lens for the given getter and setter functions.
2669 * The getter "gets" the value of the focus; the setter "sets" the value of the focus.
2670 * The setter should not mutate the data structure.
2671 *
2672 * See also {@link view}, {@link set}, {@link over}, {@link lensIndex}, {@link lensProp}.
2673 */
2674export function lens<S, A>(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens<S, A>;
2675
2676/**
2677 * Returns a lens whose focus is the specified index.
2678 *
2679 * See also {@link view}, {@link set}, {@link over}, {@link nth}, {@link lens}.
2680 *
2681 * @example
2682 * ```typescript
2683 * const headLens = R.lensIndex<string>(0);
2684 *
2685 * R.view(headLens, ['a', 'b', 'c']); //=> 'a'
2686 * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c']
2687 * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c']
2688 * ```
2689 */
2690export function lensIndex<A>(n: number): Lens<A[], A>;
2691export function lensIndex<A extends any[], N extends number>(n: N): Lens<A, A[N]>;
2692
2693/**
2694 * Returns a lens whose focus is the specified path.
2695 *
2696 * See also {@link view}, {@link set}, {@link over}, {@link lens}.
2697 *
2698 * @example
2699 * ```typescript
2700 * const xHeadYLens = R.lensPath<{ x: { y: number; z: number; }[]; }, 'x', 0, 'y'>(['x', 0, 'y']);
2701 *
2702 * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
2703 * //=> 2
2704 * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
2705 * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]}
2706 * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
2707 * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]}
2708 * ```
2709 */
2710export function lensPath<S, K0 extends keyof S = keyof S>(path: [K0]): Lens<S, S[K0]>;
2711export function lensPath<S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0]>(
2712 path: [K0, K1],
2713): Lens<S, S[K0][K1]>;
2714export function lensPath<
2715 S,
2716 K0 extends keyof S = keyof S,
2717 K1 extends keyof S[K0] = keyof S[K0],
2718 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
2719>(path: [K0, K1, K2]): Lens<S, S[K0][K1][K2]>;
2720export function lensPath<
2721 S,
2722 K0 extends keyof S = keyof S,
2723 K1 extends keyof S[K0] = keyof S[K0],
2724 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
2725 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
2726>(path: [K0, K1, K2, K3]): Lens<S, S[K0][K1][K2][K3]>;
2727export function lensPath<
2728 S,
2729 K0 extends keyof S = keyof S,
2730 K1 extends keyof S[K0] = keyof S[K0],
2731 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
2732 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
2733 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
2734>(path: [K0, K1, K2, K3, K4]): Lens<S, S[K0][K1][K2][K3][K4]>;
2735export function lensPath<
2736 S,
2737 K0 extends keyof S = keyof S,
2738 K1 extends keyof S[K0] = keyof S[K0],
2739 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
2740 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
2741 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
2742 K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4],
2743>(path: [K0, K1, K2, K3, K4, K5]): Lens<S, S[K0][K1][K2][K3][K4][K5]>;
2744
2745export function lensPath<S = any, A = any>(path: Path): Lens<S, A>;
2746
2747/**
2748 * Returns a lens whose focus is the specified property.
2749 *
2750 * See also {@link view}, {@link set}, {@link over}, {@link lens}.
2751 *
2752 * @example
2753 * ```typescript
2754 * type Point = { x: number; y: number; };
2755 *
2756 * const xLens = R.lensProp<Point, 'x'>('x');
2757 *
2758 * R.view(xLens, {x: 1, y: 2}); //=> 1
2759 * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
2760 * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
2761 * ```
2762 */
2763export function lensProp<S, K extends keyof S = keyof S>(prop: K): Lens<S, S[K]>;
2764
2765/**
2766 * "lifts" a function of arity > 1 so that it may "map over" a list,
2767 * `Function` or other object that satisfies the FantasyLand Apply spec.
2768 *
2769 * See also {@link liftN}.
2770 *
2771 * @example
2772 * ```typescript
2773 * const madd3 = R.lift((a: number, b: number, c: number) => a + b + c);
2774 *
2775 * madd3([100, 200], [30, 40], [5, 6, 7]); //=> [135, 136, 137, 145, 146, 147, 235, 236, 237, 245, 246, 247]
2776 *
2777 * const madd5 = R.lift((a: number, b: number, c: number, d: number, e: number) => a + b + c + d + e);
2778 *
2779 * madd5([10, 20], [1], [2, 3], [4], [100, 200]); //=> [117, 217, 118, 218, 127, 227, 128, 228]
2780 * ```
2781 */
2782export function lift<F extends AnyFunction>(
2783 fn: F,
2784): {
2785 (...args: ToTupleOfArray<Parameters<F>>): Array<ReturnType<F>>;
2786 <R>(...args: ToTupleOfFunction<R, Parameters<F>>): (arg: R) => ReturnType<F>;
2787};
2788
2789/**
2790 * "lifts" a function to be the specified arity,
2791 * so that it may "map over" that many lists, Functions or other objects
2792 * that satisfy the FantasyLand Apply spec.
2793 *
2794 * See also {@link lift}, {@link ap}.
2795 *
2796 * @example
2797 * ```typescript
2798 * const madd3 = R.liftN(3, (...args: [number, number, number]) => R.sum(args));
2799 * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
2800 * ```
2801 */
2802export function liftN<N extends number, F extends AnyFunction>(
2803 n: N,
2804 fn: F,
2805): {
2806 (...args: Take<N, ToTupleOfArray<Parameters<F>>>): Array<ReturnType<F>>;
2807 <R>(...args: Take<N, ToTupleOfFunction<R, Parameters<F>>>): (arg: R) => ReturnType<F>;
2808};
2809
2810/**
2811 * Returns `true` if the first parameter is less than the second; `false` otherwise.
2812 *
2813 * See also {@link gt}, {@link gte}, {@link lte}.
2814 *
2815 * @example
2816 * ```typescript
2817 * R.lt(2, 1); //=> false
2818 * R.lt(2, 2); //=> false
2819 * R.lt(2, 3); //=> true
2820 * R.lt('a', 'z'); //=> true
2821 * R.lt('z', 'a'); //=> false
2822 * ```
2823 */
2824export function lt(__: Placeholder, b: number): (a: number) => boolean;
2825export function lt(__: Placeholder): (b: number, a: number) => boolean;
2826export function lt(a: number, b: number): boolean;
2827export function lt(a: string, b: string): boolean;
2828export function lt(a: number): (b: number) => boolean;
2829
2830/**
2831 * Returns `true` if the first parameter is less than or equal to the second; `false` otherwise.
2832 *
2833 * See also {@link gt}, {@link gte}, {@link lt}.
2834 *
2835 * @example
2836 * ```typescript
2837 * R.lte(2, 1); //=> false
2838 * R.lte(2, 2); //=> true
2839 * R.lte(2, 3); //=> true
2840 * R.lte('a', 'z'); //=> true
2841 * R.lte('z', 'a'); //=> false
2842 * ```
2843 */
2844export function lte(__: Placeholder, b: number): (a: number) => boolean;
2845export function lte(__: Placeholder): (b: number, a: number) => boolean;
2846export function lte(a: number, b: number): boolean;
2847export function lte(a: string, b: string): boolean;
2848export function lte(a: number): (b: number) => boolean;
2849
2850/**
2851 * Takes a function and a functor,
2852 * applies the function to each of the functor's values,
2853 * and returns a functor of the same shape.
2854 *
2855 * Ramda provides suitable `map` implementations for `Array` and `Object`,
2856 * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`.
2857 *
2858 * Dispatches to the `map` method of the second argument, if present.
2859 *
2860 * Acts as a transducer if a transformer is given in list position.
2861 *
2862 * Also treats functions as functors and will compose them together.
2863 *
2864 * See also {@link addIndex}, {@link pluck}, {@link project}, {@link transduce}.
2865 *
2866 * @example
2867 * ```typescript
2868 * const double = x => x * 2;
2869 *
2870 * R.map(double, [1, 2, 3]); //=> [2, 4, 6]
2871 *
2872 * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}
2873 * ```
2874 */
2875export function map<T, U>(fn: (x: T) => U, list: readonly T[]): U[];
2876export function map<T, U>(fn: (x: T) => U): (list: readonly T[]) => U[];
2877export function map<T, U>(fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U], list: T): U;
2878export function map<T, U>(fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U]): (list: T) => U;
2879export function map<T, U>(fn: (x: T) => U, obj: Functor<T>): Functor<U>; // used in functors
2880export function map<T, U>(fn: (x: T) => U): (obj: Functor<T>) => Functor<U>; // used in functors
2881
2882/**
2883 * The `mapAccum` function behaves like a combination of map and reduce;
2884 * it applies a function to each element of a list,
2885 * passing an accumulating parameter from left to right,
2886 * and returning a final value of this accumulator together with the new list.
2887 *
2888 * The iterator function receives two arguments, `acc` and `value`,
2889 * and should return a tuple `[acc, value]`.
2890 *
2891 * See also {@link scan}, {@link addIndex}, {@link mapAccumRight}.
2892 *
2893 * @example
2894 * ```typescript
2895 * const digits = ['1', '2', '3', '4'];
2896 * const appender = (a: string, b: string) => [a + b, a + b] as const;
2897 *
2898 * R.mapAccum(appender, '0', digits); //=> ['01234', ['01', '012', '0123', '01234']]
2899 * ```
2900 */
2901export function mapAccum<T, U, TResult>(
2902 fn: (acc: U, value: T) => [U, TResult],
2903 acc: U,
2904 list: readonly T[],
2905): [U, TResult[]];
2906export function mapAccum<T, U, TResult>(
2907 fn: (acc: U, value: T) => [U, TResult],
2908): (acc: U, list: readonly T[]) => [U, TResult[]];
2909export function mapAccum<T, U, TResult>(
2910 fn: (acc: U, value: T) => [U, TResult],
2911 acc: U,
2912): (list: readonly T[]) => [U, TResult[]];
2913
2914/**
2915 * Applies a function to each element of a list,
2916 * passing an accumulating parameter from right to left,
2917 * and returning a final value of this accumulator together with the new list.
2918 *
2919 * Similar to `R.mapAccum`, except moves through the input list from the right to the left.
2920 *
2921 * The iterator function receives two arguments, `acc` and `value`,
2922 * and should return a tuple `[acc, value]`.
2923 *
2924 * See also {@link addIndex}, {@link mapAccum}.
2925 *
2926 * @example
2927 * ```typescript
2928 * const digits = ['1', '2', '3', '4'];
2929 * const appender = (a: string, b: string) => [b + a, b + a] as const;
2930 *
2931 * R.mapAccumRight(appender, '5', digits); //=> ['12345', ['12345', '2345', '345', '45']]
2932 * ```
2933 */
2934export function mapAccumRight<T, U, TResult>(
2935 fn: (acc: U, value: T) => [U, TResult],
2936 acc: U,
2937 list: readonly T[],
2938): [U, TResult[]];
2939export function mapAccumRight<T, U, TResult>(
2940 fn: (acc: U, value: T) => [U, TResult],
2941): (acc: U, list: readonly T[]) => [U, TResult[]];
2942export function mapAccumRight<T, U, TResult>(
2943 fn: (acc: U, value: T) => [U, TResult],
2944 acc: U,
2945): (list: readonly T[]) => [U, TResult[]];
2946
2947/**
2948 * Like mapObj, but but passes additional arguments to the predicate function.
2949 */
2950type PartialRecord<K extends keyof any, T> = {
2951 [P in K]?: T;
2952};
2953export function mapObjIndexed<T, TResult, TKey extends string>(
2954 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult,
2955 obj: Record<TKey, T>,
2956): Record<TKey, TResult>;
2957export function mapObjIndexed<T, TResult, TKey extends string>(
2958 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult,
2959 obj: PartialRecord<TKey, T>,
2960): PartialRecord<TKey, TResult>;
2961export function mapObjIndexed<T, TResult, TKey extends string>(
2962 fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult,
2963): (obj: Record<TKey, T>) => Record<TKey, TResult>;
2964export function mapObjIndexed<T, TResult, TKey extends string>(
2965 fn: (value: T, key: TKey, obj?: PartialRecord<TKey, T>) => TResult,
2966): (obj: Record<TKey, T>) => PartialRecord<TKey, TResult>;
2967export function mapObjIndexed<T, TResult>(
2968 fn: (
2969 value: T,
2970 key: string,
2971 obj?: {
2972 [key: string]: T;
2973 },
2974 ) => TResult,
2975 obj: {
2976 [key: string]: T;
2977 },
2978): {
2979 [key: string]: TResult;
2980};
2981
2982/**
2983 * Tests a `RegExp` against a String.
2984 *
2985 * @note This function will return an empty array when there are no matches.
2986 * This differs from `String.prototype.match` which returns `null` when there are no matches.
2987 *
2988 * @example
2989 * ```typescript
2990 * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na']
2991 * R.match(/a/, 'b'); //=> []
2992 * ```
2993 */
2994export function match(regexp: RegExp, str: string): string[];
2995export function match(regexp: RegExp): (str: string) => string[];
2996
2997/**
2998 * `mathMod` behaves like the modulo operator should mathematically,
2999 * unlike the `%` operator (and by extension, `R.modulo`).
3000 * So while `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`.
3001 * `mathMod` requires integer arguments,
3002 * and returns `NaN` when the modulus is zero or negative.
3003 *
3004 * See also {@link modulo}.
3005 *
3006 * @example
3007 * ```typescript
3008 * R.mathMod(-17, 5); //=> 3
3009 * R.mathMod(17, 5); //=> 2
3010 * R.mathMod(17, -5); //=> NaN
3011 * R.mathMod(17, 0); //=> NaN
3012 * R.mathMod(17.2, 5); //=> NaN
3013 * R.mathMod(17, 5.3); //=> NaN
3014 *
3015 * const clock = R.mathMod(R.__, 12);
3016 * clock(15); //=> 3
3017 * clock(24); //=> 0
3018 *
3019 * const seventeenMod = R.mathMod(17);
3020 * seventeenMod(3); //=> 2
3021 * seventeenMod(4); //=> 1
3022 * seventeenMod(10); //=> 7
3023 * ```
3024 */
3025export function mathMod(__: Placeholder, b: number): (a: number) => number;
3026export function mathMod(__: Placeholder): (b: number, a: number) => number;
3027export function mathMod(a: number, b: number): number;
3028export function mathMod(a: number): (b: number) => number;
3029
3030/**
3031 * Returns the larger of its two arguments.
3032 *
3033 * See also {@link maxBy}, {@link min}, {@link minBy}.
3034 *
3035 * @example
3036 * ```typescript
3037 * R.max(789, 123); //=> 789
3038 * R.max('a', 'b'); //=> 'b'
3039 * ```
3040 */
3041export function max<T extends Ord>(a: T, b: T): T;
3042export function max<T extends Ord>(a: T): (b: T) => T;
3043
3044/**
3045 * Takes a function and two values, and returns whichever value produces
3046 * the larger result when passed to the provided function.
3047 *
3048 * See also {@link max}, {@link min}, {@link minBy}.
3049 *
3050 * @example
3051 * ```typescript
3052 * // square :: Number -> Number
3053 * const square = (n: number) => n * n;
3054 *
3055 * R.maxBy(square, -3, 2); //=> -3
3056 *
3057 * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
3058 * R.reduce(R.maxBy(square), 0, [] as number[]); //=> 0
3059 * ```
3060 */
3061export function maxBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T;
3062export function maxBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T;
3063export function maxBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>;
3064
3065/**
3066 * Returns the mean of the given list of numbers.
3067 *
3068 * See also {@link median}.
3069 *
3070 * @example
3071 * ```typescript
3072 * R.mean([2, 7, 9]); //=> 6
3073 * R.mean([]); //=> NaN
3074 * ```
3075 */
3076export function mean(list: readonly number[]): number;
3077
3078/**
3079 * Returns the median of the given list of numbers.
3080 *
3081 * See also {@link mean}.
3082 *
3083 * @example
3084 * ```typescript
3085 * R.median([2, 9, 7]); //=> 7
3086 * R.median([7, 2, 10, 9]); //=> 8
3087 * R.median([]); //=> NaN
3088 * ```
3089 */
3090export function median(list: readonly number[]): number;
3091
3092/**
3093 * Creates a new function that, when invoked,
3094 * caches the result of calling the given function for a given argument set and returns the result.
3095 * Subsequent calls to the memoized function with the same argument set will return the cached result.
3096 *
3097 * @example
3098 * ```typescript
3099 * let count = 0;
3100 * const factorial = R.memoizeWith(String, (n: number) => {
3101 * count += 1;
3102 * return R.product(R.range(1, n + 1));
3103 * });
3104 * factorial(5); //=> 120
3105 * factorial(5); //=> 120
3106 * factorial(5); //=> 120
3107 * count; //=> 1
3108 * ```
3109 */
3110export function memoizeWith<T extends AnyFunction>(keyFn: (...v: Parameters<T>) => string, fn: T): T;
3111
3112/**
3113 * Create a new object with the own properties of a
3114 * merged with the own properties of object b.
3115 * This function will *not* mutate passed-in objects.
3116 *
3117 * @deprecated since 0.26 in favor of mergeRight
3118 */
3119export function merge<O2 extends object>(__: Placeholder, b: O2): <O1 extends object>(a: O1) => Merge<O2, O1, 'flat'>;
3120export function merge(__: Placeholder): <O1 extends object, O2 extends object>(b: O2, a: O1) => Merge<O2, O1, 'flat'>;
3121export function merge<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O2, O1, 'flat'>;
3122export function merge<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O2, O1, 'flat'>;
3123
3124/**
3125 * Creates one new object with the own properties from a list of objects.
3126 * If a key exists in more than one object,
3127 * the value from the last object it exists in will be used.
3128 *
3129 * See also {@link reduce}.
3130 *
3131 * @example
3132 * ```typescript
3133 * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3}
3134 * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2}
3135 * ```
3136 */
3137export function mergeAll<Os extends readonly object[]>(list: Os): MergeAll<Os>;
3138
3139/**
3140 * Creates a new object with the own properties of the first object
3141 * merged with the own properties of the second object.
3142 *
3143 * If a key exists in both objects:
3144 * - and both values are objects, the two values will be recursively merged
3145 * - otherwise the value from the first object will be used.
3146 *
3147 * See also {@link mergeDeepRight}, {@link mergeDeepWith}, {@link mergeDeepWithKey}.
3148 *
3149 * @example
3150 * ```typescript
3151 * R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
3152 * { age: 40, contact: { email: 'baa@example.com' }});
3153 * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }}
3154 * ```
3155 */
3156export function mergeDeepLeft<O1 extends object, O2 extends object>(o1: O1, o2: O2): Merge<O1, O2, 'deep'>;
3157export function mergeDeepLeft<O1 extends object>(o1: O1): <O2 extends object>(o2: O2) => Merge<O1, O2, 'deep'>;
3158
3159/**
3160 * Creates a new object with the own properties of the first object
3161 * merged with the own properties of the second object.
3162 *
3163 * If a key exists in both objects:
3164 * - and both values are objects, the two values will be recursively merged
3165 * - otherwise the value from the second object will be used.
3166 *
3167 * See also {@link mergeDeepLeft}, {@link mergeDeepWith}, {@link mergeDeepWithKey}.
3168 *
3169 * @example
3170 * ```typescript
3171 * R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
3172 * { age: 40, contact: { email: 'baa@example.com' }});
3173 * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }}
3174 * ```
3175 */
3176export function mergeDeepRight<O1 extends object, O2 extends object>(o1: O1, o2: O2): Merge<O2, O1, 'deep'>;
3177export function mergeDeepRight<O1 extends object>(a: O1): <O2 extends object>(o2: O2) => Merge<O2, O1, 'deep'>;
3178
3179/**
3180 * Creates a new object with the own properties of the two provided objects.
3181 *
3182 * If a key exists in both objects:
3183 * - and both associated values are also objects then the values will be recursively merged.
3184 * - otherwise the provided function is applied to associated values
3185 * using the resulting value as the new value associated with the key.
3186 * If a key only exists in one object,
3187 * the value will be associated with the key of the resulting object.
3188 *
3189 * See also {@link mergeWith}, {@link mergeDeepWithKey}.
3190 *
3191 * @example
3192 * ```typescript
3193 * R.mergeDeepWith(R.concat,
3194 * { a: true, c: { values: [10, 20] }},
3195 * { b: true, c: { values: [15, 35] }});
3196 * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
3197 * ```
3198 */
3199export function mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any, a: T1, b: T2): any;
3200export function mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any, a: T1): (b: T2) => any;
3201export function mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any): (a: T1, b: T2) => any;
3202
3203/**
3204 * Creates a new object with the own properties of the two provided objects. If a key exists in both objects:
3205 * and both associated values are also objects then the values will be recursively merged.
3206 * otherwise the provided function is applied to the key and associated values using the resulting value as
3207 * the new value associated with the key. If a key only exists in one object, the value will be associated with
3208 * the key of the resulting object.
3209 *
3210 * See also {@link mergeWith}, {@link mergeWithKey}, {@link mergeDeepWith}.
3211 *
3212 * @example
3213 * ```typescript
3214 * let concatValues = <T>(k: string, l: T, r: T) => k == 'values' ? R.concat(l, r) : r
3215 * R.mergeDeepWithKey(concatValues,
3216 * { a: true, c: { thing: 'foo', values: [10, 20] }},
3217 * { b: true, c: { thing: 'bar', values: [15, 35] }});
3218 * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
3219 * ```
3220 */
3221export function mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any, a: T1, b: T2): any;
3222export function mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any, a: T1): (b: T2) => any;
3223export function mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any): (a: T1, b: T2) => any;
3224
3225/**
3226 * Create a new object with the own properties of the first object
3227 * merged with the own properties of the second object.
3228 * If a key exists in both objects,
3229 * the value from the first object will be used.
3230 *
3231 * See also {@link mergeRight}, {@link mergeDeepLeft}, {@link mergeWith}, {@link mergeWithKey}.
3232 *
3233 * @example
3234 * ```typescript
3235 * R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 });
3236 * //=> { 'name': 'fred', 'age': 40 }
3237 *
3238 * const resetToDefault = R.mergeLeft({x: 0});
3239 * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2}
3240 * ```
3241 */
3242export function mergeLeft<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O1, O2, 'flat'>;
3243export function mergeLeft<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O1, O2, 'flat'>;
3244
3245/**
3246 * Create a new object with the own properties of the first object merged with the own properties of the second object.
3247 * If a key exists in both objects, the value from the second object will be used.
3248 *
3249 * See also {@link mergeLeft}, {@link mergeDeepRight}, {@link mergeWith}, {@link mergeWithKey}.
3250 *
3251 * @example
3252 * ```typescript
3253 * R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 });
3254 * //=> { 'name': 'fred', 'age': 40 }
3255 *
3256 * const withDefaults = R.mergeRight({x: 0, y: 0});
3257 * withDefaults({y: 2}); //=> {x: 0, y: 2}
3258 * ```
3259 */
3260export function mergeRight<O1 extends object, O2 extends object>(a: O1, b: O2): Merge<O2, O1, 'flat'>;
3261export function mergeRight<O1 extends object>(a: O1): <O2 extends object>(b: O2) => Merge<O2, O1, 'flat'>;
3262
3263/**
3264 * Creates a new object with the own properties of the two provided objects.
3265 * If a key exists in both objects,
3266 * the provided function is applied to the values associated with the key in each object,
3267 * with the result being used as the value associated with the key in the returned object.
3268 * The key will be excluded from the returned object
3269 * if the resulting value is `undefined`.
3270 *
3271 * See also {@link mergeDeepWith}, {@link merge}, {@link mergeWithKey}.
3272 *
3273 * @example
3274 * ```typescript
3275 * R.mergeWith(R.concat,
3276 * { a: true, values: [10, 20] },
3277 * { b: true, values: [15, 35] });
3278 * //=> { a: true, b: true, values: [10, 20, 15, 35] }
3279 * ```
3280 */
3281export function mergeWith<U, V>(fn: (x: any, z: any) => any, a: U, b: V): any;
3282export function mergeWith<U>(fn: (x: any, z: any) => any, a: U): <V>(b: V) => any;
3283export function mergeWith(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => any;
3284
3285/**
3286 * Creates a new object with the own properties of the two provided objects.
3287 * If a key exists in both objects,
3288 * the provided function is applied to the key and the values associated with the key in each object,
3289 * with the result being used as the value associated with the key in the returned object.
3290 * The key will be excluded from the returned object
3291 * if the resulting value is `undefined`.
3292 *
3293 * See also {@link mergeDeepWithKey}, {@link merge}, {@link mergeWith}.
3294 *
3295 * @example
3296 * ```typescript
3297 * let concatValues = <T>(k: string, l: T, r: T) => k == 'values' ? R.concat(l as any, r as any) : r
3298 * R.mergeWithKey(concatValues,
3299 * { a: true, thing: 'foo', values: [10, 20] },
3300 * { b: true, thing: 'bar', values: [15, 35] });
3301 * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
3302 * ```
3303 */
3304export function mergeWithKey<U, V>(fn: (str: string, x: any, z: any) => any, a: U, b: V): any;
3305export function mergeWithKey<U>(fn: (str: string, x: any, z: any) => any, a: U): <V>(b: V) => any;
3306export function mergeWithKey(fn: (str: string, x: any, z: any) => any): <U, V>(a: U, b: V) => any;
3307
3308/**
3309 * Returns the smaller of its two arguments.
3310 *
3311 * See also {@link minBy}, {@link max}.
3312 *
3313 * @example
3314 * ```typescript
3315 * R.min(789, 123); //=> 123
3316 * R.min('a', 'b'); //=> 'a'
3317 * ```
3318 */
3319export function min<T extends Ord>(a: T, b: T): T;
3320export function min<T extends Ord>(a: T): (b: T) => T;
3321
3322/**
3323 * Takes a function and two values,
3324 * and returns whichever value produces the smaller result
3325 * when passed to the provided function.
3326 *
3327 * See also {@link min}, {@link maxBy}.
3328 *
3329 * @example
3330 * ```typescript
3331 * // square :: Number -> Number
3332 * const square = (n: number) => n * n;
3333 *
3334 * R.minBy(square, -3, 2); //=> 2
3335 *
3336 * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1
3337 * R.reduce(R.minBy(square), Infinity, [] as number); //=> Infinity
3338 * ```
3339 */
3340export function minBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T;
3341export function minBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T;
3342export function minBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>;
3343
3344/**
3345 * Returns the modulo of two numbers. Equivalent to `a % b` but curried.
3346 *
3347 * Divides the first parameter by the second and returns the remainder.
3348 * Note that this function preserves the JavaScript-style behavior for modulo.
3349 * For mathematical modulo see `R.mathMod`.
3350 *
3351 * See also {@link mathMod}.
3352 *
3353 * @example
3354 * ```typescript
3355 * R.modulo(17, 3); //=> 2
3356 * // JS behavior:
3357 * R.modulo(-17, 3); //=> -2
3358 * R.modulo(17, -3); //=> 2
3359 *
3360 * const isOdd = R.modulo(R.__, 2);
3361 * isOdd(42); //=> 0
3362 * isOdd(21); //=> 1
3363 * ```
3364 */
3365export function modulo(__: Placeholder, b: number): (a: number) => number;
3366export function modulo(__: Placeholder): (b: number, a: number) => number;
3367export function modulo(a: number, b: number): number;
3368export function modulo(a: number): (b: number) => number;
3369
3370/**
3371 * Returns a copy of the given list
3372 * with the item at the given source index moved to the given destination index.
3373 *
3374 * @example
3375 * ```typescript
3376 * R.move(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['b', 'c', 'a', 'd', 'e', 'f']
3377 * R.move(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'a', 'b', 'c', 'd', 'e'] list rotation
3378 * ```
3379 */
3380export function move<T>(from: number, to: number, list: readonly T[]): T[];
3381export function move(from: number, to: number): <T>(list: readonly T[]) => T[];
3382export function move(from: number): {
3383 <T>(to: number, list: readonly T[]): T[];
3384 (to: number): <T>(list: readonly T[]) => T[];
3385};
3386
3387/**
3388 * Multiplies two numbers. Equivalent to `a * b` but curried.
3389 *
3390 * See also {@link divide}.
3391 *
3392 * @example
3393 * ```typescript
3394 * const double = R.multiply(2);
3395 * const triple = R.multiply(3);
3396 * double(3); //=> 6
3397 * triple(4); //=> 12
3398 * R.multiply(2, 5); //=> 10
3399 * ```
3400 */
3401export function multiply(a: number, b: number): number;
3402export function multiply(a: number): (b: number) => number;
3403
3404/**
3405 * Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters.
3406 * Any extraneous parameters will not be passed to the supplied function.
3407 *
3408 * See also {@link binary}, {@link unary}.
3409 *
3410 * @example
3411 * ```typescript
3412 * const takesTwoArgs = <T, U>(a: T, b: U) => [a, b];
3413 *
3414 * takesTwoArgs.length; //=> 2
3415 * takesTwoArgs(1, 2); //=> [1, 2]
3416 *
3417 * const takesOneArg = R.nAry(1, takesTwoArgs);
3418 * takesOneArg.length; //=> 1
3419 * // Only `n` arguments are passed to the wrapped function
3420 * takesOneArg(1); //=> [1, undefined]
3421 * ```
3422 */
3423export function nAry<N extends number, T extends AnyFunction>(
3424 n: N,
3425 fn: T,
3426): (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>;
3427export function nAry<N extends number>(
3428 n: N,
3429): <T extends AnyFunction>(fn: T) => (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>;
3430
3431/**
3432 * Negates its argument.
3433 *
3434 * @example
3435 * ```typescript
3436 * R.negate(42); //=> -42
3437 * ```
3438 */
3439export function negate(n: number): number;
3440
3441/**
3442 * Returns `true` if no elements of the list match the predicate, `false` otherwise.
3443 *
3444 * Dispatches to the `all` method of the second argument, if present.
3445 *
3446 * Acts as a transducer if a transformer is given in list position.
3447 *
3448 * See also {@link all}, {@link any}, {@link transduce}.
3449 *
3450 * @example
3451 * ```typescript
3452 * const isEven = (n: number) => n % 2 === 0;
3453 * const isOdd = (n: number) => n % 2 !== 0;
3454 *
3455 * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true
3456 * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false
3457 * ```
3458 */
3459export function none<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
3460export function none<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
3461
3462/**
3463 * A function that returns the `!` of its argument.
3464 * It will return true when passed falsy value, and false when passed a truthy one.
3465 *
3466 * See also {@link complement}.
3467 *
3468 * @example
3469 * ```typescript
3470 * R.not(true); //=> false
3471 * R.not(false); //=> true
3472 * R.not(0); //=> true
3473 * R.not(1); //=> false
3474 * ```
3475 */
3476export function not(value: any): boolean;
3477
3478/**
3479 * Returns the nth element of the given list or string.
3480 *
3481 * If `n` is negative the element at index `length + n` is returned.
3482 *
3483 * @example
3484 * ```typescript
3485 * const list = ['foo', 'bar', 'baz', 'quux'];
3486 * R.nth(1, list); //=> 'bar'
3487 * R.nth(-1, list); //=> 'quux'
3488 * R.nth(-99, list); //=> undefined
3489 *
3490 * R.nth(2, 'abc'); //=> 'c'
3491 * R.nth(3, 'abc'); //=> ''
3492 * ```
3493 */
3494export function nth<T>(n: number, list: readonly T[]): T | undefined;
3495export function nth(n: number, list: string): string;
3496export function nth(
3497 n: number,
3498): <T extends readonly any[] | string>(list: T) => (T extends Array<infer E> ? E : string) | undefined;
3499
3500/**
3501 * Returns a function which returns its nth argument.
3502 *
3503 * @example
3504 * ```typescript
3505 * R.nthArg(1)('a', 'b', 'c'); //=> 'b'
3506 * R.nthArg(-1)('a', 'b', 'c'); //=> 'c'
3507 * ```
3508 */
3509export function nthArg(n: number): (...args: unknown[]) => unknown;
3510
3511/**
3512 * `o` is a curried composition function that returns a unary function.
3513 * Like `compose`, `o` performs right-to-left function composition.
3514 * Unlike `compose`, the rightmost function passed to `o` will be invoked with only one argument.
3515 * Also, unlike compose, `o` is limited to accepting only 2 unary functions.
3516 * The name `o` was chosen because of its similarity to the mathematical composition operator `∘`.
3517 *
3518 * See also {@link compose}, {@link pipe}.
3519 *
3520 * @example
3521 * ```typescript
3522 * type Name = { first: string; last: string; };
3523 *
3524 * const classyGreeting = (name: Name) => "The name's " + name.last + ", " + name.first + " " + name.last
3525 * const yellGreeting = R.o(R.toUpper, classyGreeting);
3526 * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND"
3527 *
3528 * R.o(R.multiply(10), R.add(10))(-4) //=> 60
3529 * ```
3530 */
3531export function o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2, v: T1): R;
3532export function o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2): (v: T1) => R;
3533export function o<T2, R>(
3534 f: (x: T2) => R,
3535): {
3536 <T1>(g: (x: T1) => T2, v: T1): R;
3537 <T1>(g: (x: T1) => T2): (v: T1) => R;
3538};
3539
3540/**
3541 * Creates an object containing a single key:value pair.
3542 *
3543 * See also {@link pair}.
3544 *
3545 * @example
3546 * ```typescript
3547 * const matchPhrases = R.compose(
3548 * R.objOf('must'),
3549 * R.map(R.objOf('match_phrase'))
3550 * );
3551 * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]}
3552 * ```
3553 */
3554export function objOf<T, K extends string>(key: K, value: T): Record<K, T>;
3555export function objOf<K extends string>(key: K): <T>(value: T) => Record<K, T>;
3556
3557/**
3558 * Returns a singleton array containing the value provided.
3559 *
3560 * @note This `of` is different from the ES6 `Array.of`.
3561 *
3562 * @example
3563 * ```typescript
3564 * R.of(null); //=> [null]
3565 * R.of([42]); //=> [[42]]
3566 * ```
3567 */
3568export function of<T>(x: T): T[];
3569
3570/**
3571 * Returns a partial copy of an object omitting the keys specified.
3572 *
3573 * See also {@link pick}.
3574 *
3575 * @example
3576 * ```typescript
3577 * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3}
3578 * ```
3579 */
3580export function omit<T, K extends string>(names: readonly K[], obj: T): Omit<T, K>;
3581export function omit<K extends string>(names: readonly K[]): <T>(obj: T) => Omit<T, K>;
3582
3583/**
3584 * Takes a binary function `f`, a unary function `g`, and two values.
3585 * Applies `g` to each value, then applies the result of each to `f`.
3586 * Also known as the P combinator.
3587 *
3588 * @example
3589 * ```typescript
3590 * const eqBy = R.on((a, b) => a === b);
3591 * eqBy(R.prop('a'), {b:0, a:1}, {a:1}) //=> true;
3592 *
3593 * const containsInsensitive = R.on(R.contains, R.toLower);
3594 * containsInsensitive('o', 'FOO'); //=> true
3595 * ```
3596 */
3597export function on<T, U, R>(combine: (a: U, b: U) => R, transform: (value: T) => U, a: T, b: T): R;
3598export function on<T, U, R>(combine: (a: U, b: U) => R, transform: (value: T) => U, a: T): (b: T) => R;
3599export function on<T, U, R>(
3600 combine: (a: U, b: U) => R,
3601 transform: (value: T) => U,
3602): {
3603 (a: T, b: T): R;
3604 (a: T): (b: T) => R;
3605};
3606export function on<U, R>(
3607 combine: (a: U, b: U) => R,
3608): {
3609 <T>(transform: (value: T) => U, a: T, b: T): R;
3610 <T>(transform: (value: T) => U, a: T): (b: T) => R;
3611 <T>(transform: (value: T) => U): {
3612 (a: T, b: T): R;
3613 (a: T): (b: T) => R;
3614 };
3615};
3616// For manually specifying overloads
3617export function on<T, U, R>(
3618 combine: (a: U, b: U) => R,
3619): {
3620 (transform: (value: T) => U, a: T, b: T): R;
3621 (transform: (value: T) => U, a: T): (b: T) => R;
3622 (transform: (value: T) => U): {
3623 (a: T, b: T): R;
3624 (a: T): (b: T) => R;
3625 };
3626};
3627
3628/**
3629 * Accepts a function `fn` and returns a function that guards invocation of `fn`
3630 * such that `fn` can only ever be called once,
3631 * no matter how many times the returned function is invoked.
3632 * The first value calculated is returned in subsequent invocations.
3633 *
3634 * @example
3635 * ```typescript
3636 * const addOneOnce = R.once((x: number) => x + 1);
3637 * addOneOnce(10); //=> 11
3638 * addOneOnce(addOneOnce(50)); //=> 11
3639 * ```
3640 */
3641export function once<F extends AnyFunction>(fn: F): F;
3642
3643/**
3644 * Returns the first argument if it is truthy, otherwise the second argument.
3645 *
3646 * Acts as boolean `or` if both inputs are booleans.
3647 *
3648 * @note This is **not** short-circuited, meaning that if expressions are passed they are both evaluated.
3649 *
3650 * See also {@link either}, {@link and}, {@link xor}.
3651 *
3652 * @example
3653 * ```typescript
3654 * R.or(true, true); //=> true
3655 * R.or(true, false); //=> true
3656 * R.or(false, true); //=> true
3657 * R.or(false, false); //=> false
3658 * ```
3659 */
3660export function or<T, U>(a: T | Falsy, b: U): T | U;
3661export function or<T>(a: T | Falsy): <U>(b: U) => T | U;
3662
3663/**
3664 * Returns the result of applying the `onFailure` function to the value inside a failed `Promise`.
3665 * This is useful for handling rejected `Promise`s inside function compositions.
3666 *
3667 * @example
3668 * ```typescript
3669 * const failedFetch = (id: number) => Promise.reject('bad ID');
3670 * const useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' });
3671 *
3672 * //recoverFromFailure :: String -> Promise ({ firstName, lastName })
3673 * const recoverFromFailure = R.pipe(
3674 * failedFetch,
3675 * R.otherwise(useDefault),
3676 * R.andThen(R.pick(['firstName', 'lastName'])),
3677 * );
3678 * recoverFromFailure(12345).then(console.log);
3679 * ```
3680 */
3681export function otherwise<A, B>(onError: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<B>;
3682export function otherwise<A, B>(onError: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<B>;
3683
3684/**
3685 * Returns the result of "setting" the portion of the given data structure
3686 * focused by the given lens to the given value.
3687 *
3688 * See also {@link view}, {@link set}, {@link lens}, {@link lensIndex}, {@link lensProp}, {@link lensPath}.
3689 *
3690 * @example
3691 * ```typescript
3692 * const headLens = R.lensIndex<string>(0);
3693 *
3694 * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz']
3695 * ```
3696 */
3697export function over<S, A>(lens: Lens<S, A>, fn: (a: A) => A, value: S): S;
3698export function over<S, A>(lens: Lens<S, A>, fn: (a: A) => A): (value: S) => S;
3699export function over<S, A>(lens: Lens<S, A>): (fn: (a: A) => A, value: S) => S;
3700
3701/**
3702 * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`.
3703 *
3704 * See also {@link objOf}, {@link of}.
3705 *
3706 * @example
3707 * ```typescript
3708 * R.pair('foo', 'bar'); //=> ['foo', 'bar']
3709 * ```
3710 */
3711export function pair<F, S>(fst: F, snd: S): [F, S];
3712export function pair<F>(fst: F): <S>(snd: S) => [F, S];
3713
3714/**
3715 * Takes a function `f` and a list of arguments, and returns a function `g`.
3716 * When applied, `g` returns the result of applying `f` to the arguments provided initially
3717 * followed by the arguments provided to `g`.
3718 *
3719 * See also {@link partialRight}, {@link curry}.
3720 *
3721 * @example
3722 * ```typescript
3723 * const multiply2 = (a: number, b: number) => a * b;
3724 * const double = R.partial(multiply2, [2]);
3725 * double(3); //=> 6
3726 *
3727 * const greet = (salutation: string, title: string, firstName: string, lastName: string) =>
3728 * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
3729 *
3730 * const sayHello = R.partial(greet, ['Hello']);
3731 * const sayHelloToMs = R.partial(sayHello, ['Ms.']);
3732 * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'
3733 * ```
3734 */
3735export function partial<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T;
3736export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0, V1]): (x2: V2) => T;
3737export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0]): (x1: V1, x2: V2) => T;
3738export function partial<V0, V1, V2, V3, T>(
3739 fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,
3740 args: [V0, V1, V2],
3741): (x2: V3) => T;
3742export function partial<V0, V1, V2, V3, T>(
3743 fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,
3744 args: [V0, V1],
3745): (x2: V2, x3: V3) => T;
3746export function partial<V0, V1, V2, V3, T>(
3747 fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,
3748 args: [V0],
3749): (x1: V1, x2: V2, x3: V3) => T;
3750
3751export function partial<T>(fn: (...args: any[]) => T, args: unknown[]): (...args: unknown[]) => T;
3752
3753/**
3754 * Takes a function `f` and an object, and returns a function `g`.
3755 * When applied, `g` returns the result of applying `f` to the object
3756 * provided initially merged deeply (right) with the object provided as an argument to `g`.
3757 *
3758 * See also {@link partial}, {@link partialRight}, {@link curry}, {@link mergeDeepRight}.
3759 *
3760 * @example
3761 * ```typescript
3762 * const multiply2 = ({ a, b }: { a: number, b: number }) => a * b;
3763 * const double = R.partialObject(multiply2, { a: 2 });
3764 * double({ b: 2 }); //=> 4
3765 *
3766 * type GreetArgs = {
3767 * salutation: string;
3768 * title: string;
3769 * firstName: string;
3770 * lastName: string;
3771 * };
3772 *
3773 * const greet = ({ salutation, title, firstName, lastName }: GreetArgs) =>
3774 * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
3775 *
3776 * const sayHello = R.partialObject(greet, { salutation: 'Hello' });
3777 * const sayHelloToMs = R.partialObject(sayHello, { title: 'Ms.' });
3778 * sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!'
3779 * ```
3780 */
3781// NOTE: The objects are merged deeply - meaning this should be `DeepOmit` (ideally `& Partial<Omitted>` too)
3782export function partialObject<T extends P1, P1, R>(fn: (value: T) => R, partial: P1): (value: Omit<T, keyof P1>) => R;
3783export function partialObject<T, R>(fn: (value: T) => R): <P1>(partial: P1) => (value: Omit<T, keyof P1>) => R;
3784
3785/**
3786 * Takes a function `f` and a list of arguments, and returns a function `g`.
3787 * When applied, `g` returns the result of applying `f` to the arguments
3788 * provided to `g` followed by the arguments provided initially.
3789 *
3790 * See also {@link partial}.
3791 *
3792 * @example
3793 * ```typescript
3794 * const greet = (salutation: string, title: string, firstName: string, lastName: string) =>
3795 * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
3796 *
3797 * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);
3798 *
3799 * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'
3800 * ```
3801 */
3802export function partialRight<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V1]): (x1: V0) => T;
3803export function partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V1, V2]): (x2: V0) => T;
3804export function partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V2]): (x1: V0, x2: V1) => T;
3805export function partialRight<V0, V1, V2, V3, T>(
3806 fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,
3807 args: [V1, V2, V3],
3808): (x0: V0) => T;
3809export function partialRight<V0, V1, V2, V3, T>(
3810 fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,
3811 args: [V2, V3],
3812): (x0: V0, x1: V1) => T;
3813export function partialRight<V0, V1, V2, V3, T>(
3814 fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T,
3815 args: [V3],
3816): (x0: V0, x1: V1, x2: V2) => T;
3817
3818export function partialRight<T>(fn: (...args: any[]) => T, args: unknown[]): (...args: unknown[]) => T;
3819
3820/**
3821 * Takes a predicate and a list or other `Filterable` object
3822 * and returns the elements split into two lists
3823 * based on whether the element satisfied the predicate.
3824 * Filterable objects include plain objects
3825 * and objects with a `filter` method such as `Array`.
3826 *
3827 * See also {@link filter}, {@link reject}.
3828 *
3829 * @example
3830 * ```typescript
3831 * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']);
3832 * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]
3833 *
3834 * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' });
3835 * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ]
3836 * ```
3837 */
3838export function partition(fn: (a: string) => boolean, list: readonly string[]): [string[], string[]];
3839export function partition<T>(fn: (a: T) => boolean, list: readonly T[]): [T[], T[]];
3840export function partition<T>(fn: (a: T) => boolean): (list: readonly T[]) => [T[], T[]];
3841export function partition(fn: (a: string) => boolean): (list: readonly string[]) => [string[], string[]];
3842
3843/**
3844 * Retrieve the value at a given path.
3845 *
3846 * See also {@link prop}, {@link nth}.
3847 *
3848 * @example
3849 * ```typescript
3850 * R.path(['a', 'b'], {a: {b: 2}}); //=> 2
3851 * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined
3852 * R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1
3853 * R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2
3854 * ```
3855 */
3856export function path<S, K0 extends keyof S = keyof S>(path: [K0], obj: S): S[K0];
3857export function path<S, K0 extends keyof S = keyof S, K1 extends keyof S[K0] = keyof S[K0]>(path: [K0, K1], obj: S): S[K0][K1];
3858export function path<
3859 S,
3860 K0 extends keyof S = keyof S,
3861 K1 extends keyof S[K0] = keyof S[K0],
3862 K2 extends keyof S[K0][K1] = keyof S[K0][K1]
3863>(path: [K0, K1, K2], obj: S): S[K0][K1][K2];
3864export function path<
3865 S,
3866 K0 extends keyof S = keyof S,
3867 K1 extends keyof S[K0] = keyof S[K0],
3868 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
3869 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
3870>(path: [K0, K1, K2, K3], obj: S): S[K0][K1][K2][K3];
3871export function path<
3872 S,
3873 K0 extends keyof S = keyof S,
3874 K1 extends keyof S[K0] = keyof S[K0],
3875 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
3876 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
3877 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
3878>(path: [K0, K1, K2, K3, K4], obj: S): S[K0][K1][K2][K3][K4];
3879export function path<
3880 S,
3881 K0 extends keyof S = keyof S,
3882 K1 extends keyof S[K0] = keyof S[K0],
3883 K2 extends keyof S[K0][K1] = keyof S[K0][K1],
3884 K3 extends keyof S[K0][K1][K2] = keyof S[K0][K1][K2],
3885 K4 extends keyof S[K0][K1][K2][K3] = keyof S[K0][K1][K2][K3],
3886 K5 extends keyof S[K0][K1][K2][K3][K4] = keyof S[K0][K1][K2][K3][K4],
3887>(path: [K0, K1, K2, K3, K4, K5], obj: S): S[K0][K1][K2][K3][K4][K5];
3888export function path<T>(path: Path, obj: any): T | undefined;
3889export function path<T>(path: Path): (obj: any) => T | undefined;
3890
3891/**
3892 * Determines whether a nested path on an object has a specific value,
3893 * in {@link equals `R.equals`} terms.
3894 * Most likely used to filter a list.
3895 *
3896 * @example
3897 * ```typescript
3898 * const user1 = { address: { zipCode: 90210 } };
3899 * const user2 = { address: { zipCode: 55555 } };
3900 * const user3 = { name: 'Bob' };
3901 * const users = [ user1, user2, user3 ];
3902 * const isFamous = R.pathEq(['address', 'zipCode'], 90210);
3903 * R.filter(isFamous, users); //=> [ user1 ]
3904 * ```
3905 */
3906export function pathEq(path: Path, val: any, obj: any): boolean;
3907export function pathEq(path: Path, val: any): (obj: any) => boolean;
3908export function pathEq(path: Path): _.F.Curry<(a: any, b: any) => boolean>;
3909
3910/**
3911 * If the given, non-null object has a value at the given path,
3912 * returns the value at that path.
3913 * Otherwise returns the provided default value.
3914 *
3915 * @example
3916 * ```typescript
3917 * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2
3918 * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"
3919 * ```
3920 */
3921export function pathOr<T>(defaultValue: T, path: Path, obj: any): T;
3922export function pathOr<T>(defaultValue: T, path: Path): (obj: any) => T;
3923export function pathOr<T>(defaultValue: T): _.F.Curry<(a: Path, b: any) => T>;
3924
3925/**
3926 * Retrieves the values at given paths of an object.
3927 *
3928 * See also {@link path}.
3929 *
3930 * @example
3931 * ```typescript
3932 * R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3]
3933 * R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined]
3934 * ```
3935 */
3936export function paths<T>(paths: readonly Path[], obj: any): Array<T | undefined>;
3937export function paths<T>(paths: readonly Path[]): (obj: any) => Array<T | undefined>;
3938
3939/**
3940 * Returns `true` if the specified object property at given path satisfies the given predicate;
3941 * `false` otherwise.
3942 *
3943 * See also {@link propSatisfies}, {@link path}.
3944 *
3945 * @example
3946 * ```typescript
3947 * R.pathSatisfies((y: number) => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true
3948 * R.pathSatisfies(R.is(Object), [], {x: {y: 2}}); //=> true
3949 * ```
3950 */
3951export function pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path, obj: U): boolean;
3952export function pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path): (obj: U) => boolean;
3953export function pathSatisfies<T, U>(pred: (val: T) => boolean): _.F.Curry<(a: Path, b: U) => boolean>;
3954
3955/**
3956 * Returns a partial copy of an object containing only the keys specified.
3957 * If the key does not exist, the property is ignored.
3958 *
3959 * See also {@link omit}, {@link props}.
3960 *
3961 * @example
3962 * ```typescript
3963 * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
3964 * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1}
3965 * ```
3966 */
3967export function pick<T, K extends string | number | symbol>(
3968 names: readonly K[],
3969 obj: T,
3970): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
3971export function pick<K extends string | number | symbol>(
3972 names: readonly K[],
3973): <T>(obj: T) => Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
3974
3975/**
3976 * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist.
3977 *
3978 * @example
3979 * ```typescript
3980 * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
3981 * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined}
3982 * ```
3983 */
3984export function pickAll<T, K extends keyof T>(names: readonly K[], obj: T): Pick<T, K>;
3985export function pickAll<T, U>(names: readonly string[], obj: T): U;
3986export function pickAll(names: readonly string[]): <T, U>(obj: T) => U;
3987
3988/**
3989 * Returns a partial copy of an object containing only the keys that satisfy the supplied predicate.
3990 *
3991 * @example
3992 * ```typescript
3993 * const isUpperCase = <T>(_val: T, key: string) => key.toUpperCase() === key;
3994 * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
3995 * ```
3996 */
3997export function pickBy<T, U>(pred: ObjPred<T>, obj: T): U;
3998export function pickBy<T>(pred: ObjPred<T>): <U, V extends T>(obj: V) => U;
3999
4000/**
4001 * Creates a new function that runs each of the functions supplied as parameters in turn,
4002 * passing the return value of each function invocation to the next function invocation,
4003 * beginning with whatever arguments were passed to the initial invocation.
4004 *
4005 * Performs left-to-right function composition.
4006 * The first argument may have any arity; the remaining arguments must be unary.
4007 *
4008 * In some libraries this function is named `sequence`.
4009 *
4010 * @note The result of `pipe` is not automatically curried.
4011 *
4012 * See also {@link compose}.
4013 *
4014 * @example
4015 * ```typescript
4016 * const f = R.pipe(Math.pow, R.negate, R.inc);
4017 *
4018 * f(3, 4); // -(3^4) + 1
4019 * ```
4020 */
4021export function pipe<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7, TResult>(
4022 ...funcs: [
4023 f1: (...args: TArgs) => R1,
4024 f2: (a: R1) => R2,
4025 f3: (a: R2) => R3,
4026 f4: (a: R3) => R4,
4027 f5: (a: R4) => R5,
4028 f6: (a: R5) => R6,
4029 f7: (a: R6) => R7,
4030 ...func: Array<(a: any) => any>,
4031 fnLast: (a: any) => TResult,
4032 ]
4033): (...args: TArgs) => TResult; // fallback overload if number of piped functions greater than 7
4034export function pipe<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7>(
4035 f1: (...args: TArgs) => R1,
4036 f2: (a: R1) => R2,
4037 f3: (a: R2) => R3,
4038 f4: (a: R3) => R4,
4039 f5: (a: R4) => R5,
4040 f6: (a: R5) => R6,
4041 f7: (a: R6) => R7,
4042): (...args: TArgs) => R7;
4043export function pipe<TArgs extends any[], R1, R2, R3, R4, R5, R6>(
4044 f1: (...args: TArgs) => R1,
4045 f2: (a: R1) => R2,
4046 f3: (a: R2) => R3,
4047 f4: (a: R3) => R4,
4048 f5: (a: R4) => R5,
4049 f6: (a: R5) => R6,
4050): (...args: TArgs) => R6;
4051export function pipe<TArgs extends any[], R1, R2, R3, R4, R5>(
4052 f1: (...args: TArgs) => R1,
4053 f2: (a: R1) => R2,
4054 f3: (a: R2) => R3,
4055 f4: (a: R3) => R4,
4056 f5: (a: R4) => R5,
4057): (...args: TArgs) => R5;
4058export function pipe<TArgs extends any[], R1, R2, R3, R4>(
4059 f1: (...args: TArgs) => R1,
4060 f2: (a: R1) => R2,
4061 f3: (a: R2) => R3,
4062 f4: (a: R3) => R4,
4063): (...args: TArgs) => R4;
4064export function pipe<TArgs extends any[], R1, R2, R3>(
4065 f1: (...args: TArgs) => R1,
4066 f2: (a: R1) => R2,
4067 f3: (a: R2) => R3,
4068): (...args: TArgs) => R3;
4069export function pipe<TArgs extends any[], R1, R2>(
4070 f1: (...args: TArgs) => R1,
4071 f2: (a: R1) => R2,
4072): (...args: TArgs) => R2;
4073export function pipe<TArgs extends any[], R1>(f1: (...args: TArgs) => R1): (...args: TArgs) => R1;
4074
4075/**
4076 * Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain.
4077 * The typings currently support arrays only as return values.
4078 * All functions need to be unary.
4079 * R.pipeK(f, g, h) is equivalent to R.pipe(f, R.chain(g), R.chain(h)).
4080 *
4081 * @deprecated since 0.26 in favor of pipeWith(chain)
4082 */
4083export function pipeK<V0, T1>(fn0: (x0: V0) => T1[]): (x0: V0) => T1[];
4084export function pipeK<V0, T1, T2>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[]): (x0: V0) => T2[];
4085export function pipeK<V0, T1, T2, T3>(
4086 fn0: (x: V0) => T1[],
4087 fn1: (x: T1) => T2[],
4088 fn2: (x: T2) => T3[],
4089): (x: V0) => T3[];
4090export function pipeK<V0, T1, T2, T3, T4>(
4091 fn0: (x: V0) => T1[],
4092 fn1: (x: T1) => T2[],
4093 fn2: (x: T2) => T3[],
4094 fn3: (x: T3) => T4[],
4095): (x: V0) => T4[];
4096export function pipeK<V0, T1, T2, T3, T4, T5>(
4097 fn0: (x: V0) => T1[],
4098 fn1: (x: T1) => T2[],
4099 fn2: (x: T2) => T3[],
4100 fn3: (x: T3) => T4[],
4101 fn4: (x: T4) => T5[],
4102): (x: V0) => T5[];
4103export function pipeK<V0, T1, T2, T3, T4, T5, T6>(
4104 fn0: (x: V0) => T1[],
4105 fn1: (x: T1) => T2[],
4106 fn2: (x: T2) => T3[],
4107 fn3: (x: T3) => T4[],
4108 fn4: (x: T4) => T5[],
4109 fn5: (x: T5) => T6[],
4110): (x: V0) => T6[];
4111export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7>(
4112 fn0: (x: V0) => T1[],
4113 fn1: (x: T1) => T2[],
4114 fn2: (x: T2) => T3[],
4115 fn3: (x: T3) => T4[],
4116 fn4: (x: T4) => T5[],
4117 fn5: (x: T5) => T6[],
4118 fn: (x: T6) => T7[],
4119): (x: V0) => T7[];
4120export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8>(
4121 fn0: (x: V0) => T1[],
4122 fn1: (x: T1) => T2[],
4123 fn2: (x: T2) => T3[],
4124 fn3: (x: T3) => T4[],
4125 fn4: (x: T4) => T5[],
4126 fn5: (x: T5) => T6[],
4127 fn6: (x: T6) => T7[],
4128 fn: (x: T7) => T8[],
4129): (x: V0) => T8[];
4130export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
4131 fn0: (x0: V0) => T1[],
4132 fn1: (x: T1) => T2[],
4133 fn2: (x: T2) => T3[],
4134 fn3: (x: T3) => T4[],
4135 fn4: (x: T4) => T5[],
4136 fn5: (x: T5) => T6[],
4137 fn6: (x: T6) => T7[],
4138 fn7: (x: T7) => T8[],
4139 fn8: (x: T8) => T9[],
4140): (x0: V0) => T9[];
4141export function pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
4142 fn0: (x0: V0) => T1[],
4143 fn1: (x: T1) => T2[],
4144 fn2: (x: T2) => T3[],
4145 fn3: (x: T3) => T4[],
4146 fn4: (x: T4) => T5[],
4147 fn5: (x: T5) => T6[],
4148 fn6: (x: T6) => T7[],
4149 fn7: (x: T7) => T8[],
4150 fn8: (x: T8) => T9[],
4151 fn9: (x: T9) => T10[],
4152): (x0: V0) => T10[];
4153
4154/**
4155 * Performs left-to-right composition of one or more Promise-returning functions.
4156 * All functions need to be unary.
4157 *
4158 * @deprecated since 0.26 in favor of pipeWith(then)
4159 */
4160export function pipeP<V0, T1>(fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T1>;
4161export function pipeP<V0, T1, T2>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>): (x0: V0) => Promise<T2>;
4162export function pipeP<V0, T1, T2, T3>(
4163 fn0: (x: V0) => Promise<T1>,
4164 fn1: (x: T1) => Promise<T2>,
4165 fn2: (x: T2) => Promise<T3>,
4166): (x: V0) => Promise<T3>;
4167export function pipeP<V0, T1, T2, T3, T4>(
4168 fn0: (x: V0) => Promise<T1>,
4169 fn1: (x: T1) => Promise<T2>,
4170 fn2: (x: T2) => Promise<T3>,
4171 fn3: (x: T3) => Promise<T4>,
4172): (x: V0) => Promise<T4>;
4173export function pipeP<V0, T1, T2, T3, T4, T5>(
4174 fn0: (x: V0) => Promise<T1>,
4175 fn1: (x: T1) => Promise<T2>,
4176 fn2: (x: T2) => Promise<T3>,
4177 fn3: (x: T3) => Promise<T4>,
4178 fn4: (x: T4) => Promise<T5>,
4179): (x: V0) => Promise<T5>;
4180export function pipeP<V0, T1, T2, T3, T4, T5, T6>(
4181 fn0: (x: V0) => Promise<T1>,
4182 fn1: (x: T1) => Promise<T2>,
4183 fn2: (x: T2) => Promise<T3>,
4184 fn3: (x: T3) => Promise<T4>,
4185 fn4: (x: T4) => Promise<T5>,
4186 fn5: (x: T5) => Promise<T6>,
4187): (x: V0) => Promise<T6>;
4188export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7>(
4189 fn0: (x: V0) => Promise<T1>,
4190 fn1: (x: T1) => Promise<T2>,
4191 fn2: (x: T2) => Promise<T3>,
4192 fn3: (x: T3) => Promise<T4>,
4193 fn4: (x: T4) => Promise<T5>,
4194 fn5: (x: T5) => Promise<T6>,
4195 fn: (x: T6) => Promise<T7>,
4196): (x: V0) => Promise<T7>;
4197export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8>(
4198 fn0: (x: V0) => Promise<T1>,
4199 fn1: (x: T1) => Promise<T2>,
4200 fn2: (x: T2) => Promise<T3>,
4201 fn3: (x: T3) => Promise<T4>,
4202 fn4: (x: T4) => Promise<T5>,
4203 fn5: (x: T5) => Promise<T6>,
4204 fn6: (x: T6) => Promise<T7>,
4205 fn: (x: T7) => Promise<T8>,
4206): (x: V0) => Promise<T8>;
4207export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
4208 fn0: (x0: V0) => Promise<T1>,
4209 fn1: (x: T1) => Promise<T2>,
4210 fn2: (x: T2) => Promise<T3>,
4211 fn3: (x: T3) => Promise<T4>,
4212 fn4: (x: T4) => Promise<T5>,
4213 fn5: (x: T5) => Promise<T6>,
4214 fn6: (x: T6) => Promise<T7>,
4215 fn7: (x: T7) => Promise<T8>,
4216 fn8: (x: T8) => Promise<T9>,
4217): (x0: V0) => Promise<T9>;
4218export function pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
4219 fn0: (x0: V0) => Promise<T1>,
4220 fn1: (x: T1) => Promise<T2>,
4221 fn2: (x: T2) => Promise<T3>,
4222 fn3: (x: T3) => Promise<T4>,
4223 fn4: (x: T4) => Promise<T5>,
4224 fn5: (x: T5) => Promise<T6>,
4225 fn6: (x: T6) => Promise<T7>,
4226 fn7: (x: T7) => Promise<T8>,
4227 fn8: (x: T8) => Promise<T9>,
4228 fn9: (x: T9) => Promise<T10>,
4229): (x0: V0) => Promise<T10>;
4230
4231/**
4232 * Performs left-to-right function composition using transforming function.
4233 * The first function may have any arity; the remaining functions must be unary.
4234 *
4235 * @note The result of `pipeWith` is not automatically curried. Transforming function is not used on the first argument.
4236 *
4237 * See also {@link composeWith}, {@link pipe}.
4238 *
4239 * @example
4240 * ```typescript
4241 * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res));
4242 * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc])
4243 *
4244 * f(3, 4); // -(3^4) + 1
4245 * ```
4246 */
4247export function pipeWith<TArgs extends any[], TResult>(
4248 transformer: (fn: AnyFunction, intermediateResult: any) => any,
4249 fns: AtLeastOneFunctionsFlow<TArgs, TResult>,
4250): (...args: TArgs) => TResult;
4251export function pipeWith(
4252 transformer: (fn: AnyFunction, intermediateResult: any) => any,
4253): <TArgs extends any[], TResult>(fns: AtLeastOneFunctionsFlow<TArgs, TResult>) => (...args: TArgs) => TResult;
4254
4255/**
4256 * Returns a new list by plucking the same named property off all objects in the list supplied.
4257 *
4258 * `pluck` will work on any functor in addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`.
4259 *
4260 * See also {@link project}, {@link prop}, {@link props}.
4261 *
4262 * @example
4263 * ```typescript
4264 * var getAges = R.pluck('age');
4265 * const people = [{name: 'fred', age: 29}, {name: 'wilma', age: 27}]
4266 * getAges(people); //=> [29, 27]
4267 *
4268 * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3]
4269 * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5}
4270 * ```
4271 */
4272export function pluck<K extends keyof T, T>(p: K, list: readonly T[]): Array<T[K]>;
4273export function pluck<T>(p: number, list: ReadonlyArray<{ [k: number]: T }>): T[];
4274export function pluck<P extends string>(p: P): <T>(list: ReadonlyArray<Record<P, T>>) => T[];
4275export function pluck(p: number): <T>(list: ReadonlyArray<{ [k: number]: T }>) => T[];
4276
4277/**
4278 * Returns a new list with the given element at the front,
4279 * followed by the contents of the list.
4280 *
4281 * See also {@link append}.
4282 *
4283 * @example
4284 * ```typescript
4285 * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum']
4286 * ```
4287 */
4288export function prepend<T>(el: T, list: readonly T[]): T[];
4289export function prepend<T>(el: T): (list: readonly T[]) => T[];
4290
4291/**
4292 * Multiplies together all the elements of a list.
4293 *
4294 * See also {@link reduce}.
4295 *
4296 * @example
4297 * ```typescript
4298 * R.product([2,4,6,8,100,1]); //=> 38400
4299 * ```
4300 */
4301export function product(list: readonly number[]): number;
4302
4303/**
4304 * Reasonable analog to SQL `select` statement.
4305 *
4306 * See also {@link pluck}, {@link props}, {@link prop}.
4307 *
4308 * @example
4309 * ```typescript
4310 * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2};
4311 * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7};
4312 * const kids = [abby, fred];
4313 * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]
4314 * ```
4315 */
4316export function project<T, U>(props: readonly string[], objs: readonly T[]): U[];
4317export function project<T, U>(props: readonly string[]): (objs: readonly T[]) => U[];
4318
4319/**
4320 * Takes two functions as pre- and post- processors respectively for a third function,
4321 * i.e. `promap(f, g, h)(x) === g(h(f(x)))`.
4322 * Dispatches to the `promap` method of the third argument, if present,
4323 * according to the FantasyLand Profunctor spec.
4324 * Acts as a transducer if a transformer is given in profunctor position.
4325 *
4326 * See also {@link transduce}.
4327 *
4328 * @example
4329 * ```typescript
4330 * const decodeChar = R.promap((s: string) => s.charCodeAt(0), String.fromCharCode, R.add(-8))
4331 * const decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar))
4332 * decodeString("ziuli") //=> "ramda"
4333 * ```
4334 */
4335export function promap<A, B, C, D>(pre: (value: A) => B, post: (value: C) => D, fn: (value: B) => C): (value: A) => D;
4336export function promap<A, B, C, D>(
4337 pre: (value: A) => B,
4338 post: (value: C) => D,
4339): (fn: (value: B) => C) => (value: A) => D;
4340export function promap<A, B>(
4341 pre: (value: A) => B,
4342): <C, D>(post: (value: C) => D, fn: (value: B) => C) => (value: A) => D;
4343
4344/**
4345 * Returns a function that when supplied an object
4346 * returns the indicated property of that object, if it exists.
4347 *
4348 * See also {@link propOr}, {@link path}, {@link props}, {@link pluck}, {@link project}, {@link nth}.
4349 *
4350 * @example
4351 * ```typescript
4352 * R.prop('x', {x: 100}); //=> 100
4353 * R.prop(0, [100]); //=> 100
4354 * R.compose(R.inc, R.prop<number>('x'))({ x: 3 }) //=> 4
4355 * ```
4356 */
4357export function prop<_, T>(__: Placeholder, value: T): {
4358 <P extends keyof Exclude<T, undefined>>(p: P): Prop<T, P>;
4359 <P extends keyof never>(p: P): Prop<T, P>;
4360};
4361export function prop<V>(__: Placeholder, value: unknown): (p: keyof never) => V;
4362export function prop<_, P extends keyof never, T>(p: P, value: T): Prop<T, P>;
4363export function prop<V>(p: keyof never, value: unknown): V;
4364export function prop<_, P extends keyof never>(p: P): <T>(value: T) => Prop<T, P>;
4365export function prop<V>(p: keyof never): (value: unknown) => V;
4366
4367// NOTE: `hair` property was added to `alois` to make example work.
4368// A union of two types is a valid usecase but doesn't work with current types
4369/**
4370 * Returns `true` if the specified object property is equal,
4371 * in `R.equals` terms, to the given value; `false` otherwise.
4372 * You can test multiple properties with `R.whereEq`.
4373 *
4374 * See also {@link whereEq}, {@link propSatisfies}, {@link equals}.
4375 *
4376 * @example
4377 * ```typescript
4378 * const abby = {name: 'Abby', age: 7, hair: 'blond'};
4379 * const fred = {name: 'Fred', age: 12, hair: 'brown'};
4380 * const rusty = {name: 'Rusty', age: 10, hair: 'brown'};
4381 * const alois = {name: 'Alois', age: 15, hair: 'brown', disposition: 'surly'};
4382 * const kids = [abby, fred, rusty, alois];
4383 * const hasBrownHair = R.propEq('hair', 'brown');
4384 * R.filter(hasBrownHair, kids); //=> [fred, rusty]
4385 * ```
4386 */
4387export function propEq<K extends string | number>(name: K, val: any, obj: Record<K, any>): boolean;
4388export function propEq<K extends string | number>(name: K, val: any): (obj: Record<K, any>) => boolean;
4389export function propEq<K extends string | number>(
4390 name: K,
4391): {
4392 (val: any, obj: Record<K, any>): boolean;
4393 (val: any): (obj: Record<K, any>) => boolean;
4394};
4395
4396/**
4397 * Returns `true` if the specified object property is of the given type; `false` otherwise.
4398 *
4399 * See also {@link is}, {@link propSatisfies}.
4400 *
4401 * @example
4402 * ```typescript
4403 * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true
4404 * R.propIs(Number, 'x', {x: 'foo'}); //=> false
4405 * R.propIs(Number, 'x', {}); //=> false
4406 * ```
4407 */
4408export function propIs<C extends AnyFunction, K extends PropertyKey>(
4409 type: C,
4410 name: K,
4411 obj: any,
4412): obj is Record<K, ReturnType<C>>;
4413export function propIs<C extends AnyConstructor, K extends PropertyKey>(
4414 type: C,
4415 name: K,
4416 obj: any,
4417): obj is Record<K, InstanceType<C>>;
4418export function propIs<C extends AnyFunction, K extends PropertyKey>(
4419 type: C,
4420 name: K,
4421): (obj: any) => obj is Record<K, ReturnType<C>>;
4422export function propIs<C extends AnyConstructor, K extends PropertyKey>(
4423 type: C,
4424 name: K,
4425): (obj: any) => obj is Record<K, InstanceType<C>>;
4426export function propIs<C extends AnyFunction>(
4427 type: C,
4428): {
4429 <K extends keyof any>(name: K, obj: any): obj is Record<K, ReturnType<C>>;
4430 <K extends keyof any>(name: K): (obj: any) => obj is Record<K, ReturnType<C>>;
4431};
4432export function propIs<C extends AnyConstructor>(
4433 type: C,
4434): {
4435 <K extends keyof any>(name: K, obj: any): obj is Record<K, InstanceType<C>>;
4436 <K extends keyof any>(name: K): (obj: any) => obj is Record<K, InstanceType<C>>;
4437};
4438
4439/**
4440 * Return the specified property of the given non-null object
4441 * if the property is present and its value is not `null`, `undefined` or `NaN`.
4442 *
4443 * Otherwise the first argument is returned.
4444 *
4445 * See also {@link prop}.
4446 *
4447 * @example
4448 * ```typescript
4449 * const alice = {
4450 * name: 'ALICE',
4451 * age: 101
4452 * };
4453 * const favorite = R.prop('favoriteLibrary');
4454 * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
4455 *
4456 * favorite(alice as any); //=> undefined
4457 * favoriteWithDefault(alice); //=> 'Ramda'
4458 * ```
4459 */
4460export function propOr<T, U>(val: T, __: Placeholder, obj: U): <V>(p: string) => V;
4461export function propOr<U>(__: Placeholder, p: string, obj: U): <T, V>(val: T) => V;
4462export function propOr<T, U, V>(val: T, p: string, obj: U): V;
4463export function propOr<T>(val: T, p: string): <U, V>(obj: U) => V;
4464export function propOr<T>(val: T): <U, V>(p: string, obj: U) => V;
4465
4466/**
4467 * Acts as multiple `prop`: array of keys in, array of values out. Preserves order.
4468 *
4469 * See also {@link prop}, {@link pluck}, {@link project}.
4470 *
4471 * @example
4472 * ```typescript
4473 * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
4474 * R.props(['c', 'a', 'b'], {b: 2, a: 1, c: 3}); //=> [3, 1, 2]
4475 *
4476 * const fullName = R.compose(R.join(' '), R.props(['first', 'last']));
4477 * const tony = {last: 'Bullet-Tooth', age: 33, first: 'Tony'};
4478 * fullName(tony); //=> 'Tony Bullet-Tooth'
4479 * ```
4480 */
4481export function props<P extends string, T>(ps: readonly P[], obj: Record<P, T>): T[];
4482export function props<P extends string>(ps: readonly P[]): <T>(obj: Record<P, T>) => T[];
4483export function props<P extends string, T>(ps: readonly P[]): (obj: Record<P, T>) => T[];
4484
4485/**
4486 * Returns `true` if the specified object property satisfies the given predicate; `false` otherwise.
4487 * You can test multiple properties with `R.where`.
4488 *
4489 * See also {@link where}, {@link propEq}, {@link propIs}.
4490 *
4491 * @example
4492 * ```typescript
4493 * const val = {x: 1, y: 2};
4494 * R.propSatisfies(x => x > 0, 'x', val); //=> true
4495 * ```
4496 */
4497export function propSatisfies<P, K extends keyof any>(
4498 pred: (val: any) => val is P,
4499 name: K,
4500 obj: any,
4501): obj is Record<K, P>;
4502export function propSatisfies<P, K extends keyof any>(
4503 pred: (val: any) => val is P,
4504 name: K,
4505): (obj: any) => obj is Record<K, P>;
4506export function propSatisfies<P>(pred: (val: any) => val is P): {
4507 <K extends keyof any>(name: K, obj: any): obj is Record<K, P>;
4508 <K extends keyof any>(name: K): (obj: any) => obj is Record<K, P>;
4509};
4510export function propSatisfies(pred: (val: any) => boolean, name: keyof any, obj: any): boolean;
4511export function propSatisfies(pred: (val: any) => boolean, name: keyof any): (obj: any) => boolean;
4512export function propSatisfies(pred: (val: any) => boolean): _.F.Curry<(a: keyof any, b: any) => boolean>;
4513
4514/**
4515 * Returns a list of numbers from `from` (inclusive) to `to` (exclusive).
4516 * In mathematical terms, `range(a, b)` is equivalent to the half-open interval `[a, b)`.
4517 *
4518 * @example
4519 * ```typescript
4520 * R.range(1, 5); //=> [1, 2, 3, 4]
4521 * R.range(50, 53); //=> [50, 51, 52]
4522 * ```
4523 */
4524export function range(from: number, to: number): number[];
4525export function range(from: number): (to: number) => number[];
4526
4527/**
4528 * Returns a single item by iterating through the list,
4529 * successively calling the iterator function and passing it an accumulator value and the current value from the array,
4530 * and then passing the result to the next call.
4531 *
4532 * The iterator function receives two values: `(acc, value)`. It may use `R.reduced` to shortcut the iteration.
4533 *
4534 * @note `R.reduce` does not skip deleted or unassigned indices (sparse arrays), unlike the native `Array.prototype.reduce` method.
4535 *
4536 * Dispatches to the `reduce` method of the third argument, if present.
4537 * When doing so, it is up to the user to handle the `R.reduced` shortcutting,
4538 * as this is not implemented by `reduce`.
4539 *
4540 * See also {@link reduced}, {@link addIndex}, {@link reduceRight}.
4541 *
4542 * @example
4543 * ```typescript
4544 * R.reduce(R.subtract, 0, [1, 2, 3, 4]) //=> ((((0 - 1) - 2) - 3) - 4) = -10
4545 * // - -10
4546 * // / \ / \
4547 * // - 4 -6 4
4548 * // / \ / \
4549 * // - 3 ==> -3 3
4550 * // / \ / \
4551 * // - 2 -1 2
4552 * // / \ / \
4553 * // 0 1 0 1
4554 * ```
4555 */
4556export function reduce<T, TResult>(
4557 fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>,
4558 acc: TResult,
4559 list: readonly T[],
4560): TResult;
4561export function reduce<T, TResult>(
4562 fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>,
4563): (acc: TResult, list: readonly T[]) => TResult;
4564export function reduce<T, TResult>(
4565 fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>,
4566 acc: TResult,
4567): (list: readonly T[]) => TResult;
4568
4569/**
4570 * Groups the elements of the list
4571 * according to the result of calling the string-returning function `keyFn` on each element
4572 * and reduces the elements of each group to a single value via the reducer function `valueFn`.
4573 *
4574 * The value function receives two values: `(acc, value)`.
4575 * It may use `R.reduced` to short circuit the iteration.
4576 *
4577 * This function is basically a more general `R.groupBy` function.
4578 *
4579 * Acts as a transducer if a transformer is given in list position.
4580 *
4581 * See also {@link groupBy}, {@link reduce}, {@link reduced}, {@link transduce}.
4582 *
4583 * @example
4584 * ```typescript
4585 * const groupNames = (acc: string[], { name }: { name: string; }) => acc.concat(name)
4586 * const toGrade = ({ score }: { score: number; }) =>
4587 * score < 65 ? 'F' :
4588 * score < 70 ? 'D' :
4589 * score < 80 ? 'C' :
4590 * score < 90 ? 'B' : 'A'
4591 *
4592 * var students = [
4593 * {name: 'Abby', score: 83},
4594 * {name: 'Bart', score: 62},
4595 * {name: 'Curt', score: 88},
4596 * {name: 'Dora', score: 92},
4597 * ]
4598 *
4599 * R.reduceBy(groupNames, [], toGrade, students)
4600 * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]}
4601 * ```
4602 */
4603export function reduceBy<T, TResult>(
4604 valueFn: (acc: TResult, elem: T) => TResult,
4605 acc: TResult,
4606 keyFn: (elem: T) => string,
4607 list: readonly T[],
4608): { [index: string]: TResult };
4609export function reduceBy<T, TResult>(
4610 valueFn: (acc: TResult, elem: T) => TResult,
4611 acc: TResult,
4612 keyFn: (elem: T) => string,
4613): (list: readonly T[]) => { [index: string]: TResult };
4614export function reduceBy<T, TResult>(
4615 valueFn: (acc: TResult, elem: T) => TResult,
4616 acc: TResult,
4617): _.F.Curry<(a: (elem: T) => string, b: readonly T[]) => { [index: string]: TResult }>;
4618export function reduceBy<T, TResult>(
4619 valueFn: (acc: TResult, elem: T) => TResult,
4620): _.F.Curry<(a: TResult, b: (elem: T) => string, c: readonly T[]) => { [index: string]: TResult }>;
4621
4622/**
4623 * Returns a value wrapped to indicate that it is the final value of the `R.reduce` and `R.transduce` functions.
4624 * The returned value should be considered a black box:
4625 * the internal structure is not guaranteed to be stable.
4626 *
4627 * This optimization is available to the below functions:
4628 * - `R.reduce`
4629 * - `R.reduceWhile`
4630 * - `R.reduceBy`
4631 * - `R.reduceRight`
4632 * - `R.transduce`
4633 *
4634 * See also {@link reduce}, {@link reduceWhile}, {@link reduceBy}, {@link reduceRight}, {@link transduce}.
4635 *
4636 * @example
4637 * ```typescript
4638 * R.reduce(
4639 * (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item),
4640 * [] as number[],
4641 * [1, 2, 3, 4, 5]) // [1, 2, 3]
4642 * ```
4643 */
4644export function reduced<T>(elem: T): Reduced<T>;
4645
4646// NOTE: the example currently does not work, even if `R.__` overloads are removed
4647/**
4648 * Returns a single item by iterating through the list,
4649 * successively calling the iterator function
4650 * and passing it an accumulator value and the current value from the array,
4651 * and then passing the result to the next call.
4652 *
4653 * Similar to `R.reduce`, except moves through the input list from the right to the left.
4654 *
4655 * The iterator function receives two values: `(value, acc)`,
4656 * reversed compared to that of `R.reduce`'s iterator function.
4657 * `reduceRight` may use `R.reduced` to short circuit the iteration.
4658 *
4659 * @note `R.reduceRight` does not skip deleted or unassigned indices (sparse arrays),
4660 * unlike the native `Array.prototype.reduceRight` method.
4661 *
4662 * See also {@link reduce}, {@link addIndex}, {@link reduced}.
4663 *
4664 * @example
4665 * ```typescript
4666 * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2
4667 * // - -2
4668 * // / \ / \
4669 * // 1 - 1 3
4670 * // / \ / \
4671 * // 2 - ==> 2 -1
4672 * // / \ / \
4673 * // 3 - 3 4
4674 * // / \ / \
4675 * // 4 0 4 0
4676 * ```
4677 */
4678export function reduceRight<T, TResult>(
4679 fn: (elem: T, acc: TResult) => TResult,
4680 acc: TResult,
4681 list: readonly T[],
4682): TResult;
4683export function reduceRight<T, TResult>(
4684 fn: (elem: T, acc: TResult) => TResult,
4685): (acc: TResult, list: readonly T[]) => TResult;
4686export function reduceRight<T, TResult>(
4687 fn: (elem: T, acc: TResult) => TResult,
4688 acc: TResult,
4689): (list: readonly T[]) => TResult;
4690
4691/**
4692 * Like `R.reduce`, `R.reduceWhile` returns a single item by iterating through the list,
4693 * successively calling the iterator function.
4694 * `R.reduceWhile` also takes a predicate that is evaluated before each step.
4695 * If the predicate returns a falsy value,
4696 * it "short-circuits" the iteration and returns the current value of the accumulator.
4697 *
4698 * See also {@link reduce}, {@link reduced}.
4699 *
4700 * @example
4701 * ```typescript
4702 * const isOdd = (acc: number, x: number) => x % 2 !== 0;
4703 * const xs = [1, 3, 5, 60, 777, 800];
4704 * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9
4705 *
4706 * const ys = [2, 4, 6]
4707 * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111
4708 * ```
4709 */
4710export function reduceWhile<T, TResult>(
4711 predicate: (acc: TResult, elem: T) => boolean,
4712 fn: (acc: TResult, elem: T) => TResult,
4713 acc: TResult,
4714 list: readonly T[],
4715): TResult;
4716export function reduceWhile<T, TResult>(
4717 predicate: (acc: TResult, elem: T) => boolean,
4718 fn: (acc: TResult, elem: T) => TResult,
4719 acc: TResult,
4720): (list: readonly T[]) => TResult;
4721export function reduceWhile<T, TResult>(
4722 predicate: (acc: TResult, elem: T) => boolean,
4723 fn: (acc: TResult, elem: T) => TResult,
4724): _.F.Curry<(a: TResult, b: readonly T[]) => TResult>;
4725export function reduceWhile<T, TResult>(
4726 predicate: (acc: TResult, elem: T) => boolean,
4727): _.F.Curry<(a: (acc: TResult, elem: T) => TResult, b: TResult, c: readonly T[]) => TResult>;
4728
4729/**
4730 * The complement of `R.filter`.
4731 *
4732 * Acts as a transducer if a transformer is given in list position.
4733 * `Filterable` objects include plain objects or any object that has a `filter` method such as `Array`.
4734 *
4735 * See also {@link filter}, {@link transduce}, {@link addIndex}.
4736 *
4737 * @example
4738 * ```typescript
4739 * const isOdd = (n: number) => n % 2 !== 0;
4740 *
4741 * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
4742 *
4743 * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
4744 * ```
4745 */
4746export function reject<A, P extends A>(
4747 pred: (val: A) => val is P,
4748): {
4749 <B extends A>(list: readonly B[]): Array<Exclude<B, P>>;
4750 <B extends A>(dict: Dictionary<B>): Dictionary<Exclude<B, P>>;
4751};
4752export function reject<T>(
4753 pred: (value: T) => boolean,
4754): <P extends T, C extends readonly P[] | Dictionary<P>>(collection: C) => C;
4755export function reject<A, B extends A, P extends A>(
4756 pred: (val: A) => val is P,
4757 list: readonly B[],
4758): Array<Exclude<B, P>>;
4759export function reject<A, B extends A, P extends A>(
4760 pred: (val: A) => val is P,
4761 dict: Dictionary<B>,
4762): Dictionary<Exclude<B, P>>;
4763export function reject<T, C extends readonly T[] | Dictionary<T>>(pred: (value: T) => boolean, collection: C): C;
4764
4765/**
4766 * Returns a copy of the given list
4767 * with the given number of elements removed,
4768 * starting at the given start index.
4769 *
4770 * See also {@link without}.
4771 *
4772 * @example
4773 * ```typescript
4774 * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]
4775 * ```
4776 */
4777export function remove<T>(start: number, count: number, list: readonly T[]): T[];
4778export function remove<T>(start: number): {
4779 (count: number, list: readonly T[]): T[];
4780 (count: number): (list: readonly T[]) => T[];
4781};
4782export function remove<T>(start: number, count: number): (list: readonly T[]) => T[];
4783
4784/**
4785 * Returns a fixed list of size `n`, containing a specified identical value.
4786 *
4787 * See also {@link times}.
4788 *
4789 * @example
4790 * ```typescript
4791 * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi']
4792 *
4793 * const obj = {};
4794 * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}]
4795 * repeatedObjs[0] === repeatedObjs[1]; //=> true
4796 * ```
4797 */
4798export function repeat<T>(a: T, n: number): T[];
4799export function repeat<T>(a: T): (n: number) => T[];
4800
4801/**
4802 * Replace a substring or regex match in a string with a replacement.
4803 *
4804 * The first two parameters correspond to the parameters of `String.prototype.replace`,
4805 * so the second parameter can also be a function.
4806 *
4807 * @example
4808 * ```typescript
4809 * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
4810 * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'
4811 *
4812 * // Use the "g" (global) flag to replace all occurrences:
4813 * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
4814 * ```
4815 */
4816export function replace(
4817 pattern: RegExp | string,
4818 replacement: string | ((match: string, ...args: readonly any[]) => string),
4819 str: string,
4820): string;
4821export function replace(
4822 pattern: RegExp | string,
4823 replacement: string | ((match: string, ...args: readonly any[]) => string),
4824): (str: string) => string;
4825export function replace(
4826 pattern: RegExp | string,
4827): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => (str: string) => string;
4828
4829/**
4830 * Returns a new list or string with the elements in reverse order.
4831 *
4832 * @example
4833 * ```typescript
4834 * R.reverse([1, 2, 3]); //=> [3, 2, 1]
4835 * R.reverse([1, 2]); //=> [2, 1]
4836 * R.reverse([1]); //=> [1]
4837 * R.reverse([]); //=> []
4838 *
4839 * R.reverse('abc'); //=> 'cba'
4840 * R.reverse('ab'); //=> 'ba'
4841 * R.reverse('a'); //=> 'a'
4842 * R.reverse(''); //=> ''
4843 * ```
4844 */
4845export function reverse<T>(list: readonly T[]): T[];
4846export function reverse(str: string): string;
4847
4848/**
4849 * Similar to `R.reduce`, but returns a list of successively reduced values from the left.
4850 *
4851 * See also {@link reduce}, {@link mapAccum}.
4852 *
4853 * @example
4854 * ```typescript
4855 * const numbers = [1, 2, 3, 4];
4856 * const factorials = R.scan(R.multiply, 1 as number, numbers); //=> [1, 1, 2, 6, 24]
4857 * ```
4858 */
4859export function scan<T, TResult>(fn: (acc: TResult, elem: T) => any, acc: TResult, list: readonly T[]): TResult[];
4860export function scan<T, TResult>(fn: (acc: TResult, elem: T) => any, acc: TResult): (list: readonly T[]) => TResult[];
4861export function scan<T, TResult>(fn: (acc: TResult, elem: T) => any): (acc: TResult, list: readonly T[]) => TResult[];
4862
4863/**
4864 * Returns the result of "setting" the portion of the given data structure focused by the given lens
4865 * to the given value.
4866 *
4867 * See also {@link view}, {@link over}, {@link lens}, {@link lensIndex}, {@link lensProp}, {@link lensPath}.
4868 *
4869 * @example
4870 * ```typescript
4871 * const xLens = R.lensProp<'x', number>('x');
4872 *
4873 * const point = {x: 1, y: 2};
4874 * R.set(xLens, 4, point); //=> {x: 4, y: 2}
4875 * R.set(xLens, 8, point); //=> {x: 8, y: 2}
4876 * ```
4877 */
4878export function set<S, A>(lens: Lens<S, A>, a: A, obj: S): S;
4879export function set<S, A>(lens: Lens<S, A>, a: A): (obj: S) => S;
4880export function set<S, A>(lens: Lens<S, A>): (a: A, obj: S) => S;
4881
4882/**
4883 * Returns the elements of the given list or string
4884 * from `fromIndex` (inclusive) to `toIndex` (exclusive).
4885 *
4886 * Dispatches to the `slice` method of the third argument, if present.
4887 *
4888 * @example
4889 * ```typescript
4890 * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
4891 * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
4892 * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
4893 * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
4894 * R.slice(0, 3, 'ramda'); //=> 'ram'
4895 * ```
4896 */
4897export function slice(a: number, b: number, list: string): string;
4898export function slice<T>(a: number, b: number, list: readonly T[]): T[];
4899export function slice(
4900 a: number,
4901 b: number,
4902): {
4903 <T>(list: readonly T[]): T[];
4904 (list: string): string;
4905};
4906export function slice(a: number): {
4907 <T>(b: number, list: readonly T[]): T[];
4908 (b: number, list: string): string;
4909};
4910
4911/**
4912 * Returns a copy of the list, sorted according to the comparator function,
4913 * which should accept two values at a time and return:
4914 * - a negative number if the first value is smaller,
4915 * - a positive number if it's larger, and
4916 * - zero if they are equal.
4917 *
4918 * See also {@link sortBy}, {@link sortWith}, {@link ascend}, {@link descend}.
4919 *
4920 * @example
4921 * ```typescript
4922 * R.sort(R.subtract, [4,2,7,5]); //=> [2, 4, 5, 7]
4923 * ```
4924 */
4925export function sort<T>(fn: (a: T, b: T) => number, list: readonly T[]): T[];
4926export function sort<T>(fn: (a: T, b: T) => number): (list: readonly T[]) => T[];
4927
4928/**
4929 * Sorts the list according to a key generated by the supplied function.
4930 *
4931 * See also {@link sort}, {@link sortWith}, {@link ascend}, {@link descend}.
4932 *
4933 * @example
4934 * ```typescript
4935 * type Person = { name: string; age: number; };
4936 *
4937 * const sortByFirstItem = R.sortBy(R.prop(0));
4938 * const pairs = [[-1, 1], [-2, 2], [-3, 3]];
4939 * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]
4940 * const sortByNameCaseInsensitive = R.sortBy<Person>(R.compose(R.toLower, R.prop('name')));
4941 * const alice = {
4942 * name: 'ALICE',
4943 * age: 101
4944 * };
4945 * const bob = {
4946 * name: 'Bob',
4947 * age: -10
4948 * };
4949 * const clara = {
4950 * name: 'clara',
4951 * age: 314.159
4952 * };
4953 * const people = [clara, bob, alice];
4954 * sortByNameCaseInsensitive(people); //=> [alice, bob, clara]
4955 * ```
4956 */
4957export function sortBy<T>(fn: (a: T) => Ord, list: readonly T[]): T[];
4958export function sortBy<T>(fn: (a: T) => Ord): (list: readonly T[]) => T[];
4959export function sortBy(fn: (a: any) => Ord): <T>(list: readonly T[]) => T[];
4960
4961/**
4962 * Sorts a list according to a list of comparators.
4963 *
4964 * See also {@link sort}, {@link sortBy}, {@link ascend}, {@link descend}.
4965 *
4966 * @example
4967 * ```typescript
4968 * type Person = { age: number; name: string; };
4969 *
4970 * const alice = {
4971 * name: 'alice',
4972 * age: 40
4973 * };
4974 * const bob = {
4975 * name: 'bob',
4976 * age: 30
4977 * };
4978 * const clara = {
4979 * name: 'clara',
4980 * age: 40
4981 * };
4982 * const people = [clara, bob, alice];
4983 * const ageNameSort = R.sortWith<Person>([
4984 * R.descend(R.prop('age')),
4985 * R.ascend(R.prop('name'))
4986 * ]);
4987 * ageNameSort(people); //=> [alice, clara, bob]
4988 * ```
4989 */
4990export function sortWith<T>(fns: ReadonlyArray<(a: T, b: T) => number>, list: readonly T[]): T[];
4991export function sortWith<T>(fns: ReadonlyArray<(a: T, b: T) => number>): (list: readonly T[]) => T[];
4992
4993/**
4994 * Splits a string into an array of strings based on the given separator.
4995 *
4996 * See also {@link join}.
4997 *
4998 * @example
4999 * ```typescript
5000 * const pathComponents = R.split('/');
5001 * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node']
5002 *
5003 * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd']
5004 * ```
5005 */
5006export function split(sep: string | RegExp): (str: string) => string[];
5007export function split(sep: string | RegExp, str: string): string[];
5008
5009/**
5010 * Splits a given list or string at a given index.
5011 *
5012 * @example
5013 * ```typescript
5014 * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]]
5015 * R.splitAt(5, 'hello world'); //=> ['hello', ' world']
5016 * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r']
5017 * ```
5018 */
5019export function splitAt<T>(index: number, list: readonly T[]): [T[], T[]];
5020export function splitAt(index: number, list: string): [string, string];
5021export function splitAt(index: number): {
5022 <T>(list: readonly T[]): [T[], T[]];
5023 (list: string): [string, string];
5024};
5025
5026/**
5027 * Splits a collection into slices of the specified length.
5028 *
5029 * @example
5030 * ```typescript
5031 * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]]
5032 * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz']
5033 * ```
5034 */
5035export function splitEvery<T>(a: number, list: readonly T[]): T[][];
5036export function splitEvery(a: number, list: string): string[];
5037export function splitEvery(a: number): {
5038 (list: string): string[];
5039 <T>(list: readonly T[]): T[][];
5040};
5041
5042/**
5043 * Takes a list and a predicate and returns a pair of lists.
5044 * The first list contains all elements
5045 * before (but not including) the first element for which the predicate returns a truthy value.
5046 * The second list contains the rest of the elements.
5047 * It will be empty if no elements satisfy the predicate.
5048 *
5049 * @example
5050 * ```typescript
5051 * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]]
5052 * ```
5053 */
5054export function splitWhen<T>(pred: (val: T) => boolean, list: readonly T[]): [T[], T[]];
5055export function splitWhen<T>(pred: (val: T) => boolean): <U extends T>(list: readonly U[]) => [U[], U[]];
5056
5057/**
5058 * Splits an array into slices on every occurrence of a value.
5059 *
5060 * @example
5061 * ```typescript
5062 * R.splitWhenever(R.equals(2), [1, 2, 3, 2, 4, 5, 2, 6, 7]); //=> [[1], [3], [4, 5], [6, 7]]
5063 * ```
5064 */
5065export function splitWhenever<T>(pred: (a: T) => boolean, list: T[]): T[][];
5066export function splitWhenever<T>(pred: (a: T) => boolean): <U extends T>(list: U[]) => U[][];
5067
5068/**
5069 * Checks if a list starts with the provided sublist.
5070 *
5071 * Similarly, checks if a string starts with the provided substring.
5072 *
5073 * See also {@link endsWith}.
5074 *
5075 * @example
5076 * ```typescript
5077 * R.startsWith('a', 'abc') //=> true
5078 * R.startsWith('b', 'abc') //=> false
5079 * R.startsWith(['a'], ['a', 'b', 'c']) //=> true
5080 * R.startsWith(['b'], ['a', 'b', 'c']) //=> false
5081 * ```
5082 */
5083export function startsWith(substr: string, str: string): boolean;
5084export function startsWith(substr: string): (str: string) => boolean;
5085export function startsWith<T>(subList: readonly T[], list: readonly T[]): boolean;
5086export function startsWith<T>(subList: readonly T[]): (list: readonly T[]) => boolean;
5087
5088/**
5089 * Subtracts two numbers. Equivalent to `a - b` but curried.
5090 *
5091 * @example
5092 * ```typescript
5093 * R.subtract(10, 8); //=> 2
5094 *
5095 * const minus5 = R.subtract(R.__, 5);
5096 * minus5(17); //=> 12
5097 *
5098 * const complementaryAngle = R.subtract(90);
5099 * complementaryAngle(30); //=> 60
5100 * complementaryAngle(72); //=> 18
5101 * ```
5102 */
5103export function subtract(__: Placeholder, b: number): (a: number) => number;
5104export function subtract(__: Placeholder): (b: number, a: number) => number;
5105export function subtract(a: number, b: number): number;
5106export function subtract(a: number): (b: number) => number;
5107
5108/**
5109 * Adds together all the elements of a list.
5110 *
5111 * See also {@link reduce}.
5112 *
5113 * @example
5114 * ```typescript
5115 * R.sum([2,4,6,8,100,1]); //=> 121
5116 * ```
5117 */
5118export function sum(list: readonly number[]): number;
5119
5120/**
5121 * Finds the set (i.e. no duplicates) of all elements
5122 * contained in the first or second list, but not both.
5123 *
5124 * See also {@link symmetricDifferenceWith}, {@link difference}, {@link differenceWith}.
5125 *
5126 * @example
5127 * ```typescript
5128 * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5]
5129 * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2]
5130 * ```
5131 */
5132export function symmetricDifference<T>(list1: readonly T[], list2: readonly T[]): T[];
5133export function symmetricDifference<T>(list: readonly T[]): <T>(list: readonly T[]) => T[];
5134
5135/**
5136 * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.
5137 * Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
5138 *
5139 * @example
5140 * ```typescript
5141 * const eqA = R.eqBy(R.prop<number>('a'));
5142 * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
5143 * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}];
5144 * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}]
5145 * ```
5146 */
5147export function symmetricDifferenceWith<T>(
5148 pred: (a: T, b: T) => boolean,
5149 list1: readonly T[],
5150 list2: readonly T[],
5151): T[];
5152export function symmetricDifferenceWith<T>(
5153 pred: (a: T, b: T) => boolean,
5154): _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>;
5155
5156/**
5157 * A function that always returns `true`. Any passed in parameters are ignored.
5158 *
5159 * See also {@link F}.
5160 *
5161 * @example
5162 * ```typescript
5163 * R.T(); //=> true
5164 * ```
5165 */
5166export function T(...args: unknown[]): true;
5167
5168/**
5169 * Returns all but the first element of a list or string.
5170 *
5171 * @example
5172 * ```typescript
5173 * R.tail([1, 2, 3]); //=> [2, 3]
5174 * R.tail([1, 2]); //=> [2]
5175 * R.tail([1]); //=> []
5176 * R.tail([]); //=> []
5177 *
5178 * R.tail('abc'); //=> 'bc'
5179 * R.tail('ab'); //=> 'b'
5180 * R.tail('a'); //=> ''
5181 * R.tail(''); //=> ''
5182 * ```
5183 */
5184export function tail(list: string): string;
5185export function tail<T>(list: readonly T[]): T[];
5186
5187/**
5188 * Returns the first (at most) `n` elements of the given list, string, or transducer/transformer.
5189 *
5190 * Dispatches to the `take` method of the second argument, if present.
5191 *
5192 * See also {@link drop}.
5193 *
5194 * @example
5195 * ```typescript
5196 * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo']
5197 * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
5198 * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
5199 * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
5200 * R.take(3, 'ramda'); //=> 'ram'
5201 *
5202 * const personnel = [
5203 * 'Dave Brubeck',
5204 * 'Paul Desmond',
5205 * 'Eugene Wright',
5206 * 'Joe Morello',
5207 * 'Gerry Mulligan',
5208 * 'Bob Bates',
5209 * 'Joe Dodge',
5210 * 'Ron Crotty'
5211 * ];
5212 *
5213 * const takeFive = R.take(5);
5214 * takeFive(personnel);
5215 * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan']
5216 * ```
5217 */
5218export function take<T>(n: number, xs: readonly T[]): T[];
5219export function take(n: number, xs: string): string;
5220export function take(n: number): {
5221 (xs: string): string;
5222 <T>(xs: readonly T[]): T[];
5223};
5224export function take<T>(n: number): (xs: readonly T[]) => T[];
5225
5226/**
5227 * Returns a new list containing the last (at most) `n` elements of the given list.
5228 *
5229 * See also {@link dropLast}.
5230 *
5231 * @example
5232 * ```typescript
5233 * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
5234 * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
5235 * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
5236 * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
5237 * R.takeLast(3, 'ramda'); //=> 'mda'
5238 * ```
5239 */
5240export function takeLast<T>(n: number, xs: readonly T[]): T[];
5241export function takeLast(n: number, xs: string): string;
5242export function takeLast(n: number): {
5243 (xs: string): string;
5244 <T>(xs: readonly T[]): T[];
5245};
5246
5247/**
5248 * Returns a new list containing the last elements of a given list,
5249 * passing each value to the supplied predicate function
5250 * and terminating when the predicate function returns a falsy value.
5251 * Excludes the element that caused the predicate function to fail.
5252 *
5253 * See also {@link dropLastWhile}, {@link addIndex}.
5254 */
5255export function takeLastWhile<T>(pred: (a: T) => boolean, list: readonly T[]): T[];
5256export function takeLastWhile<T>(pred: (a: T) => boolean): <T>(list: readonly T[]) => T[];
5257
5258/**
5259 * Returns a new list containing the first elements of a given list,
5260 * passing each value to the supplied predicate function,
5261 * and terminating when the predicate function returns a falsy value.
5262 *
5263 * Dispatches to the `takeWhile` method of the second argument, if present.
5264 *
5265 * Acts as a transducer if a transformer is given in list position.
5266 *
5267 * See also {@link dropWhile}, {@link addIndex}, {@link transduce}.
5268 */
5269export function takeWhile<T>(fn: (x: T) => boolean, list: readonly T[]): T[];
5270export function takeWhile<T>(fn: (x: T) => boolean): (list: readonly T[]) => T[];
5271
5272/**
5273 * Runs the given function with the supplied object, then returns the object.
5274 * Acts as a transducer if a transformer is given as second parameter.
5275 *
5276 * @example
5277 * ```typescript
5278 * const sayX = <T>(x: T) => console.log('x is ' + x);
5279 * R.tap(sayX, 100); //=> 100
5280 * // logs 'x is 100'
5281 * ```
5282 */
5283export function tap<T, R extends T = T>(fn: (a: T) => asserts a is R, value: T): R;
5284export function tap<T, R extends T = T>(fn: (a: T) => asserts a is R): (value: T) => R;
5285export function tap<T>(fn: (a: T) => void, value: T): T;
5286export function tap<T>(fn: (a: T) => void): (value: T) => T;
5287
5288/**
5289 * Determines whether a given string matches a given regular expression.
5290 *
5291 * See also {@link match}.
5292 *
5293 * @example
5294 * ```typescript
5295 * R.test(/^x/, 'xyz'); //=> true
5296 * R.test(/^y/, 'xyz'); //=> false
5297 * ```
5298 */
5299export function test(regexp: RegExp, str: string): boolean;
5300export function test(regexp: RegExp): (str: string) => boolean;
5301
5302/**
5303 * Creates a thunk out of a function.
5304 * A thunk delays a calculation until its result is needed,
5305 * providing lazy evaluation of arguments.
5306 *
5307 * See also {@link partial}, {@link partialRight}.
5308 *
5309 * @example
5310 * ```typescript
5311 * R.thunkify(R.identity)(42)(); //=> 42
5312 * R.thunkify((a: number, b: number) => a + b)(25, 17)(); //=> 42
5313 * ```
5314 */
5315export function thunkify<F extends AnyFunction>(fn: F): _.F.Curry<(...args: Parameters<F>) => () => ReturnType<F>>;
5316
5317/**
5318 * Calls an input function `n` times,
5319 * returning an array containing the results of those function calls.
5320 *
5321 * `fn` is passed one argument:
5322 * The current value of `n`,
5323 * which begins at `0` and is gradually incremented to `n - 1`.
5324 *
5325 * See also {@link repeat}.
5326 *
5327 * @example
5328 * ```typescript
5329 * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4]
5330 * ```
5331 */
5332export function times<T>(fn: (i: number) => T, n: number): T[];
5333export function times<T>(fn: (i: number) => T): (n: number) => T[];
5334
5335/**
5336 * The lower case version of a string.
5337 *
5338 * See also {@link toUpper}.
5339 *
5340 * @example
5341 * ```typescript
5342 * R.toLower('XYZ'); //=> 'xyz'
5343 * ```
5344 */
5345export function toLower<S extends string>(str: S): Lowercase<S>;
5346export function toLower(str: string): string;
5347
5348/**
5349 * Converts an object into an array of key, value arrays.
5350 * Only the object's own properties are used.
5351 * Note that the order of the output array is not guaranteed to be consistent
5352 * across different JS platforms.
5353 *
5354 * See also {@link toPairsIn}, {@link fromPairs}, {@link keys}, {@link values}.
5355 */
5356export function toPairs<O extends object, K extends Extract<keyof O, string | number>>(
5357 obj: O,
5358): Array<{ [key in K]: [`${key}`, O[key]] }[K]>;
5359export function toPairs<S>(obj: Record<string | number, S>): Array<[string, S]>;
5360
5361/**
5362 * Converts an object into an array of key, value arrays.
5363 * The object's own properties and prototype properties are used.
5364 * Note that the order of the output array is not guaranteed to be consistent
5365 * across different JS platforms.
5366 *
5367 * See also {@link toPairs}.=
5368 *
5369 * @example
5370 * ```typescript
5371 * class F {
5372 * x: string;
5373 * y = 'Y';
5374 *
5375 * constructor() {
5376 * this.x = 'X';
5377 * }
5378 * }
5379 *
5380 * const f = new F();
5381 * R.toPairsIn(f); //=> [['x','X'], ['y','Y']]
5382 * ```
5383 */
5384export function toPairsIn<O extends object, K extends Extract<keyof O, string | number>>(
5385 obj: O,
5386): Array<{ [key in K]: [`${key}`, O[key]] }[K]>;
5387export function toPairsIn<S>(obj: Record<string | number, S>): Array<[string, S]>;
5388
5389/**
5390 * Returns the string representation of the given value.
5391 * `eval`'ing the output should result in a value equivalent to the input value.
5392 * Many of the built-in `toString` methods do not satisfy this requirement.
5393 *
5394 * If the given value is an `Object` with a toString method other than `Object.prototype.toString`,
5395 * that method is invoked with no arguments to produce the return value.
5396 * This means user-defined constructor functions can provide a suitable `toString` method.
5397 *
5398 * @example
5399 * ```typescript
5400 * class Point {
5401 * constructor(public x: number, public y: number) {}
5402 *
5403 * toString() {
5404 * return 'new Point(' + this.x + ', ' + this.y + ')';
5405 * }
5406 * }
5407 *
5408 * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)'
5409 * R.toString(42); //=> '42'
5410 * R.toString('abc'); //=> '"abc"'
5411 * R.toString([1, 2, 3]); //=> '[1, 2, 3]'
5412 * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}'
5413 * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")'
5414 * ```
5415 */
5416export function toString(val: unknown): string;
5417
5418/**
5419 * The upper case version of a string.
5420 *
5421 * See also {@link toLower}.
5422 *
5423 * @example
5424 * ```typescript
5425 * R.toUpper('abc'); //=> 'ABC'
5426 * ```
5427 */
5428export function toUpper<S extends string>(str: S): Uppercase<S>;
5429export function toUpper(str: string): string;
5430
5431/**
5432 * Initializes a transducer using supplied iterator function.
5433 * Returns a single item by iterating through the list,
5434 * successively calling the transformed iterator function
5435 * and passing it an accumulator value and the current value from the array,
5436 * and then passing the result to the next call.
5437 *
5438 * The iterator function receives two values: `(acc, value)`.
5439 * It will be wrapped as a transformer to initialize the transducer.
5440 * A transformer can be passed directly in place of an iterator function.
5441 * In both cases, iteration may be stopped early with the `R.reduced` function.
5442 *
5443 * A transducer is a function that accepts a transformer and returns a transformer and can be composed directly.
5444 *
5445 * The accumulator can also be a transformer object that provides:
5446 * - A 2-arity iterator function, which is passed directly to reduce.
5447 * - A 0-arity initial value function, which is used to provide the initial accumulator.
5448 * This is ignored by `R.transduce`.
5449 * - A 1-arity result extraction function, which is used to convert the final accumulator into the return type.
5450 *
5451 * The iteration is performed with `R.reduce` after initializing the transducer.
5452 *
5453 * See also {@link reduce}, {@link reduced}, {@link into}.
5454 *
5455 * @example
5456 * ```typescript
5457 * const numbers = [1, 2, 3, 4];
5458 * const transducer = R.compose(R.map(R.add(1)), R.take<number>(2));
5459 * R.transduce(transducer, R.flip<number, number[], number[]>(R.append), [], numbers); //=> [2, 3]
5460 *
5461 * const isOdd = (x: number) => x % 2 !== 0;
5462 * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1));
5463 * R.transduce(firstOddTransducer, R.flip<number, number[], number[]>(R.append), [], R.range(0, 100)); //=> [1]
5464 * ```
5465 */
5466export function transduce<T, U, V>(
5467 xf: (arg: readonly T[]) => U[],
5468 fn: (acc: V, val: U) => V,
5469 acc: V,
5470 list: readonly T[],
5471): V;
5472export function transduce<T, U, V>(
5473 xf: (arg: readonly T[]) => U[],
5474): (fn: (acc: V, val: U) => V, acc: V, list: readonly T[]) => V;
5475export function transduce<T, U, V>(
5476 xf: (arg: readonly T[]) => U[],
5477 fn: (acc: V, val: U) => V,
5478): (acc: readonly T[], list: readonly T[]) => V;
5479export function transduce<T, U, V>(
5480 xf: (arg: readonly T[]) => U[],
5481 fn: (acc: V, val: U) => V,
5482 acc: readonly T[],
5483): (list: readonly T[]) => V;
5484
5485/**
5486 * Transposes the rows and columns of a 2D list.
5487 * When passed a list of `n` lists of length `x`,
5488 * returns a list of `x` lists of length `n`.
5489 *
5490 * @example
5491 * ```typescript
5492 * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']]
5493 * R.transpose<string | number>([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']]
5494 *
5495 * // If some of the rows are shorter than the following rows, their elements are skipped:
5496 * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]]
5497 * ```
5498 */
5499export function transpose<T>(list: readonly T[][]): T[][];
5500
5501/**
5502 * Maps an `Applicative`-returning function over a `Traversable`,
5503 * then uses `R.sequence` to transform the resulting `Traversable` of `Applicative`
5504 * into an `Applicative` of `Traversable`.
5505 *
5506 * Dispatches to the `traverse` method of the third argument, if present.
5507 *
5508 * See also {@link sequence}.
5509 *
5510 * @example
5511 * ```typescript
5512 * // Returns `[]` if the given divisor is `0`
5513 * const safeDiv = (n: number) => (d: number) => d === 0 ? [] : Array.of(n / d)
5514 *
5515 * R.traverse(Array.of, safeDiv(10), [2, 4, 5]); //=> [[5, 2.5, 2]]
5516 * R.traverse(Array.of, safeDiv(10), [2, 0, 5]); //=> []
5517 * ```
5518 */
5519export function traverse<A, B>(of: (a: B) => B[], fn: (t: A) => B[], list: readonly A[]): B[][];
5520export function traverse<A, B>(of: (a: B) => B[], fn: (t: A) => B[]): (list: readonly A[]) => B[][];
5521export function traverse<A, B>(of: (a: B) => B[]): (fn: (t: A) => B[], list: readonly A[]) => B[][];
5522
5523/**
5524 * Removes (strips) whitespace from both ends of the string.
5525 *
5526 * @example
5527 * ```typescript
5528 * R.trim(' xyz '); //=> 'xyz'
5529 * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z']
5530 * ```
5531 */
5532export function trim(str: string): string;
5533
5534/**
5535 * `R.tryCatch` takes two functions, a `tryer` and a `catcher`.
5536 * The returned function evaluates the `tryer`;
5537 * if it does not throw, it simply returns the result.
5538 * If the `tryer` does throw,
5539 * the returned function evaluates the `catcher` function and returns its result.
5540 *
5541 * @note For effective composition with this function,
5542 * both the `tryer` and `catcher` functions must return the same type of results.
5543 *
5544 * @example
5545 * ```typescript
5546 * R.tryCatch(R.prop('x'), R.F)({ x: true }); //=> true
5547 * R.tryCatch((_s: string) => { throw 'foo' }, R.always('caught'))('bar') //=> 'caught'
5548 * // Don't do this, it's just an example
5549 * R.tryCatch(R.times(R.identity), R.always([]))('s' as never) //=> []
5550 * R.tryCatch((_s: string) => { throw 'this is not a valid value' }, (err, value)=>({ error: err, value }))('bar')
5551 * //=> {'error': 'this is not a valid value', 'value': 'bar'}
5552 * ```
5553 */
5554export function tryCatch<F extends AnyFunction, RE = ReturnType<F>, E = unknown>(
5555 tryer: F,
5556 catcher: (error: E, ...args: _.F.Parameters<F>) => RE,
5557): F | (() => RE);
5558export function tryCatch<F extends AnyFunction>(
5559 tryer: F,
5560): <RE = ReturnType<F>, E = unknown>(catcher: (error: E, ...args: _.F.Parameters<F>) => RE) => F | (() => RE);
5561
5562/**
5563 * Gives a single-word string description of the (native) type of a value,
5564 * returning such answers as `'Object'`, `'Number'`, `'Array'`, or `'Null'`.
5565 * Does not attempt to distinguish user `Object` types any further,
5566 * reporting them all as `'Object'`.
5567 *
5568 * Uses `Object.prototype.toString` internally for values other than `null` and `undefined`.
5569 *
5570 * @example
5571 * ```typescript
5572 * R.type({}); //=> "Object"
5573 * R.type(1); //=> "Number"
5574 * R.type(false); //=> "Boolean"
5575 * R.type('s'); //=> "String"
5576 * R.type(null); //=> "Null"
5577 * R.type([]); //=> "Array"
5578 * R.type(/[A-z]/); //=> "RegExp"
5579 * R.type(() => {}); //=> "Function"
5580 * R.type(undefined); //=> "Undefined"
5581 * ```
5582 */
5583export function type(
5584 val: any,
5585):
5586 | 'Object'
5587 | 'Number'
5588 | 'Boolean'
5589 | 'String'
5590 | 'Null'
5591 | 'Array'
5592 | 'RegExp'
5593 | 'Function'
5594 | 'Undefined'
5595 | 'Symbol'
5596 | 'Error';
5597
5598/**
5599 * Takes a function `fn`, which takes a single array argument, and returns a function which:
5600 * - takes any number of positional arguments;
5601 * - passes these arguments to fn as an array; and
5602 * - returns the result.
5603 *
5604 * In other words, `R.unapply` derives a variadic function from a function which takes an array.
5605 * `R.unapply` is the inverse of `R.apply`.
5606 *
5607 * See also {@link apply}.
5608 *
5609 * @example
5610 * ```typescript
5611 * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]'
5612 * ```
5613 */
5614export function unapply<T>(fn: (args: any[]) => T): (...args: unknown[]) => T;
5615
5616/**
5617 * Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter.
5618 * Any extraneous parameters will not be passed to the supplied function.
5619 *
5620 * See also {@link binary}, {@link nAry}.
5621 *
5622 * @example
5623 * ```typescript
5624 * const takesTwoArgs = <T, U>(a: T, b: U) => [a, b];
5625 * takesTwoArgs.length; //=> 2
5626 * takesTwoArgs(1, 2); //=> [1, 2]
5627 *
5628 * const takesOneArg = R.unary(takesTwoArgs);
5629 * takesOneArg.length; //=> 1
5630 * // Only 1 argument is passed to the wrapped function
5631 * takesOneArg(1); //=> [1, undefined]
5632 * ```
5633 */
5634export function unary<T, R>(fn: (a: T, ...args: any[]) => R): (a: T) => R;
5635
5636/**
5637 * Returns a function of arity n from a (manually) curried function.
5638 *
5639 * @note The returned function is actually a ramda style curryied function,
5640 * which can accept one or more arguments in each function calling.
5641 *
5642 * @example
5643 * ```typescript
5644 * const addFour = (a: number) => (b: number) => (c: number) => (d: number) => a + b + c + d;
5645 *
5646 * const uncurriedAddFour = R.uncurryN<number>(4, addFour);
5647 * uncurriedAddFour(1, 2, 3, 4); //=> 10
5648 * ```
5649 */
5650export function uncurryN<T>(len: number, fn: (a: any) => any): (...args: unknown[]) => T;
5651export function uncurryN<T>(len: number): (fn: (a: any) => any) => (...args: unknown[]) => T;
5652
5653/**
5654 * Builds a list from a seed value.
5655 * Accepts an iterator function, which returns either a falsy value to stop iteration
5656 * or an array of length 2 containing the value to add to the resulting list
5657 * and the seed to be used in the next call to the iterator function.
5658 *
5659 * @example
5660 * ```typescript
5661 * const f = (n: number) => n > 50 ? false : [-n, n + 10] as const;
5662 * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50]
5663 * ```
5664 */
5665export function unfold<T, TResult>(fn: (seed: T) => [TResult, T] | false, seed: T): TResult[];
5666export function unfold<T, TResult>(fn: (seed: T) => [TResult, T] | false): (seed: T) => TResult[];
5667
5668/**
5669 * Combines two lists into a set (i.e. no duplicates) composed of the elements of each list.
5670 *
5671 * @example
5672 * ```typescript
5673 * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4]
5674 * ```
5675 */
5676export function union<T>(as: readonly T[], bs: readonly T[]): T[];
5677export function union<T>(as: readonly T[]): (bs: readonly T[]) => T[];
5678
5679/**
5680 * Combines two lists into a set (i.e. no duplicates) composed of the elements of each list.
5681 * Duplication is determined according to the value returned
5682 * by applying the supplied predicate to two list elements.
5683 * If an element exists in both lists,
5684 * the first element from the first list will be used.
5685 *
5686 * @example
5687 * ```typescript
5688 * const l1 = [{a: 1}, {a: 2}];
5689 * const l2 = [{a: 1}, {a: 4}];
5690 * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}]
5691 * ```
5692 */
5693export function unionWith<T>(pred: (a: T, b: T) => boolean, list1: readonly T[], list2: readonly T[]): T[];
5694export function unionWith<T>(pred: (a: T, b: T) => boolean): _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>;
5695
5696/**
5697 * Returns a new list containing only one copy of each element in the original list.
5698 *
5699 * @example
5700 * ```typescript
5701 * R.uniq([1, 1, 2, 1]); //=> [1, 2]
5702 * R.uniq([1, '1']); //=> [1, '1']
5703 * R.uniq([[42], [42]]); //=> [[42]]
5704 * ```
5705 */
5706export function uniq<T>(list: readonly T[]): T[];
5707
5708/**
5709 * Returns a new list containing only one copy of each element in the original list,
5710 * based upon the value returned by applying the supplied function to each list element.
5711 * Prefers the first item if the supplied function produces the same value on two items.
5712 * `R.equals` is used for comparison.
5713 *
5714 * @example
5715 * ```typescript
5716 * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10]
5717 * ```
5718 */
5719export function uniqBy<T, U>(fn: (a: T) => U, list: readonly T[]): T[];
5720export function uniqBy<T, U>(fn: (a: T) => U): (list: readonly T[]) => T[];
5721
5722/**
5723 * Returns a new list containing only one copy of each element in the original list,
5724 * based upon the value returned by applying the supplied predicate to two list elements.
5725 * Prefers the first item if two items compare equal based on the predicate.
5726 *
5727 * Acts as a transducer if a transformer is given in list position.
5728 *
5729 * See also {@link transduce}.
5730 *
5731 * @example
5732 * ```typescript
5733 * const strEq = R.eqBy(String);
5734 * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2]
5735 * R.uniqWith(strEq)([{}, {}]); //=> [{}]
5736 * R.uniqWith(strEq)([1, '1', 1]); //=> [1]
5737 * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1']
5738 * ```
5739 */
5740export function uniqWith<T, U>(pred: (x: T, y: T) => boolean, list: readonly T[]): T[];
5741export function uniqWith<T, U>(pred: (x: T, y: T) => boolean): (list: readonly T[]) => T[];
5742
5743/**
5744 * Tests the final argument by passing it to the given predicate function.
5745 * If the predicate is not satisfied,
5746 * the function will return the result of calling the `whenFalseFn` function with the same argument.
5747 * If the predicate is satisfied, the argument is returned as is.
5748 *
5749 * See also {@link ifElse}, {@link when}, {@link cond}.
5750 *
5751 * @example
5752 * ```typescript
5753 * let safeInc = R.unless<number | null | undefined, null | undefined>(R.isNil, R.inc);
5754 * safeInc(null); //=> null
5755 * safeInc(1); //=> 2
5756 * ```
5757 */
5758export function unless<T, U>(pred: (a: T) => boolean, whenFalseFn: (a: T) => U, a: T): T | U;
5759export function unless<T, U>(pred: (a: T) => boolean, whenFalseFn: (a: T) => U): (a: T) => T | U;
5760
5761/**
5762 * Shorthand for `R.chain(R.identity)`,
5763 * which removes one level of nesting from any `Chain`.
5764 *
5765 * See also {@link flatten}, {@link chain}.
5766 *
5767 * @example
5768 * ```typescript
5769 * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]]
5770 * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6]
5771 * ```
5772 */
5773export function unnest<T extends readonly any[]>(list: T): _.T.UnNest<T>;
5774
5775/**
5776 * Takes a predicate, a transformation function, and an initial value,
5777 * and returns a value of the same type as the initial value.
5778 * It does so by applying the transformation until the predicate is satisfied,
5779 * at which point it returns the satisfactory value.
5780 *
5781 * @example
5782 * ```typescript
5783 * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
5784 * ```
5785 */
5786export function until<T, U>(pred: (val: T) => boolean, fn: (val: T) => U, init: U): U;
5787export function until<T, U>(pred: (val: T) => boolean, fn: (val: T) => U): (init: U) => U;
5788
5789/**
5790 * Returns a new copy of the array with the element at the provided index replaced with the given value.
5791 *
5792 * See also {@link adjust}.
5793 *
5794 * @example
5795 * ```typescript
5796 * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c']
5797 * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_']
5798 * ```
5799 */
5800export function update<T>(index: number, value: T, list: readonly T[]): T[];
5801export function update<T>(index: number, value: T): (list: readonly T[]) => T[];
5802
5803/**
5804 * Accepts a function fn and a list of transformer functions and returns a new curried function.
5805 * When the new function is invoked,
5806 * it calls the function fn with parameters
5807 * consisting of the result of calling each supplied handler on successive arguments to the new function.
5808 *
5809 * If more arguments are passed to the returned function than transformer functions,
5810 * those arguments are passed directly to fn as additional parameters.
5811 * If you expect additional arguments that don't need to be transformed,
5812 * although you can ignore them,
5813 * it's best to pass an identity function
5814 * so that the new function reports the correct arity.
5815 *
5816 * See also {@link converge}.
5817 *
5818 * @example
5819 * ```typescript
5820 * R.useWith(Math.pow, [(n: number) => n, (n: number) => n])(3, 4); //=> 81
5821 * R.useWith(Math.pow, [(n: number) => n, (n: number) => n])(3)(4); //=> 81
5822 * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32
5823 * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32
5824 * ```
5825 */
5826export function useWith<
5827 TArg1,
5828 TR1,
5829 TArg2,
5830 TR2,
5831 TArg3,
5832 TR3,
5833 TArg4,
5834 TR4,
5835 TArg5,
5836 TR5,
5837 TArg6,
5838 TR6,
5839 TArg7,
5840 TR7,
5841 TResult,
5842 RestFunctions extends AnyFunction[],
5843 TArgs extends [TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, ...InputTypesOfFns<RestFunctions>],
5844>(
5845 fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7, ...ReturnTypesOfFns<RestFunctions>]) => TResult,
5846 transformers: [
5847 (arg: TArg1) => TR1,
5848 (arg: TArg2) => TR2,
5849 (arg: TArg3) => TR3,
5850 (arg: TArg4) => TR4,
5851 (arg: TArg5) => TR5,
5852 (arg: TArg6) => TR6,
5853 (arg: TArg7) => TR7,
5854 ...RestFunctions,
5855 ],
5856): (...args: TArgs) => TResult;
5857export function useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TArg5, TR5, TArg6, TR6, TArg7, TR7, TResult>(
5858 fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7] & { length: 7 }) => TResult,
5859 transformers: [
5860 (arg: TArg1) => TR1,
5861 (arg: TArg2) => TR2,
5862 (arg: TArg3) => TR3,
5863 (arg: TArg4) => TR4,
5864 (arg: TArg5) => TR5,
5865 (arg: TArg6) => TR6,
5866 (arg: TArg7) => TR7,
5867 ],
5868): (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg7]) => TResult;
5869export function useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TArg5, TR5, TArg6, TR6, TResult>(
5870 fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6] & { length: 6 }) => TResult,
5871 transformers: [
5872 (arg: TArg1) => TR1,
5873 (arg: TArg2) => TR2,
5874 (arg: TArg3) => TR3,
5875 (arg: TArg4) => TR4,
5876 (arg: TArg5) => TR5,
5877 (arg: TArg6) => TR6,
5878 ],
5879): (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg6]) => TResult;
5880export function useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TArg5, TR5, TResult>(
5881 fn: (...args: [TR1, TR2, TR3, TR4, TR5] & { length: 5 }) => TResult,
5882 transformers: [
5883 (arg: TArg1) => TR1,
5884 (arg: TArg2) => TR2,
5885 (arg: TArg3) => TR3,
5886 (arg: TArg4) => TR4,
5887 (arg: TArg5) => TR5,
5888 ],
5889): (...args: [TArg1, TArg2, TArg3, TArg4, TArg5]) => TResult;
5890export function useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TResult>(
5891 fn: (...args: [TR1, TR2, TR3, TR4] & { length: 4 }) => TResult,
5892 transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4],
5893): (...args: [TArg1, TArg2, TArg3, TArg4]) => TResult;
5894export function useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TResult>(
5895 fn: (...args: [TR1, TR2, TR3] & { length: 3 }) => TResult,
5896 transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3],
5897): (...args: [TArg1, TArg2, TArg3]) => TResult;
5898export function useWith<TArg1, TR1, TArg2, TR2, TResult>(
5899 fn: (...args: [TR1, TR2] & { length: 2 }) => TResult,
5900 transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2],
5901): (...args: [TArg1, TArg2]) => TResult;
5902export function useWith<TArg1, TR1, TResult>(
5903 fn: (...args: [TR1]) => TResult,
5904 transformers: [(arg: TArg1) => TR1],
5905): (...args: [TArg1]) => TResult;
5906
5907/**
5908 * Returns a list of all the enumerable own properties of the supplied object.
5909 *
5910 * @note The order of the output array is not guaranteed across different JS platforms.
5911 *
5912 * See also {@link valuesIn}, {@link keys}, {@link toPairs}.
5913 *
5914 * @example
5915 * ```typescript
5916 * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3]
5917 * ```
5918 */
5919export function values<T extends object, K extends keyof T>(obj: T): Array<T[K] | ValueOfUnion<T>>;
5920
5921/**
5922 * Returns a list of all the properties, including prototype properties, of the supplied
5923 * object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
5924 *
5925 * See also {@link values}, {@link keysIn}.
5926 *
5927 * @example
5928 * ```typescript
5929 * lass F {
5930 * x: string;
5931 * y = 'Y';
5932 *
5933 * constructor() {
5934 * this.x = 'X';
5935 * }
5936 * }
5937 *
5938 * const f = new F();
5939 * R.valuesIn(f); //=> ['X', 'Y']
5940 * ```
5941 */
5942export function valuesIn<T>(obj: any): T[];
5943
5944/**
5945 * Returns a "view" of the given data structure, determined by the given lens.
5946 * The lens's focus determines which portion of the data structure is visible.
5947 *
5948 * See also {@link set}, {@link over}, {@link lens}, {@link lensIndex}, {@link lensProp}, {@link lensPath}.
5949 *
5950 * @example
5951 * ```typescript
5952 * const xLens = R.lensProp('x');
5953 *
5954 * const a = {x: 1, y: 2};
5955 * R.view(xLens, a); //=> 1
5956 * const b = {x: 4, y: 2};
5957 * R.view(xLens, b); //=> 4
5958 * ```
5959 */
5960export function view<S, A>(lens: Lens<S, A>): (obj: S) => A;
5961export function view<S, A>(lens: Lens<S, A>, obj: S): A;
5962
5963/**
5964 * Tests the final argument by passing it to the given predicate function.
5965 * If the predicate is satisfied,
5966 * the function will return the result of calling the `whenTrueFn` function with the same argument.
5967 * If the predicate is not satisfied, the argument is returned as is.
5968 *
5969 * See also {@link ifElse}, {@link unless}, {@link cond}.
5970 *
5971 * @example
5972 * ```typescript
5973 * // truncate :: String -> String
5974 * const truncate = R.when(
5975 * R.propSatisfies(R.gt(R.__, 10), 'length'),
5976 * R.pipe(R.take(10), R.append('…'), R.join(''))
5977 * );
5978 * truncate('12345'.split('')); //=> '12345'
5979 * truncate('0123456789ABC'.split('')); //=> '0123456789…'
5980 * ```
5981 */
5982export function when<T, U extends T, V>(pred: (a: T) => a is U, whenTrueFn: (a: U) => V, a: T): T | V;
5983export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U, a: T): T | U;
5984export function when<T, U extends T, V>(pred: (a: T) => a is U, whenTrueFn: (a: U) => V): (a: T) => T | V;
5985export function when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U): (a: T) => T | U;
5986
5987/**
5988 * Takes a spec object and a test object and returns true if the test satisfies the spec.
5989 * Any property on the spec that is not a function
5990 * is interpreted as an equality relation.
5991 *
5992 * If the spec has a property mapped to a function,
5993 * then `where` evaluates the function,
5994 * passing in the test object's value for the property in question,
5995 * as well as the whole test object.
5996 *
5997 * `R.where` is well suited to declaratively expressing constraints for other functions,
5998 * e.g., `R.filter`, `R.find`, `R.pickWith`, etc.
5999 *
6000 * Seee also {@link propSatisfies}, {@link whereEq}.
6001 *
6002 * @example
6003 * ```typescript
6004 * // pred :: Object -> Boolean
6005 * const pred = R.where({
6006 * a: R.equals('foo'),
6007 * b: R.complement(R.equals('bar')),
6008 * x: R.gt(R.__, 10),
6009 * y: R.lt(R.__, 20)
6010 * });
6011 *
6012 * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
6013 * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
6014 * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
6015 * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
6016 * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false
6017 * ```
6018 */
6019export function where<T, U>(spec: T, testObj: U): boolean;
6020export function where<T>(spec: T): <U>(testObj: U) => boolean;
6021export function where<ObjFunc2, U>(spec: ObjFunc2, testObj: U): boolean;
6022export function where<ObjFunc2>(spec: ObjFunc2): <U>(testObj: U) => boolean;
6023
6024/**
6025 * Takes a spec object and a test object; returns `true` if the test satisfies the spec, `false` otherwise.
6026 * An object satisfies the spec if, for each of the spec's own properties,
6027 * accessing that property of the object gives the same value (in `R.eq` terms)
6028 * as accessing that property of the spec.
6029 *
6030 * `R.whereEq` is a specialization of `R.where`.
6031 *
6032 * See also {@link propEq}, {@link where}.
6033 *
6034 * @example
6035 * ```typescript
6036 * // pred :: Object -> Boolean
6037 * const pred = R.whereEq({a: 1, b: 2});
6038 *
6039 * pred({a: 1}); //=> false
6040 * pred({a: 1, b: 2}); //=> true
6041 * pred({a: 1, b: 2, c: 3}); //=> true
6042 * pred({a: 1, b: 1}); //=> false
6043 * ```
6044 */
6045export function whereEq<T, U>(spec: T, obj: U): boolean;
6046export function whereEq<T>(spec: T): <U>(obj: U) => boolean;
6047
6048/**
6049 * Returns a new list without values in the first argument.
6050 * `R.equals` is used to determine equality.
6051 * Acts as a transducer if a transformer is given in list position.
6052 *
6053 * See also {@link transduce}, {@link difference}, {@link remove}.
6054 *
6055 * @example
6056 * ```typescript
6057 * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4]
6058 * ```
6059 */
6060export function without<T>(list1: readonly unknown[], list2: readonly T[]): T[];
6061export function without<T>(list1: readonly T[] | readonly unknown[]): (list2: readonly T[]) => T[];
6062
6063/**
6064 * Exclusive disjunction logical operation.
6065 * Returns `true` if one of the arguments is truthy and the other is falsy.
6066 * Otherwise, it returns `false`.
6067 *
6068 * See also {@link or}, {@link and}.
6069 *
6070 * @example
6071 * ```typescript
6072 * R.xor(true, true); //=> false
6073 * R.xor(true, false); //=> true
6074 * R.xor(false, true); //=> true
6075 * R.xor(false, false); //=> false
6076 * ```
6077 */
6078export function xor(a: any, b: any): boolean;
6079export function xor(a: any): (b: any) => boolean;
6080
6081/**
6082 * Creates a new list out of the two supplied by creating each possible pair from the lists
6083 *
6084 * Short for cross product.
6085 *
6086 * @example
6087 * ```typescript
6088 * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
6089 * ```
6090 */
6091export function xprod<K, V>(as: readonly K[], bs: readonly V[]): Array<KeyValuePair<K, V>>;
6092export function xprod<K>(as: readonly K[]): <V>(bs: readonly V[]) => Array<KeyValuePair<K, V>>;
6093
6094/**
6095 * Creates a new list out of the two supplied
6096 * by pairing up equally-positioned items from both lists.
6097 * The returned list is truncated
6098 * to the length of the shorter of the two input lists.
6099 *
6100 * @note `R.zip` is equivalent to `R.zipWith((a, b) => [a, b] as const)`.
6101 *
6102 * @example
6103 * ```typescript
6104 * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]
6105 * ```
6106 */
6107export function zip<K, V>(list1: readonly K[], list2: readonly V[]): Array<KeyValuePair<K, V>>;
6108export function zip<K>(list1: readonly K[]): <V>(list2: readonly V[]) => Array<KeyValuePair<K, V>>;
6109
6110/**
6111 * Creates a new object out of a list of keys and a list of values.
6112 * Key/value pairing is truncated to the length of the shorter of the two lists.
6113 *
6114 * @note `R.zipObj` is equivalent to `R.pipe(R.zip, R.fromPairs)`.
6115 *
6116 * @example
6117 * ```typescript
6118 * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3}
6119 * ```
6120 */
6121// TODO: Dictionary<T> as a return value is to specific, any seems to loose
6122export function zipObj<T, K extends string>(keys: readonly K[], values: readonly T[]): { [P in K]: T };
6123export function zipObj<K extends string>(keys: readonly K[]): <T>(values: readonly T[]) => { [P in K]: T };
6124export function zipObj<T, K extends number>(keys: readonly K[], values: readonly T[]): { [P in K]: T };
6125export function zipObj<K extends number>(keys: readonly K[]): <T>(values: readonly T[]) => { [P in K]: T };
6126
6127/**
6128 * Creates a new list out of the two supplied
6129 * by applying the function to each equally-positioned pair in the lists.
6130 *
6131 * @example
6132 * ```typescript
6133 * const f = (x: number, y: string) => [x, y] as const;
6134 * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']);
6135 * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')]
6136 * ```
6137 */
6138export function zipWith<T, U, TResult>(
6139 fn: (x: T, y: U) => TResult,
6140 list1: readonly T[],
6141 list2: readonly U[],
6142): TResult[];
6143export function zipWith<T, U, TResult>(
6144 fn: (x: T, y: U) => TResult,
6145 list1: readonly T[],
6146): (list2: readonly U[]) => TResult[];
6147export function zipWith<T, U, TResult>(
6148 fn: (x: T, y: U) => TResult,
6149): (list1: readonly T[], list2: readonly U[]) => TResult[];
6150
6151/**
6152 * Creates a copy of the passed object by applying an fn function to the given prop property.
6153 * The function will not be invoked, and the object will not change if its corresponding property does not exist in the object.
6154 * All non-primitive properties are copied to the new object by reference.
6155 *
6156 * @example
6157 * ```typescript
6158 * const person = {name: 'James', age: 20, pets: ['dog', 'cat']};
6159 * R.modify('age', R.add(1), person); //=> {name: 'James', age: 21, pets: ['dog', 'cat']}
6160 * R.modify('pets', R.append('turtle'), person); //=> {name: 'James', age: 20, pets: ['dog', 'cat', 'turtle']}
6161 * ```
6162 */
6163export function modify<T extends object, K extends keyof T, P>(
6164 prop: K,
6165 fn: (a: T[K]) => P,
6166 obj: T,
6167): Omit<T, K> & Record<K, P>;
6168export function modify<K extends string, A, P>(
6169 prop: K,
6170 fn: (a: A) => P,
6171): <T extends Record<K, A>>(target: T) => Omit<T, K> & Record<K, P>;
6172
6173export as namespace R;