Play items from a set, skipping ones that do not change
function distinctUntilKeyChanged(keySelector) {
    return function* (it) {
        let prev = undefined;
        for (const item of it) {
            const key = keySelector(item);
            if (key === prev) {
                continue;
            }
            prev = key;
            yield item;
        }
    };
}