Catalog npm
PACKAGE EXPLORERView in registry

@0x1luxa/utils

npm

A collection of utility functions

helpersutilityutils
Versions collected23
Direct dependencies6From release 0.2.22
Last observed20 Oct, 22:34 UTC

README

Current package documentation

@0x1luxa/utils

A collection of utility functions for various common tasks, including formatting values, handling dates, and interacting with web3.

Installation

To install the package, use npm:

npm install @0x1luxa/utils

Usage

Formatting Utilities

Format USD Value

Formats a number to a USD currency string.

import { formatUsdValue } from "@0x1luxa/utils"

const formattedValue = formatUsdValue(1234.56)
console.log(formattedValue) // "$1,234.56"

Format Percent Value

Formats a number to a percentage string.

import { formatPercentValue } from "@0x1luxa/utils"

const formattedPercent = formatPercentValue(0.1234)
console.log(formattedPercent) // "12.34%"

Date Utilities

Get Days Ago

Calculates how many days ago a given date was.

import { getDaysAgo } from "@0x1luxa/utils"

const daysAgo = getDaysAgo("2023-01-01")
console.log(daysAgo) // e.g., "9 months ago"

Web3 Utilities

Shorten Address

Shortens an Ethereum address for display purposes.

import { shortenAddress } from "@0x1luxa/utils"

const shortAddress = shortenAddress(
  "0x1234567890abcdef1234567890abcdef12345678"
)
console.log(shortAddress) // "0x1234...5678"

Parse RPC Error

Parses an RPC error to extract useful information.

import { parseRpcError } from "@0x1luxa/utils"

const error = new Error("Transaction reverted")
const parsedError = parseRpcError(error)
console.log(parsedError.revertReason) // "Transaction reverted"

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 23

Collected releases
VersionPublishedDirect dependenciesOpen version
0.2.22Registry latest20 Mar 20256
0.2.2020 Mar 20256
0.2.1920 Mar 20256
0.2.1820 Mar 20256
0.2.1720 Mar 20256
0.2.1620 Mar 20256
0.2.1520 Mar 20256
0.2.1420 Mar 20256
0.2.1319 Mar 20256
0.2.1219 Mar 20256
0.2.1119 Mar 20256
0.2.1019 Mar 20256
0.2.919 Mar 20256
0.2.819 Mar 20255
0.2.719 Mar 20255
0.2.619 Mar 20255
0.2.519 Mar 20255
0.2.419 Mar 20255
0.2.319 Mar 20255
0.2.219 Mar 20255

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:34 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:07ee5719d80f76a77fd5d58295c71ad42e99911f15ca16c2664f009050304afa