Skip to content

Binary Helpers

Utility functions for working with binary operations.

FunctionDescription
createByteReaderCreates a cursor over bytes, for decoding binary formats: fixed-size integers and floats, LEB128 varints (signed ones z…
createByteWriterCreates a growable buffer to encode binary formats: the counterpart of createByteReader, with the same types, byte orde…
mediaTypeOfFinds the media type of an image from its first bytes (its magic number), whatever its name says: PNG, JPEG, GIF, WebP,…
mediaTypeOfPathFinds the media type of a file from the extension of its path or URL: images, fonts, web documents, scripts and styles,…
toHexWrites bytes as lowercase hexadecimal, two digits per byte.
zigzagDecodeThe inverse of zigzagEncode: maps an unsigned 64-bit zigzag value back to the signed integer.
zigzagEncodeMaps 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`…