Binary Helpers
Utility functions for working with binary operations.
Functions
Section titled “Functions”| Function | Description |
|---|---|
createByteReader | Creates a cursor over bytes, for decoding binary formats: fixed-size integers and floats, LEB128 varints (signed ones z… |
createByteWriter | Creates a growable buffer to encode binary formats: the counterpart of createByteReader, with the same types, byte orde… |
mediaTypeOf | Finds the media type of an image from its first bytes (its magic number), whatever its name says: PNG, JPEG, GIF, WebP,… |
mediaTypeOfPath | Finds the media type of a file from the extension of its path or URL: images, fonts, web documents, scripts and styles,… |
toHex | Writes bytes as lowercase hexadecimal, two digits per byte. |
zigzagDecode | The inverse of zigzagEncode: maps an unsigned 64-bit zigzag value back to the signed integer. |
zigzagEncode | Maps a signed 64-bit integer to an unsigned one so that values near zero stay small (`0, -1, 1, -2` become `0, 1, 2, 3`… |
