Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0x1luxa/utils
A collection of utility functions
A collection of utility functions for various common tasks, including formatting values, handling dates, and interacting with web3.
To install the package, use npm:
npm install @0x1luxa/utils
Formats a number to a USD currency string.
import { formatUsdValue } from "@0x1luxa/utils"
const formattedValue = formatUsdValue(1234.56)
console.log(formattedValue) // "$1,234.56"
Formats a number to a percentage string.
import { formatPercentValue } from "@0x1luxa/utils"
const formattedPercent = formatPercentValue(0.1234)
console.log(formattedPercent) // "12.34%"
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"
Shortens an Ethereum address for display purposes.
import { shortenAddress } from "@0x1luxa/utils"
const shortAddress = shortenAddress(
"0x1234567890abcdef1234567890abcdef12345678"
)
console.log(shortAddress) // "0x1234...5678"
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"
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
tsupEnvironment{
"local_name": "tsup",
"alias": false,
"peer_metadata": null
} | ^8.4.0 | runtime |
viemEnvironment{
"local_name": "viem",
"alias": false,
"peer_metadata": null
} | ^2.23.12 | runtime |
dayjsEnvironment{
"local_name": "dayjs",
"alias": false,
"peer_metadata": null
} | ^1.11.13 | runtime |
bignumber.jsEnvironment{
"local_name": "bignumber.js",
"alias": false,
"peer_metadata": null
} | ^9.1.2 | runtime |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^22 | development |
Source distribution
{
"shasum": "0b4487d197a5e7ee68efb5f8c85dfc4617f02963",
"tarball": "https://registry.npmjs.org/@0x1luxa/utils/-/utils-0.2.15.tgz",
"fileCount": 3,
"integrity": "sha512-z5nMAEAYonj3hAQQkZw4rCwsjWqRJc2Fy1W6wIFPPzog8aTzNlTpixl+t0SDdJa0lrog93/BCDXjVxp2AQGcNg==",
"signatures": [
{
"sig": "MEUCIQDdOWlsMK+7Osz2eV9OPs//jrWlv+ibaiDMyDKMmDUb5gIgMfUBX1Cfr68z2tcpfab1daSXFnaCWca+hLPLhinti8M=",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 6988
}Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:a3023b4ae75d1a66cb03bfda0f07e5721621744954362b9280fbbec7cd2e3e0d