isBytes

Determines if the argument is a byte array.

isBytesvalueis-bytes

nametypedescription

value

Value

A value to be tested.

is-bytes

Boolean

true if value is an instance of Uint8Array, false otherwise.

isBytes provides a type check to determine if value is a byte array:

Returns true or false.

Example

import assert from "assert"
import {confidential} from "panda-confidential"
{isBytes, Message} = confidential()

do ->
  assert.equal (isBytes "Hello, World!"), false

  assert.equal (isBytes Buffer.from "Hello, World!"), true

  # to method will return a byte array with the hint `bytes`
  plaintext = Message.from "utf8", "Hello, World!"
  assert.equal (isBytes plaintext.to "bytes"), true