@xylabs/hex
v5.0.64
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Readme
@xylabs/hex
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Reference
@xylabs/hex
Interfaces
Type Aliases
Variables
Functions
- toAddress
- isAddress
- asAddress
- isHashBitLength
- isHash
- asHash
- asHex
- hexFrom
- hexFromArrayBuffer
- hexFromBigInt
- hexFromHexString
- hexFromNumber
- isHex
- isHexZero
- toHexLegacy
- bitsToNibbles
- nibblesToBits
- toHex
- hexToBigInt
functions
asAddress
Call Signature
function asAddress(value): undefined | Lowercase<string>;Parameters
value
unknown
Returns
undefined | Lowercase<string>
Call Signature
function asAddress(value, assert): Lowercase<string>;Parameters
value
unknown
assert
AssertConfig
Returns
Lowercase<string>
asHash
Call Signature
function asHash(value): undefined | Lowercase<string>;Parameters
value
unknown
Returns
undefined | Lowercase<string>
Call Signature
function asHash(value, assert): Lowercase<string>;Parameters
value
unknown
assert
AssertConfig
Returns
Lowercase<string>
asHex
Call Signature
function asHex(value): undefined | Lowercase<string>;Parameters
value
unknown
Returns
undefined | Lowercase<string>
Call Signature
function asHex(value, assert): Lowercase<string>;Parameters
value
unknown
assert
AssertConfig
Returns
Lowercase<string>
bitsToNibbles
function bitsToNibbles(value): number;Parameters
value
number
Returns
number
hexFrom
function hexFrom(value, config?): Lowercase<string>;Takes unknown value and tries our best to convert it to a hex string
Parameters
value
Supported types are string, number, bigint, and ArrayBuffer
string | number | bigint | ArrayBufferLike
config?
Configuration of output format and validation
Returns
Lowercase<string>
hexFromArrayBuffer
function hexFromArrayBuffer(buffer, config?): Lowercase<string>;Convert an ArrayBuffer to a hex string
Parameters
buffer
ArrayBufferLike
The buffer to be converted
config?
Configuration of output format and validation
Returns
Lowercase<string>
hexFromBigInt
function hexFromBigInt(value, config): Lowercase<string>;Convert a bigint to a hex string
Parameters
value
bigint
The bigint to be converted
config
HexConfig = {}
Configuration of output format and validation
Returns
Lowercase<string>
hexFromHexString
function hexFromHexString(value, config): Lowercase<string>;Parameters
value
string
config
HexConfig = {}
Returns
Lowercase<string>
hexFromNumber
function hexFromNumber(value, config?): Lowercase<string>;Parameters
value
number
config?
Returns
Lowercase<string>
hexToBigInt
function hexToBigInt(hex): bigint;Parameters
hex
Lowercase<string>
Returns
bigint
isAddress
function isAddress(value, config): value is Lowercase<string>;Parameters
value
unknown
config
HexConfig = {}
Returns
value is Lowercase<string>
isHash
function isHash(value, bitLength): value is Lowercase<string>;Parameters
value
unknown
bitLength
HashBitLength = 256
Returns
value is Lowercase<string>
isHashBitLength
function isHashBitLength(value): value is HashBitLength;Parameters
value
unknown
Returns
value is HashBitLength
isHex
function isHex(value, config?): value is Lowercase<string>;Parameters
value
unknown
config?
Returns
value is Lowercase<string>
isHexZero
function isHexZero(value?): undefined | boolean;Parameters
value?
string
Returns
undefined | boolean
nibblesToBits
function nibblesToBits(value): number;Parameters
value
number
Returns
number
toAddress
function toAddress(value, config): Lowercase<string>;Parameters
value
string | number | bigint | ArrayBufferLike
config
HexConfig = {}
Returns
Lowercase<string>
toHex
function toHex(value, config): Lowercase<string>;takes any value and tries our best to convert it to a hex string
Parameters
value
Supported types are string, number, bigint, and ArrayBuffer
string | number | bigint | ArrayBufferLike
config
HexConfig = {}
Configuration of output format and validation
Returns
Lowercase<string>
toHexLegacy
function toHexLegacy(buffer): string;Parameters
buffer
ArrayBuffer
Returns
string
interfaces
HexConfig
Configuration of validation and output format
Properties
bitLength?
optional bitLength: number;byteSize?
optional byteSize: number;prefix?
optional prefix: boolean;type-aliases
Address
type Address = Exclude<Hex, "reserved-address-value">;Hash
type Hash = Exclude<Hex, "reserved-hash-value">;HashBitLength
type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;Hex
type Hex = Exclude<Lowercase<string>, "reserved-hex-value">;variables
HashBitLength
HashBitLength: HashBitLength[];ZERO_ADDRESS
const ZERO_ADDRESS: Address;ZERO_HASH
const ZERO_HASH: Hash;hexRegex
const hexRegex: RegExp;hexRegexWithPrefix
const hexRegexWithPrefix: RegExp;Part of sdk-js
Maintainers
License
See the LICENSE file for license details
