riot-web/src/utils/iterables.ts

18 lines
597 B
TypeScript
Raw Normal View History

/*
* Copyright 2024 New Vector Ltd.
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
* Please see LICENSE files in the repository root for full details.
*/
2022-07-11 07:52:44 +02:00
import { arrayDiff, arrayIntersection } from "./arrays";
2020-11-18 04:38:59 +01:00
export function iterableIntersection<T>(a: Iterable<T>, b: Iterable<T>): Iterable<T> {
return arrayIntersection(Array.from(a), Array.from(b));
}
2022-12-12 12:24:14 +01:00
export function iterableDiff<T>(a: Iterable<T>, b: Iterable<T>): { added: Iterable<T>; removed: Iterable<T> } {
2020-11-18 04:38:59 +01:00
return arrayDiff(Array.from(a), Array.from(b));
}