
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> [](#contributors-) <!-- ALL-CONTRIBUTORS-BADGE:END -->
Small tool to help create Buffers in NodeJS
yarn add @hertzg/bx
npm i --save @hertzg/bx
Warning: This package is native ESM and no
longer provides a CommonJS export. If your project uses CommonJS, you'll have
to convert to ESM or use
the dynamic import() function.
Package provides bx and bxx method thar accepts a string containing hex encoded buffer. The string will be
stripped of any non-hexadecimal symbols (eg: [^0-9-a-f]) and if the resulting string has even length then it's used as
a value for Buffer.from(value, 'hex') with bxx and as new Uint8Array(value).buffer with bx or otherwise throws
a TypeError.
Typescript
import { bx } from '@hertzg/bx';
const HEADER = bx('00 ff 00 ff'); // ArrayBuffer { [Uint8Contents]: <00 ff 00 ff>, byteLength: 4 }
const SYNC1 = bx('00ff00ff_b4_01020304'); // ArrayBuffer { [Uint8Contents]: <00 ff 00 ff b4 01 02 03 04>, byteLength: 9 }
const ZEROLENGTH = bx(''); // ArrayBuffer { [Uint8Contents]: <>, byteLength: 0 }
const WRONGHEX = bx('z ff 00 00'); // throws
const MISSZERO = bx('f2-00_0_00'); // throws
const SPACES = bx(' '); // throws
If you want to get Buffer instead of ArrayBuffer just replace bx calls with bxx
import { bxx } from '@hertzg/bx';
const HEADER = bxx('00 ff 00 ff'); // <Buffer 00 ff 00 ff>
const SYNC1 = bxx('00ff00ff_b4_01020304'); // <Buffer 00 ff 00 ff b4 01 02 03 04>
const ZEROLENGTH = bxx(''); // <Buffer >
const WRONGHEX = bxx('z ff 00 00'); // throws
const MISSZERO = bxx('f2-00_0_00'); // throws
const SPACES = bxx(' '); // throws
More examples can be seen in tests
Thanks goes to these wonderful people (emoji key):
George Hertz 🚧 🚇 ⚠️ 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> [](#contributors-) <!-- ALL-CONTRIBUTORS-BADGE:END -->
The npm package @hertzg/bx receives a total of 7 weekly downloads. As such, @hertzg/bx popularity was classified as not popular.
We found that @hertzg/bx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.