@mainframe/utils-hex

Hex encoding utilities

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@mainframe/utils-hex
110.1.14 years ago5 years agoMinified + gzip package size for @mainframe/utils-hex in KB

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
  1. value: any

Returns hex

hexEmpty

Returns 0x value with hex type.

encodeHex()

Arguments
  1. input: string
  2. from?: buffer$Encoding = 'utf8'

Returns hex

decodeHex()

Arguments
  1. input: hex
  2. to?: buffer$Encoding = 'utf8'

Returns string

License

MIT