This project is part of the
@thi.ng/umbrella monorepo.
About
Hex string formatters for 4/8/16/24/32/48/64bit words.
Status
STABLE - used in production
Search or submit any issues for this package
Related packages
- @thi.ng/base-n - Arbitrary base-n conversions w/ presets for base16/32/36/58/62/64/85, support for arrays & bigints
Installation
yarn add @thi.ng/hex
ES module import:
<script type="module" src="https://cdn.skypack.dev/@thi.ng/hex"></script>
Skypack documentation
For Node.js REPL:
# with flag only for < v16
node --experimental-repl-await
> const hex = await import("@thi.ng/hex");
Package sizes (gzipped, pre-treeshake): ESM: 405 bytes
Dependencies
None
API
Generated API docs
import * as h from "@thi.ng/hex";
const cssColor = (x: number) => "#" + h.U24(x);
cssColor(10597059)
h.U48(223928981472033);
h.U48HL(0xcba9, 0x87654321)
h.U64(0xaa * 0x010101010101)
h.U64HL(0x11223344, 0x89abcdef);
const BUF = [1, 2, 3, 4, 0x10, 0x20, 0x30, 0x40];
h.U32BE(BUF, 0)
h.U32BE(BUF, 4)
h.U32LE(BUF, 0)
h.U32LE(BUF, 4)
Authors
Karsten Schmidt
If this project contributes to an academic publication, please cite it as:
@misc{thing-hex,
title = "@thi.ng/hex",
author = "Karsten Schmidt",
note = "https://thi.ng/hex",
year = 2020
}
License
© 2020 - 2022 Karsten Schmidt // Apache Software License 2.0