npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xylabs/hex

v5.0.64

Published

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Readme

@xylabs/hex

logo

main-build npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge codacy-badge codeclimate-badge snyk-badge socket-badge

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Reference

@xylabs/hex


Interfaces

Type Aliases

Variables

Functions

functions

asAddress

@xylabs/hex


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

@xylabs/hex


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

@xylabs/hex


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

@xylabs/hex


function bitsToNibbles(value): number;

Parameters

value

number

Returns

number

hexFrom

@xylabs/hex


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?

HexConfig

Configuration of output format and validation

Returns

Lowercase<string>

hexFromArrayBuffer

@xylabs/hex


function hexFromArrayBuffer(buffer, config?): Lowercase<string>;

Convert an ArrayBuffer to a hex string

Parameters

buffer

ArrayBufferLike

The buffer to be converted

config?

HexConfig

Configuration of output format and validation

Returns

Lowercase<string>

hexFromBigInt

@xylabs/hex


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

@xylabs/hex


function hexFromHexString(value, config): Lowercase<string>;

Parameters

value

string

config

HexConfig = {}

Returns

Lowercase<string>

hexFromNumber

@xylabs/hex


function hexFromNumber(value, config?): Lowercase<string>;

Parameters

value

number

config?

HexConfig

Returns

Lowercase<string>

hexToBigInt

@xylabs/hex


function hexToBigInt(hex): bigint;

Parameters

hex

Lowercase<string>

Returns

bigint

isAddress

@xylabs/hex


function isAddress(value, config): value is Lowercase<string>;

Parameters

value

unknown

config

HexConfig = {}

Returns

value is Lowercase<string>

isHash

@xylabs/hex


function isHash(value, bitLength): value is Lowercase<string>;

Parameters

value

unknown

bitLength

HashBitLength = 256

Returns

value is Lowercase<string>

isHashBitLength

@xylabs/hex


function isHashBitLength(value): value is HashBitLength;

Parameters

value

unknown

Returns

value is HashBitLength

isHex

@xylabs/hex


function isHex(value, config?): value is Lowercase<string>;

Parameters

value

unknown

config?

HexConfig

Returns

value is Lowercase<string>

isHexZero

@xylabs/hex


function isHexZero(value?): undefined | boolean;

Parameters

value?

string

Returns

undefined | boolean

nibblesToBits

@xylabs/hex


function nibblesToBits(value): number;

Parameters

value

number

Returns

number

toAddress

@xylabs/hex


function toAddress(value, config): Lowercase<string>;

Parameters

value

string | number | bigint | ArrayBufferLike

config

HexConfig = {}

Returns

Lowercase<string>

toHex

@xylabs/hex


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

@xylabs/hex


function toHexLegacy(buffer): string;

Parameters

buffer

ArrayBuffer

Returns

string

interfaces

HexConfig

@xylabs/hex


Configuration of validation and output format

Properties

bitLength?

optional bitLength: number;

byteSize?

optional byteSize: number;

prefix?

optional prefix: boolean;

type-aliases

Address

@xylabs/hex


type Address = Exclude<Hex, "reserved-address-value">;

Hash

@xylabs/hex


type Hash = Exclude<Hex, "reserved-hash-value">;

HashBitLength

@xylabs/hex


type HashBitLength = 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;

Hex

@xylabs/hex


type Hex = Exclude<Lowercase<string>, "reserved-hex-value">;

variables

HashBitLength

@xylabs/hex


HashBitLength: HashBitLength[];

ZERO_ADDRESS

@xylabs/hex


const ZERO_ADDRESS: Address;

ZERO_HASH

@xylabs/hex


const ZERO_HASH: Hash;

hexRegex

@xylabs/hex


const hexRegex: RegExp;

hexRegexWithPrefix

@xylabs/hex


const hexRegexWithPrefix: RegExp;

Part of sdk-js

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥 and ❄️ by XYLabs