We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32d2ba3 commit a7a89c1Copy full SHA for a7a89c1
packages/core/src/shared/utilities/tsUtils.ts
@@ -94,6 +94,12 @@ export function createFactoryFunction<T extends new (...args: any[]) => any>(cto
94
return (...args) => new ctor(...args)
95
}
96
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
+ */
103
export function partition<T>(lst: T[], pred: (arg: T) => boolean): [T[], T[]] {
104
return lst.reduce(
105
([leftAcc, rightAcc], item) => {
0 commit comments