( items: ReadonlyArray<T>, predicate: (item: T) => boolean, )
| 261 | * in which the predicate returned true, the second where it returned false. |
| 262 | */ |
| 263 | export function bisectArray<T>( |
| 264 | items: ReadonlyArray<T>, |
| 265 | predicate: (item: T) => boolean, |
| 266 | ): [T[], T[]] { |
| 267 | const a: T[] = []; |
| 268 | const b: T[] = []; |
| 269 | for (const item of items) { |
| 270 | if (predicate(item)) { |
| 271 | a.push(item); |
| 272 | } else { |
| 273 | b.push(item); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | return [a, b]; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Flattens an array of arrays into a single-dimensional array. |
no test coverage detected