Skip to main content
Module

x/proc/mod3.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.20.39/mod3.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>