packages/mesh/lib/through.js
function through(fn, keepOpen) {
    if (keepOpen === void 0) { keepOpen = false; }
    return duplex_1.createDuplex(function (input, output) {
        var nextInput = function () {
            input.next().then(function (_a) {
                var value = _a.value;
                if (value == null) {
                    if (!keepOpen) {
                        return output.return();
                    }
                }
                return pump_1.pump(wrap_async_iterable_iterator_1.wrapAsyncIterableIterator(fn(value)), function (value) {
                    return output.unshift(value);
                }).then(nextInput);
            });
        };
        nextInput();
    });
}
function through(fn, keepOpen) {
    if (keepOpen === void 0) { keepOpen = false; }
    return duplex_1.createDuplex(function (input, output) {
        var nextInput = function () {
            input.next().then(function (_a) {
                var value = _a.value;
                if (value == null) {
                    if (!keepOpen) {
                        return output.return();
                    }
                }
                return pump_1.pump(wrap_async_iterable_iterator_1.wrapAsyncIterableIterator(fn(value)), function (value) {
                    return output.unshift(value);
                }).then(nextInput);
            });
        };
        nextInput();
    });
}
TODO - possibly endOnNoInput