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

x/proc/mod.ts>toBytes

A better way to work with processes in Deno.
Latest
function toBytes
Re-export
import { toBytes } from "https://deno.land/x/proc@0.22.1/mod.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>