TypeScript binary serialization library encoding to/from ArrayBuffer.
| Command | What |
|---|---|
npm test |
Run all tests (vitest, src as root) |
npm run build |
vite build && tsc && dts-bundle-generator --out-file dist/index.d.ts src/index.ts |
npm run benchmark |
npx tsx benchmark/run.ts |
CI order (must pass sequentially): tsc (typecheck only, no emit) → npm run test -- --run → npm run build.
No linter or formatter is configured.
Single package, entrypoint src/index.ts. All codec types re-exported from separate files under src/codecs/.
Tests are co-located with source as *.test.ts, using vitest. Run all tests: npm test. To run a single file: npx vitest src/codecs/object.test.ts. Import from #crunches (package.json imports alias).
CrunchesObject (in src/codecs/object.ts) uses new Function(...) at construction time to build optimized encode/decode functions from string templates. When debugging or modifying object codec behavior, be aware of the codegen layer.
dist/ is gitignored. The build runs vite (ESM bundle), then tsc (type checks), then dts-bundle-generator (rolls up .d.ts). Source maps included via vite.config.ts. Tests excluded from build via tsconfig.build.json.
Default is little-endian for all types. Override via .bigEndian() / .littleEndian() on any codec. Child codecs inherit parent endianness unless they've set their own.
Infer<T>→ codec output typeInferInput<T>→ codec input typeProtocolInfer<typeof protocol, 'packetName'>→ inferred payload of a protocol packet
Automated via release-please (manifest-based) + NPM publish on CI. Run npx release-please manifest locally to dry-run.