You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a new Source.prototype.buffers() method that returns the represented
source code as an array of Buffers, avoiding the intermediate Buffer.concat
allocation that buffer() performs on composite sources such as
ConcatSource. Consumers that can accept Buffer[] (e.g. fs.createWriteStream
backed by writev) can now keep data as Buffer[] across nested
CachedSource/ConcatSource layers and write it out in one shot, which avoids
repeatedly copying the same bytes.
- Source: default buffers() returns [this.buffer()].
- ConcatSource: flattens child buffers() into a single Buffer[] without
concatenating, and buffer() is now implemented via Buffer.concat(buffers()).
- CachedSource: caches the Buffer[] separately from the Buffer; buffer()
concatenates lazily when requested, so repeated buffers() calls do not
trigger copies.
- CompatSource: forwards to sourceLike.buffers() when available, otherwise
falls back to the default.
- SizeOnlySource: throws like buffer().
Closes#157
Add `Source.prototype.buffers()` that returns the source as `Buffer[]`. `ConcatSource`, `CachedSource`, and `CompatSource` implement it without allocating an intermediate concatenated buffer, allowing consumers that can write multiple buffers at once (e.g. via `writev`) to avoid the overhead of `Buffer.concat` in deeply nested sources.
0 commit comments