msgpack-lite is a pure JavaScript implementation of the MessagePack serialization format, providing fast encoding and decoding capabilities for both Node.js and web browsers. As of version 0.1.26, it offers synchronous `encode` and `decode` functions, along with streaming interfaces via `createEncodeStream` and `createDecodeStream`. It differentiated itself by claiming performance superior to some C++ MessagePack libraries for Node.js v4, without requiring native C++ compilation (node-gyp). The library supports various input types for decoding, including Node.js `Buffer`, standard JavaScript `Array`, and `Uint8Array`. It was tested on older Node.js versions (v0.10 through v6) and a wide range of browsers, including IE8. The last release was over 8 years ago, indicating it is no longer actively maintained.
npm install msgpack-liteVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both synchronous MessagePack encoding/decoding and the use of streaming APIs to write and read multiple MessagePack objects to/from a file, including proper error handling and cleanup for the file system operations.
Migrate to an actively maintained MessagePack library (e.g., `npm install @msgpack/msgpack` or `npm install msgpackr`). Be aware that API changes will require code refactoring.
Always use `const msgpack = require('msgpack-lite');` for Node.js. For browser environments, use the provided `msgpack.min.js` directly via a `<script>` tag or configure a bundler (like Browserify, as suggested in the old README) to handle CommonJS modules.When creating `Buffer` instances from raw data, use `Buffer.from(array)` or `Buffer.from(string, encoding)` instead of `new Buffer()`. When allocating new, uninitialized buffers, use `Buffer.alloc()` or `Buffer.allocUnsafe()`.
For high-performance or modern Node.js/browser applications, benchmark `msgpack-lite` against current alternatives like `@msgpack/msgpack` or `msgpackr` within your specific use case to determine actual performance characteristics.
Ensure you are using `const msgpack = require('msgpack-lite');` and then calling `msgpack.encode()` or `msgpack.decode()`. The module does not provide named exports for ES Modules.Ensure the input to `msgpack.decode()` is a `Buffer` (in Node.js), a `Uint8Array`, or a simple `Array` containing byte values (e.g., `[0x81, 0xA3, ...]`). Do not pass raw strings or other object types.
Verify that your stream pipeline is correctly configured. Ensure `encodeStream.end()` is called only once all data is written and that subsequent operations respect the stream's state. For reading, ensure `pipe()` is set up before data is expected, and handle `end` events to signal completion.
No dependency data recorded yet.