Re: [whatwg/streams] Utility buffer class for stream transformers (#1097)

It's an interesting use case.

It looks like there's a lot of plumbing going on to turn the push-style `transform()` method into a pull-based `read()` method though (using an intermediate buffer). This is tricky to get right, especially if you need to consider backpressure. I'll have a think about it, see if there's a better way.

> Could this be a useful helper class in the spec?

I think it's a bit too early to tell whether this will be useful enough to make it part of the platform. I suggest you start off by first writing it as a userland JavaScript library. 🙂

> And another thing I was curious about is if I wanted to run this process on a string, is there no utility function or easier way than below to start the process?

We're working on making it easier to turn an array or any (async) iterable into a `ReadableStream`, see #1018. You'll then be able to do:
```javascript
ReadableStream.from(str.split("")).pipeThrough(new TransformStream(new TokenizerTransformer()))
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1097#issuecomment-748038013

Received on Friday, 18 December 2020 11:35:19 UTC