ReadableStream

preview_player
Показать описание
Пример создания потока на чтение

_____________________________________________________________

const textStream = new ReadableStream({
start( controller ) {
let messages = [
"How do you use the Streams API’s readable stream functionality?",
"The Fetch API allows you to fetch resources across the network",
"The body property is a simple getter exposing the body contents as a readable stream",
"You can consume Fetch Body objects as streams and create your own custom readable streams",
"The ReadableStream interface of the Streams API represents a readable stream of byte data"
]
}
}
})

_____________________________________________________________

Чтение потока

_____________________________________________________________

function readStream ( stream, container ) {
function getChank ( { done, value } ) {
if ( done ) return
}
)
}

_____________________________________________________________

Контейнер для вывода данных

_____________________________________________________________

)

).textContent = chank
}

_____________________________________________________________

Вызов функции readStream

_____________________________________________________________

readStream ( textStream, messageBox )
Рекомендации по теме