isBytes
Determines if the argument is a byte array.
isBytesvalueis-bytes
name | type | description |
---|---|---|
value | Value | A value to be tested. |
is-bytes |
|
isBytes
provides a type check to determine if value
is a byte array:
-
An instance of
Uint8Array
-
An instance of
Buffer
(in Node.js)
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