summaryrefslogtreecommitdiff
path: root/src/prelude/array.ts
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2018-12-19 16:59:43 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2018-12-19 17:00:07 +0900
commit78ec06bda3185896119378c851661322d0937a86 (patch)
treeb47db38140aa955fc2763f4165b713d79f1b618d /src/prelude/array.ts
parentUpdate deck.notes.vue (diff)
downloadmisskey-78ec06bda3185896119378c851661322d0937a86.tar.gz
misskey-78ec06bda3185896119378c851661322d0937a86.tar.bz2
misskey-78ec06bda3185896119378c851661322d0937a86.zip
Add relation types
Diffstat (limited to 'src/prelude/array.ts')
-rw-r--r--src/prelude/array.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/prelude/array.ts b/src/prelude/array.ts
index 21d18a0af4..7eee87bf8b 100644
--- a/src/prelude/array.ts
+++ b/src/prelude/array.ts
@@ -1,3 +1,5 @@
+import { EndoRelation } from "./relation";
+
/**
* Count the number of elements that satisfy the predicate
*/
@@ -61,7 +63,7 @@ export function maximum(xs: number[]): number {
* Splits an array based on the equivalence relation.
* The concatenation of the result is equal to the argument.
*/
-export function groupBy<T>(f: (x: T, y: T) => boolean, xs: T[]): T[][] {
+export function groupBy<T>(f: EndoRelation<T>, xs: T[]): T[][] {
const groups = [] as T[][];
for (const x of xs) {
if (groups.length !== 0 && f(groups[groups.length - 1][0], x)) {