mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-10 05:58:01 -05:00
15 lines
297 B
TypeScript
15 lines
297 B
TypeScript
export function groupBy<T>(array: T[], predicate: (T) => boolean) {
|
|
const trueElements = [];
|
|
const falseElements = [];
|
|
|
|
array?.forEach(e => {
|
|
if (predicate(e)) {
|
|
trueElements.push(e);
|
|
} else {
|
|
falseElements.push(e);
|
|
}
|
|
});
|
|
|
|
return [trueElements, falseElements];
|
|
}
|