@mainframe/utils-hex

Hex encoding utilities

Stats

StarsIssuesVersionUpdatedCreatedSize
@mainframe/utils-hex
0.1.13 years ago3 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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.