-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
19 lines (18 loc) · 762 Bytes
/
index.ts
File metadata and controls
19 lines (18 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import reduceValues from "@unction/reducevalues";
import upTo from "@unction/upto";
import {MapperFunctionType} from "./types";
export default function nestedApply<A, B> (iterator: (a: MapperFunctionType<A, B>) => (b: Array<A> | Set<A> | Record<string | number | symbol, B> | Map<B, A> | string) => Array<B> | Set<B> | Record<string | number | symbol, unknown> | Map<B, unknown> | string) {
return function nestedApplyIterator (unction: MapperFunctionType<A, B>) {
return function nestedApplyIteratorUnction (depth: number) {
return reduceValues(
(accumulatedUnction: MapperFunctionType<A, B>) =>
() =>
iterator(accumulatedUnction)
)(
iterator(unction)
)(
upTo(depth)
);
};
};
}