( arr: T[], isLeft: (_: T) => _ is TLeft, )
| 45 | } |
| 46 | |
| 47 | export const partition = <T, TLeft extends T>( |
| 48 | arr: T[], |
| 49 | isLeft: (_: T) => _ is TLeft, |
| 50 | ): [TLeft[], Exclude<T, TLeft>[]] => { |
| 51 | return arr.reduce( |
| 52 | (acc, el) => { |
| 53 | if (isLeft(el)) { |
| 54 | acc[0]!.push(el) |
| 55 | } else { |
| 56 | acc[1]!.push(el as Exclude<T, TLeft>) |
| 57 | } |
| 58 | return acc as any |
| 59 | }, |
| 60 | [[], []] as [TLeft[], Exclude<T, TLeft>[]], |
| 61 | ) |
| 62 | } |
| 63 | |
| 64 | export const not = |
| 65 | <T, TGuarded extends T>(guard: (_: T) => _ is TGuarded) => |
no outgoing calls
no test coverage detected
searching dependent graphs…