Take everything but the last N items in an iterable sequence
function skipLast(count) {
    return function* (iterable) {
        const buffer = [];
        for (const item of iterable) {
            buffer.push(item);
        }
        if (buffer.length < count) {
            return;
        }
        yield* buffer.slice(0, buffer.length - count);
    };
}