Helpers

streamToString.mjs

@mr_ozio/scraper-utils · v2.5.0 · Generated April 21, 2026

Target Style

Target Style

1 exports

const

readStreamAsString

Target Style
export const readStreamAsString = async ({ from, encoding = 'utf-8' }) => {

Reads a stream into a string with named options.

Target style API. Preferred for new code.

Parameters

  • options{ from: AsyncIterable<any>, encoding?: BufferEncoding }

Returns

Promise<string>

Example

const text = await readStreamAsString({
  from: stream,
})

Legacy Style

Legacy Style

1 exports

const

streamToString

Legacy Style
export const streamToString = async (stream) => readStreamAsString({ from: stream })

Reads a stream into a UTF-8 string.

Legacy API. Kept for older code and not the preferred choice for new code.

Parameters

  • streamAsyncIterable<any>

Returns

Promise<string>