@mainframe/utils-hex
v0.1.1
Published
Hex encoding utilities
Downloads
15
Keywords
Readme
utils-hex
Utilities for hexadecimal-encoded strings.
Installation
yarn add @mainframe/utils-hex
Usage
import { encodeHex, decodeHex } from 'utils-hex'
const encoded = encodeHex('hello')
const decoded = decodeHex(encoded) // 'hello'
Types
hex
Opaque type representing an hexadecimal-encoded string prefixed with 0x
API
hexType()
Simple identity function casting the provided value as hex
to properly type-check.
Arguments
value: any
Returns hex
hexEmpty
Returns 0x
value with hex
type.
encodeHex()
Arguments
input: string
from?: buffer$Encoding = 'utf8'
Returns hex
decodeHex()
Arguments
input: hex
to?: buffer$Encoding = 'utf8'
Returns string
License
MIT