1771771771
Denoβ€’4y agoβ€’
1 reply
177177177

How to stop reading from a ReadableStream?

let user

for await (const data of readable) {
  if (data.user.id === 'user-id') {
    user = data

    break
  }
}

console.log(user)

the
break
stops the for loop, but it doesnt exit? because it only logs the
user
after the
readable
stream is completed. i dont want to wait for the stream to complete/end, i want to get
user
immidiately after
break
is called.

here
readable
is
ReadableStream
Was this page helpful?