rambda 10.1.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +125 -10
- package/README.md +1021 -259
- package/dist/rambda.cjs +167 -73
- package/dist/rambda.js +162 -74
- package/dist/rambda.umd.js +167 -73
- package/index.d.cts +179 -44
- package/index.d.ts +179 -44
- package/package.json +8 -8
- package/rambda.js +6 -0
- package/src/duplicateBy.js +9 -0
- package/src/filterAsync.js +14 -0
- package/src/indexBy.js +14 -0
- package/src/mapAsync.js +2 -2
- package/src/mapPropObject.js +10 -0
- package/src/modifyPath.js +30 -0
- package/src/replaceAll.js +10 -0
package/index.d.cts
CHANGED
|
@@ -95,10 +95,10 @@ type Flatten<T> = T extends object
|
|
|
95
95
|
[K in keyof T]-?: NonNullable<T[K]> extends infer V
|
|
96
96
|
? V extends object
|
|
97
97
|
? V extends readonly any[]
|
|
98
|
-
? never
|
|
98
|
+
? never
|
|
99
99
|
: Flatten<V>
|
|
100
100
|
: V
|
|
101
|
-
: never
|
|
101
|
+
: never
|
|
102
102
|
}
|
|
103
103
|
: T;
|
|
104
104
|
|
|
@@ -109,17 +109,17 @@ export type FlattenObject<T extends object> = object extends T
|
|
|
109
109
|
x: NonNullable<T[K]> extends infer V
|
|
110
110
|
? V extends object
|
|
111
111
|
? V extends readonly any[]
|
|
112
|
-
? never
|
|
112
|
+
? never
|
|
113
113
|
: Flatten<V> extends infer FV
|
|
114
114
|
? {
|
|
115
115
|
[P in keyof FV as `${Extract<K, string>}.${Extract<P, string>}`]: FV[P]
|
|
116
116
|
}
|
|
117
|
-
: never
|
|
117
|
+
: never
|
|
118
118
|
: Pick<T, K>
|
|
119
|
-
: never
|
|
119
|
+
: never
|
|
120
120
|
) => void
|
|
121
121
|
} extends Record<keyof T, (y: infer O) => void>
|
|
122
|
-
? O
|
|
122
|
+
? O
|
|
123
123
|
: never;
|
|
124
124
|
|
|
125
125
|
/**
|
|
@@ -295,6 +295,8 @@ export function dropRepeatsWith<T>(predicate: (x: T, y: T) => boolean): (list: T
|
|
|
295
295
|
export function dropWhile<T>(predicate: (x: T, index: number) => boolean): (list: T[]) => T[];
|
|
296
296
|
export function dropWhile<T>(predicate: (x: T) => boolean): (list: T[]) => T[];
|
|
297
297
|
|
|
298
|
+
export function duplicateBy<T, U>(fn: (x: T) => U): (list: T[]) => T[];
|
|
299
|
+
|
|
298
300
|
export function eqBy<T>(fn: (x: T) => unknown, a: T): (b: T) => boolean;
|
|
299
301
|
|
|
300
302
|
/**
|
|
@@ -340,6 +342,10 @@ export function filter<T>(
|
|
|
340
342
|
predicate: (value: T) => boolean,
|
|
341
343
|
): (list: T[]) => T[];
|
|
342
344
|
|
|
345
|
+
export function filterAsync<T>(
|
|
346
|
+
predicate: (value: T) => Promise<boolean>,
|
|
347
|
+
): (list: T[]) => Promise<T[]>;
|
|
348
|
+
|
|
343
349
|
/**
|
|
344
350
|
* It loops over each property of `obj` and returns a new object with only those properties that satisfy the `predicate`.
|
|
345
351
|
*/
|
|
@@ -408,13 +414,13 @@ export function groupBy<T, K extends string = string>(fn: (x: T) => K): (list: T
|
|
|
408
414
|
/**
|
|
409
415
|
* It returns the first element of list or string `input`. It returns `undefined` if array has length of 0.
|
|
410
416
|
*/
|
|
411
|
-
export function head<T>(listOrString: T): T extends string ? string :
|
|
412
|
-
T extends [] ? undefined:
|
|
413
|
-
T extends readonly [infer F, ...infer R] ? F :
|
|
417
|
+
export function head<T>(listOrString: T): T extends string ? string :
|
|
418
|
+
T extends [] ? undefined:
|
|
419
|
+
T extends readonly [infer F, ...infer R] ? F :
|
|
414
420
|
T extends readonly [infer F] ? F :
|
|
415
421
|
T extends [infer F] ? F :
|
|
416
|
-
T extends [infer F, ...infer R] ? F :
|
|
417
|
-
T extends unknown[] ? T[number] :
|
|
422
|
+
T extends [infer F, ...infer R] ? F :
|
|
423
|
+
T extends unknown[] ? T[number] :
|
|
418
424
|
undefined;
|
|
419
425
|
|
|
420
426
|
/**
|
|
@@ -425,6 +431,19 @@ export function head<T>(listOrString: T): T extends string ? string :
|
|
|
425
431
|
export function includes<T extends string>(valueToFind: T): (input: string) => boolean;
|
|
426
432
|
export function includes<T>(valueToFind: T): (input: T[]) => boolean;
|
|
427
433
|
|
|
434
|
+
/**
|
|
435
|
+
* It transforms list of objects to object using specified property as the base for the returned object.
|
|
436
|
+
*/
|
|
437
|
+
export function indexBy<T, K extends keyof T>(
|
|
438
|
+
property: K
|
|
439
|
+
): (list: readonly T[]) => Record<string, T>;
|
|
440
|
+
export function indexBy<T, K extends keyof T>(
|
|
441
|
+
property: K
|
|
442
|
+
): (list: T[]) => Record<string, T>;
|
|
443
|
+
|
|
444
|
+
// API_MARKER_END
|
|
445
|
+
// ============================================
|
|
446
|
+
|
|
428
447
|
/**
|
|
429
448
|
* It uses `R.equals` for list of objects/arrays or native `indexOf` for any other case.
|
|
430
449
|
*/
|
|
@@ -449,10 +468,6 @@ export function innerJoin<T1, T2>(
|
|
|
449
468
|
*/
|
|
450
469
|
export function interpolate(inputWithTags: string): (templateArguments: object) => string;
|
|
451
470
|
|
|
452
|
-
|
|
453
|
-
// API_MARKER_END
|
|
454
|
-
// ===========================================
|
|
455
|
-
|
|
456
471
|
/**
|
|
457
472
|
* It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.
|
|
458
473
|
*/
|
|
@@ -471,13 +486,13 @@ export function join<T>(glue: string): (list: T[]) => string;
|
|
|
471
486
|
/**
|
|
472
487
|
* It returns the last element of `input`, as the `input` can be either a string or an array. It returns `undefined` if array has length of 0.
|
|
473
488
|
*/
|
|
474
|
-
export function last<T>(listOrString: T): T extends string ? string :
|
|
475
|
-
T extends [] ? undefined :
|
|
476
|
-
T extends readonly [...infer R, infer L] ? L :
|
|
489
|
+
export function last<T>(listOrString: T): T extends string ? string :
|
|
490
|
+
T extends [] ? undefined :
|
|
491
|
+
T extends readonly [...infer R, infer L] ? L :
|
|
477
492
|
T extends readonly [infer L] ? L :
|
|
478
493
|
T extends [infer L] ? L :
|
|
479
|
-
T extends [...infer R, infer L] ? L :
|
|
480
|
-
T extends unknown[] ? T[number] :
|
|
494
|
+
T extends [...infer R, infer L] ? L :
|
|
495
|
+
T extends unknown[] ? T[number] :
|
|
481
496
|
undefined;
|
|
482
497
|
|
|
483
498
|
/**
|
|
@@ -518,14 +533,6 @@ export function mapAsync<T extends IterableContainer, U>(
|
|
|
518
533
|
export function mapAsync<T extends IterableContainer, U>(
|
|
519
534
|
fn: (value: T[number]) => Promise<U>,
|
|
520
535
|
): (data: T) => Promise<Mapped<T, U>>;
|
|
521
|
-
export function mapAsync<T extends IterableContainer, U>(
|
|
522
|
-
fn: (value: T[number], index: number) => Promise<U>,
|
|
523
|
-
data: T
|
|
524
|
-
): Promise<Mapped<T, U>>;
|
|
525
|
-
export function mapAsync<T extends IterableContainer, U>(
|
|
526
|
-
fn: (value: T[number]) => Promise<U>,
|
|
527
|
-
data: T
|
|
528
|
-
): Promise<Mapped<T, U>>;
|
|
529
536
|
|
|
530
537
|
/**
|
|
531
538
|
* It returns a copy of `obj` with keys transformed by `fn`.
|
|
@@ -557,14 +564,19 @@ export function mapParallelAsync<T extends IterableContainer, U>(
|
|
|
557
564
|
export function mapParallelAsync<T extends IterableContainer, U>(
|
|
558
565
|
fn: (value: T[number]) => Promise<U>,
|
|
559
566
|
): (data: T) => Promise<Mapped<T, U>>;
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
export function
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* It maps over a property of object that is a list.
|
|
570
|
+
*/
|
|
571
|
+
export function mapPropObject<T extends object, K extends keyof T, Value>(
|
|
572
|
+
valueMapper: (
|
|
573
|
+
value: T[K] extends ReadonlyArray<infer ElementType> ? ElementType : never,
|
|
574
|
+
data: T[K],
|
|
575
|
+
) => Value,
|
|
576
|
+
prop: K,
|
|
577
|
+
): (data: T) => T[K] extends ReadonlyArray<any>
|
|
578
|
+
? MergeTypes<Omit<T, K> & { [P in K]: Value[] }>
|
|
579
|
+
: never;
|
|
568
580
|
|
|
569
581
|
/**
|
|
570
582
|
* Curried version of `String.prototype.match` which returns empty array, when there is no match.
|
|
@@ -597,6 +609,123 @@ export function minBy<T>(compareFn: (input: T) => Ord, x: T): (y: T) => T;
|
|
|
597
609
|
*/
|
|
598
610
|
export function modifyItemAtIndex<T>(index: number, replaceFn: (x: T) => T): (list: T[]) => T[];
|
|
599
611
|
|
|
612
|
+
/**
|
|
613
|
+
* It changes a property of object on the base of provided path and transformer function.
|
|
614
|
+
*/
|
|
615
|
+
export function modifyPath<U, T>(path: [], fn: (value: U) => T): (obj: U) => T;
|
|
616
|
+
export function modifyPath<
|
|
617
|
+
K0 extends keyof U,
|
|
618
|
+
U,
|
|
619
|
+
T
|
|
620
|
+
>(path: [K0], fn: (value: U[K0]) => T): (obj: U) => DeepModify<[K0], U, T>;
|
|
621
|
+
export function modifyPath<
|
|
622
|
+
K0 extends string & keyof U,
|
|
623
|
+
U,
|
|
624
|
+
T
|
|
625
|
+
>(path: `${K0}`, fn: (value: U[K0]) => T): (obj: U) => DeepModify<[K0], U, T>;
|
|
626
|
+
export function modifyPath<
|
|
627
|
+
K0 extends keyof U,
|
|
628
|
+
K1 extends keyof U[K0],
|
|
629
|
+
U,
|
|
630
|
+
T
|
|
631
|
+
>(path: [K0, K1], fn: (value: U[K0][K1]) => T): (obj: U) => DeepModify<[K0, K1], U, T>;
|
|
632
|
+
export function modifyPath<
|
|
633
|
+
K0 extends string & keyof U,
|
|
634
|
+
K1 extends string & keyof U[K0],
|
|
635
|
+
U,
|
|
636
|
+
T
|
|
637
|
+
>(path: `${K0}.${K1}`, fn: (value: U[K0][K1]) => T): (obj: U) => DeepModify<[K0, K1], U, T>;
|
|
638
|
+
export function modifyPath<
|
|
639
|
+
K0 extends keyof U,
|
|
640
|
+
K1 extends keyof U[K0],
|
|
641
|
+
K2 extends keyof U[K0][K1],
|
|
642
|
+
U,
|
|
643
|
+
T
|
|
644
|
+
>(path: [K0, K1, K2], fn: (value: U[K0][K1][K2]) => T): (obj: U) => DeepModify<[K0, K1, K2], U, T>;
|
|
645
|
+
export function modifyPath<
|
|
646
|
+
K0 extends string & keyof U,
|
|
647
|
+
K1 extends string & keyof U[K0],
|
|
648
|
+
K2 extends string & keyof U[K0][K1],
|
|
649
|
+
U,
|
|
650
|
+
T
|
|
651
|
+
>(path: `${K0}.${K1}.${K2}`, fn: (value: U[K0][K1][K2]) => T): (obj: U) => DeepModify<[K0, K1, K2], U, T>;
|
|
652
|
+
export function modifyPath<
|
|
653
|
+
K0 extends keyof U,
|
|
654
|
+
K1 extends keyof U[K0],
|
|
655
|
+
K2 extends keyof U[K0][K1],
|
|
656
|
+
K3 extends keyof U[K0][K1][K2],
|
|
657
|
+
U,
|
|
658
|
+
T
|
|
659
|
+
>(path: [K0, K1, K2, K3], fn: (value: U[K0][K1][K2][K3]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3], U, T>;
|
|
660
|
+
export function modifyPath<
|
|
661
|
+
K0 extends string & keyof U,
|
|
662
|
+
K1 extends string & keyof U[K0],
|
|
663
|
+
K2 extends string & keyof U[K0][K1],
|
|
664
|
+
K3 extends string & keyof U[K0][K1][K2],
|
|
665
|
+
U,
|
|
666
|
+
T
|
|
667
|
+
>(path: `${K0}.${K1}.${K2}.${K3}`, fn: (value: U[K0][K1][K2][K3]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3], U, T>;
|
|
668
|
+
export function modifyPath<
|
|
669
|
+
K0 extends keyof U,
|
|
670
|
+
K1 extends keyof U[K0],
|
|
671
|
+
K2 extends keyof U[K0][K1],
|
|
672
|
+
K3 extends keyof U[K0][K1][K2],
|
|
673
|
+
K4 extends keyof U[K0][K1][K2][K3],
|
|
674
|
+
U,
|
|
675
|
+
T
|
|
676
|
+
>(path: [K0, K1, K2, K3, K4], fn: (value: U[K0][K1][K2][K3][K4]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3, K4], U, T>;
|
|
677
|
+
export function modifyPath<
|
|
678
|
+
K0 extends string & keyof U,
|
|
679
|
+
K1 extends string & keyof U[K0],
|
|
680
|
+
K2 extends string & keyof U[K0][K1],
|
|
681
|
+
K3 extends string & keyof U[K0][K1][K2],
|
|
682
|
+
K4 extends string & keyof U[K0][K1][K2][K3],
|
|
683
|
+
U,
|
|
684
|
+
T
|
|
685
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}`, fn: (value: U[K0][K1][K2][K3][K4]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3, K4], U, T>;
|
|
686
|
+
export function modifyPath<
|
|
687
|
+
K0 extends keyof U,
|
|
688
|
+
K1 extends keyof U[K0],
|
|
689
|
+
K2 extends keyof U[K0][K1],
|
|
690
|
+
K3 extends keyof U[K0][K1][K2],
|
|
691
|
+
K4 extends keyof U[K0][K1][K2][K3],
|
|
692
|
+
K5 extends keyof U[K0][K1][K2][K3][K4],
|
|
693
|
+
U,
|
|
694
|
+
T
|
|
695
|
+
>(path: [K0, K1, K2, K3, K4, K5], fn: (value: U[K0][K1][K2][K3][K4][K5]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3, K4, K5], U, T>;
|
|
696
|
+
export function modifyPath<
|
|
697
|
+
K0 extends string & keyof U,
|
|
698
|
+
K1 extends string & keyof U[K0],
|
|
699
|
+
K2 extends string & keyof U[K0][K1],
|
|
700
|
+
K3 extends string & keyof U[K0][K1][K2],
|
|
701
|
+
K4 extends string & keyof U[K0][K1][K2][K3],
|
|
702
|
+
K5 extends string & keyof U[K0][K1][K2][K3][K4],
|
|
703
|
+
U,
|
|
704
|
+
T
|
|
705
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}`, fn: (value: U[K0][K1][K2][K3][K4][K5]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3, K4, K5], U, T>;
|
|
706
|
+
export function modifyPath<
|
|
707
|
+
K0 extends keyof U,
|
|
708
|
+
K1 extends keyof U[K0],
|
|
709
|
+
K2 extends keyof U[K0][K1],
|
|
710
|
+
K3 extends keyof U[K0][K1][K2],
|
|
711
|
+
K4 extends keyof U[K0][K1][K2][K3],
|
|
712
|
+
K5 extends keyof U[K0][K1][K2][K3][K4],
|
|
713
|
+
K6 extends keyof U[K0][K1][K2][K3][K4][K5],
|
|
714
|
+
U,
|
|
715
|
+
T
|
|
716
|
+
>(path: [K0, K1, K2, K3, K4, K5, K6], fn: (value: U[K0][K1][K2][K3][K4][K5][K6]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3, K4, K5, K6], U, T>;
|
|
717
|
+
export function modifyPath<
|
|
718
|
+
K0 extends string & keyof U,
|
|
719
|
+
K1 extends string & keyof U[K0],
|
|
720
|
+
K2 extends string & keyof U[K0][K1],
|
|
721
|
+
K3 extends string & keyof U[K0][K1][K2],
|
|
722
|
+
K4 extends string & keyof U[K0][K1][K2][K3],
|
|
723
|
+
K5 extends string & keyof U[K0][K1][K2][K3][K4],
|
|
724
|
+
K6 extends string & keyof U[K0][K1][K2][K3][K4][K5],
|
|
725
|
+
U,
|
|
726
|
+
T
|
|
727
|
+
>(path: `${K0}.${K1}.${K2}.${K3}.${K4}.${K5}.${K6}`, fn: (value: U[K0][K1][K2][K3][K4][K5][K6]) => T): (obj: U) => DeepModify<[K0, K1, K2, K3, K4, K5, K6], U, T>;
|
|
728
|
+
|
|
600
729
|
/**
|
|
601
730
|
* It changes a property with the result of transformer function.
|
|
602
731
|
*/
|
|
@@ -1450,7 +1579,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M>(
|
|
|
1450
1579
|
fn10: (x: Awaited<K>) => L,
|
|
1451
1580
|
fn11: (x: Awaited<L>) => M,
|
|
1452
1581
|
): M;
|
|
1453
|
-
|
|
1454
1582
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(
|
|
1455
1583
|
input: A,
|
|
1456
1584
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1467,7 +1595,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(
|
|
|
1467
1595
|
fn11: (x: Awaited<L>) => M,
|
|
1468
1596
|
fn12: (x: Awaited<M>) => N,
|
|
1469
1597
|
): N;
|
|
1470
|
-
|
|
1471
1598
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(
|
|
1472
1599
|
input: A,
|
|
1473
1600
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1485,7 +1612,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(
|
|
|
1485
1612
|
fn12: (x: Awaited<M>) => N,
|
|
1486
1613
|
fn13: (x: Awaited<N>) => O,
|
|
1487
1614
|
): O;
|
|
1488
|
-
|
|
1489
1615
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(
|
|
1490
1616
|
input: A,
|
|
1491
1617
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1504,7 +1630,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(
|
|
|
1504
1630
|
fn13: (x: Awaited<N>) => O,
|
|
1505
1631
|
fn14: (x: Awaited<O>) => P,
|
|
1506
1632
|
): P;
|
|
1507
|
-
|
|
1508
1633
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(
|
|
1509
1634
|
input: A,
|
|
1510
1635
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1524,7 +1649,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(
|
|
|
1524
1649
|
fn14: (x: Awaited<O>) => P,
|
|
1525
1650
|
fn15: (x: Awaited<P>) => Q,
|
|
1526
1651
|
): Q;
|
|
1527
|
-
|
|
1528
1652
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(
|
|
1529
1653
|
input: A,
|
|
1530
1654
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1545,7 +1669,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(
|
|
|
1545
1669
|
fn15: (x: Awaited<P>) => Q,
|
|
1546
1670
|
fn16: (x: Awaited<Q>) => R,
|
|
1547
1671
|
): R;
|
|
1548
|
-
|
|
1549
1672
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(
|
|
1550
1673
|
input: A,
|
|
1551
1674
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1567,7 +1690,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R,
|
|
|
1567
1690
|
fn16: (x: Awaited<Q>) => R,
|
|
1568
1691
|
fn17: (x: Awaited<R>) => S,
|
|
1569
1692
|
): S;
|
|
1570
|
-
|
|
1571
1693
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(
|
|
1572
1694
|
input: A,
|
|
1573
1695
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1590,7 +1712,6 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R,
|
|
|
1590
1712
|
fn17: (x: Awaited<R>) => S,
|
|
1591
1713
|
fn18: (x: Awaited<S>) => T,
|
|
1592
1714
|
): T;
|
|
1593
|
-
|
|
1594
1715
|
export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U>(
|
|
1595
1716
|
input: A,
|
|
1596
1717
|
fn0: (x: Awaited<A>) => B,
|
|
@@ -1620,6 +1741,10 @@ export function pipeAsync<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R,
|
|
|
1620
1741
|
* Basically, this is `R.map(R.prop(property))`.
|
|
1621
1742
|
*/
|
|
1622
1743
|
export function pluck<T, K extends keyof T>(property: K): (list: T[]) => T[K][];
|
|
1744
|
+
export function pluck<K extends PropertyKey>(prop: K): {
|
|
1745
|
+
<U extends O[keyof O], UK extends keyof U, O extends Record<string, any>>(obj: K extends UK ? O : never): { [OK in keyof O]: O[OK][K] };
|
|
1746
|
+
<U extends readonly unknown[] | Record<K, any>>(list: readonly U[]): U extends readonly (infer T)[] ? T[] : U extends Record<K, infer T> ? T[] : never;
|
|
1747
|
+
};
|
|
1623
1748
|
|
|
1624
1749
|
/**
|
|
1625
1750
|
* It adds element `x` at the beginning of `list`.
|
|
@@ -1696,6 +1821,11 @@ export function rejectObject<T extends object>(
|
|
|
1696
1821
|
*/
|
|
1697
1822
|
export function replace(strOrRegex: RegExp | string, replacer: RegExp | string): (str: string) => string;
|
|
1698
1823
|
|
|
1824
|
+
/**
|
|
1825
|
+
* Same as `R.replace` but it accepts array of string and regular expressions instead of a single value.
|
|
1826
|
+
*/
|
|
1827
|
+
export function replaceAll(patterns: (RegExp | string)[], replacer: string): (input: string) => string;
|
|
1828
|
+
|
|
1699
1829
|
/**
|
|
1700
1830
|
* It returns a randomized copy of array.
|
|
1701
1831
|
*/
|
|
@@ -2114,6 +2244,11 @@ export function tap<T>(fn: (x: T) => void): (input: T) => T;
|
|
|
2114
2244
|
*/
|
|
2115
2245
|
export function test(regExpression: RegExp): (str: string) => boolean;
|
|
2116
2246
|
|
|
2247
|
+
export function transformPropObject<T extends object, K extends keyof T, Value>(
|
|
2248
|
+
valueMapper: (value: T[K]) => Value,
|
|
2249
|
+
prop: K,
|
|
2250
|
+
): (data: T) => MergeTypes<Omit<T, K> & { [P in K]: Value }>;
|
|
2251
|
+
|
|
2117
2252
|
/**
|
|
2118
2253
|
* It returns function that runs `fn` in `try/catch` block. If there was an error, then `fallback` is used to return the result.
|
|
2119
2254
|
*/
|