From 4909c78bb98b786c540abcf5cc3573a827bff47a Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Mon, 15 Aug 2022 01:24:42 -0700 Subject: [PATCH] Make `groupConsecutive` more capable --- common/util/array.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/util/array.ts b/common/util/array.ts index 8a429262..fd5efcc6 100644 --- a/common/util/array.ts +++ b/common/util/array.ts @@ -1,3 +1,5 @@ +import { isEqual } from 'lodash' + export function filterDefined(array: (T | null | undefined)[]) { return array.filter((item) => item !== null && item !== undefined) as T[] } @@ -26,7 +28,7 @@ export function groupConsecutive(xs: T[], key: (x: T) => U) { let curr = { key: key(xs[0]), items: [xs[0]] } for (const x of xs.slice(1)) { const k = key(x) - if (k !== curr.key) { + if (!isEqual(key, curr.key)) { result.push(curr) curr = { key: k, items: [x] } } else {