Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/proc/tools/deps/proc.ts>toBytes

A better way to work with processes in Deno.
Go to Latest
function toBytes
Re-export
import { toBytes } from "https://deno.land/x/proc@0.21.5/tools/deps/proc.ts";

Converts specific types to Uint8Array chunks.

  • string is converted to utf-8, concatenating a trailing lf
  • string[] each item in the array is converted to utf-8, adding a trailing lf, all concatenated to a single Uint8Array
  • Uint8Array is passed on unchanged
  • Uint8Array[] is concatenated to a single Uint8Array

Strings are always treated as lines, and we add a trailing lf character. Data in byte form is always treated strictly as binary data.

Parameters

iter: AsyncIterable<
| string
| Uint8Array
| string[]
| Uint8Array[]
>

Returns

AsyncIterable<Uint8Array>