Catalog npm
Back to packageRELEASE DETAILS

0.2.16

npm

@0x1luxa/utils

A collection of utility functions

helpersutilityutils
Published20 Mar 2025
Direct dependencies6
Transitive dependenciesNot calculated

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.

Declared dependencies 6

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^8.4.0runtime
viem
Environment
{
  "local_name": "viem",
  "alias": false,
  "peer_metadata": null
}
^2.23.12runtime
dayjs
Environment
{
  "local_name": "dayjs",
  "alias": false,
  "peer_metadata": null
}
^1.11.13runtime
bignumber.js
Environment
{
  "local_name": "bignumber.js",
  "alias": false,
  "peer_metadata": null
}
^9.1.2runtime
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^22development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "179aa98f9ee13bb6dbc9cfce488d9fe70e91817c",
  "tarball": "https://registry.npmjs.org/@0x1luxa/utils/-/utils-0.2.16.tgz",
  "fileCount": 4,
  "integrity": "sha512-Gruylmm/d7t1GUiDNduIzgC1g4OqH5C6sHIeHIfQn4OE5HBuEQKjHvnKIrLy1KtwuJPs9PX4sGfwhw7oMHCySA==",
  "signatures": [
    {
      "sig": "MEYCIQCr8B7Ly0H7tBhHWS5r8sWb+EBQ5pPvSt1lfR0zNxo4SAIhAJDWce4c2ccUPxwTKi1D3IheG8hB4yd/ksVcbMYlfwGK",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 15840
}

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_version:77efa3df5cdff67fda88c8ac1c8c03591c38de29dbd4795315e160027d44831f

Other collected versions

0.2.2220 Mar0.2.2020 Mar0.2.1920 Mar0.2.1820 Mar0.2.1720 Mar0.2.1520 MarView all collected versions →