@mainframe/utils-hex

0.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @mainframe/utils-hex

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

3.86 kB

Total Files

7

Last publish

Collaborators

  • sarahwiley
  • mosic
  • aclarke
  • howleysv
  • diogoperillo
  • paul_lecam