-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
26 lines (25 loc) · 912 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import reduceWithValueKey from "@unction/reducewithvaluekey";
import ifThenElse from "@unction/ifthenelse";
import equals from "@unction/equals";
import always from "@unction/always";
import attach from "@unction/attach";
import fresh from "@unction/fresh";
export default function exceptKey<A, B> (key: B) {
return function exceptKeyKey (keyedList: Array<A> | Set<A> | Record<string | number | symbol, B> | Map<B, A> | string): Array<A> | Set<A> | Record<string | number | symbol, B> | Map<B, A> | string {
return reduceWithValueKey(
(accumulated: Array<A> | Set<A> | Record<string | number | symbol, B> | Map<B, A> | string) =>
(value: A) =>
ifThenElse(
equals(key)
)(
always(accumulated)
)(
(current: A) => attach(current)(value)(accumulated)
)
)(
fresh(keyedList)
)(
keyedList
);
};
}