class AsyncIterableExt {
  constructor(iterable) {
    this.iterable = iterable;
  }
  async *[Symbol.asyncIterator]() {
    for await (const value of this.iterable) {
      yield value;
    }
  }
  map(callback) {
    const iterable = this.iterable;
    return makeAsyncIterableExt(async function* () {
      for await (const value of iterable) {
        yield callback(value);
      }
    });
  }
  filter(predicate) {
    const iterable = this.iterable;
    return makeAsyncIterableExt(async function* () {
      for await (const value of iterable) {
        if (predicate(value))
          yield value;
      }
    });
  }
  async toArray() {
    const result = [];
    for await (const item of this) {
      result.push(item);
    }
    return result;
  }
}
function makeAsyncIterableExt(generator) {
  return new AsyncIterableExt({
    [Symbol.asyncIterator]: generator
  });
}
export {
  AsyncIterableExt,
  makeAsyncIterableExt
};
//# sourceMappingURL=async-iterable.js.map