This library, `algorand-msgpack`, is a TypeScript/JavaScript implementation of the MessagePack binary serialization format, currently at version 1.1.0. It's a fork of the popular `@msgpack/msgpack` library, maintaining a similar API but introducing several key enhancements. These include improved BigInt support that allows for greater interoperability with other MessagePack implementations by not solely encoding BigInts as int64/uint64, and the ability to decode raw strings as `Uint8Array`s to handle non-UTF-8 encoded strings. Additionally, it provides support for number and binary map keys within JavaScript Maps. The most recent significant update in v1.1.0 introduced the `RawBinaryString` class, enabling encoding byte arrays as MessagePack strings and offering corresponding decoding options. While it doesn't have a strict release cadence, updates appear to be driven by the needs of the Algorand ecosystem. It's designed to be a universal library, compatible with Node.js (v14 and above) and browser environments, and ships with comprehensive TypeScript type definitions.
npm install algorand-msgpackVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic encoding and decoding of a complex JavaScript object, including the use of `RawBinaryString` for explicit binary string handling, ensuring data integrity.
Thoroughly review the fork's specific changes documented in the README (e.g., BigInt support, raw string decoding options, map key types) and adjust your encoding/decoding logic or expectations accordingly.
When calling `decode()`, pass an options object with `useRawBinaryStringClass: true` and either `rawBinaryStringKeys: true` or `rawBinaryStringValues: true` (or both) if you intend to receive `RawBinaryString` objects.
Ensure your Node.js runtime environment is version 14 or later. Upgrade Node.js if necessary.
Update all import statements in your code from `@msgpack/msgpack` to `algorand-msgpack`.
Review the BigInt support documentation for `algorand-msgpack`. You may need to use specific `EncoderOptions` or `DecoderOptions` to align BigInt serialization/deserialization with your requirements or other systems.