chromium/third_party/blink/renderer/core/streams/readable_stream.idl

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// https://streams.spec.whatwg.org/#rs-class
typedef (ReadableStreamDefaultReader or ReadableStreamBYOBReader) ReadableStreamReader;
typedef (ReadableStreamDefaultController or ReadableByteStreamController) ReadableStreamController;

enum ReadableStreamReaderMode { "byob" };
enum ReadableStreamType { "bytes" };

[
    Exposed=(Window,Worker,Worklet)
] interface ReadableStream {
    [RuntimeEnabled=ReadableStreamAsyncIterable, HasAsyncIteratorReturnAlgorithm] async iterable<any>(optional ReadableStreamIteratorOptions options = {});

    [CallWith=ScriptState, RaisesException] constructor(optional any underlyingSource, optional any strategy);
    readonly attribute boolean locked;

    // TODO(yhirano): function length is different from what's specced. Fix it.
    [RaisesException, CallWith=ScriptState] Promise<undefined> cancel(optional any reason);
    [RaisesException, CallWith=ScriptState, MeasureAs=ReadableStreamGetReader] ReadableStreamReader getReader(optional ReadableStreamGetReaderOptions options);
    [RaisesException, CallWith=ScriptState, MeasureAs=ReadableStreamPipeThrough] ReadableStream pipeThrough(
        ReadableWritablePair transform, optional StreamPipeOptions options);
    [RaisesException, CallWith=ScriptState, MeasureAs=ReadableStreamPipeTo] Promise<undefined> pipeTo(
        WritableStream destination, optional StreamPipeOptions options);
    [RaisesException, CallWith=ScriptState] sequence<ReadableStream> tee();
};