Skip to content

Commit a7a89c1

Browse files
committed
add comment to partition helper function
1 parent 32d2ba3 commit a7a89c1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/core/src/shared/utilities/tsUtils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ export function createFactoryFunction<T extends new (...args: any[]) => any>(cto
9494
return (...args) => new ctor(...args)
9595
}
9696

97+
/**
98+
* Split a list into two sublists based on the result of a predicate.
99+
* @param lst list to split
100+
* @param pred predicate to apply to each element
101+
* @returns two nested lists, where for all items x in the left sublist, pred(x) returns true. The remaining elements are in the right sublist.
102+
*/
97103
export function partition<T>(lst: T[], pred: (arg: T) => boolean): [T[], T[]] {
98104
return lst.reduce(
99105
([leftAcc, rightAcc], item) => {

0 commit comments

Comments
 (0)