Take only the last N items in an iterable sequence
function takeLast(count) {
    return function (iterable) {
        return __asyncGenerator(this, arguments, function* () {
            var e_10, _a;
            const buffer = [];
            try {
                for (var iterable_8 = __asyncValues(iterable), iterable_8_1; iterable_8_1 = yield __await(iterable_8.next()), !iterable_8_1.done;) {
                    const item = iterable_8_1.value;
                    buffer.push(item);
                    if (buffer.length > count) {
                        buffer.shift();
                    }
                }
            }
            catch (e_10_1) { e_10 = { error: e_10_1 }; }
            finally {
                try {
                    if (iterable_8_1 && !iterable_8_1.done && (_a = iterable_8.return)) yield __await(_a.call(iterable_8));
                }
                finally { if (e_10) throw e_10.error; }
            }
            return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(buffer))));
        });
    };
}