Skip to main content

Hex template literal

The hex template literal is a builtin template literal that can be used to create a Buffer from a hex string. The buffer is stored in flash.

const buf: Buffer = hex`00 ab 12 2f 00`

Comments and whitespace are allowed in hex literals:

const commentedData: Buffer = hex`
01 02 03 // first three numbers
ff aa // two more bytes
`