Node.js API compatibility - Buffer
Explore the integration and use of the Node.js Buffer API within the Azion Runtime. The Buffer API is crucial for handling binary data in Node.js, especially when dealing with file I/O or network operations where data is represented as streams.
The buffer API in Node.js is a global class used to handle binary data. It allows developers to work with raw binary data directly, enabling efficient manipulation of data streams, file I/O, and network communications.
Example: Basic buffer operations
Create and manipulate buffers with different encodings:
Example: Buffer encoding conversions
Convert between different encoding formats for data transmission:
Example: Buffer concatenation and slicing
Combine multiple buffers and extract portions of binary data:
Example: Binary data processing
Process binary data from requests or external sources:
Example: JSON serialization with buffers
Handle JSON data with buffer conversion for API responses:
Supported APIs
| API | Status |
|---|---|
Buffer.alloc() | 🟢 Supported |
Buffer.allocUnsafe() | 🟢 Supported |
Buffer.byteLength() | 🟢 Supported |
Buffer.compare() | 🟢 Supported |
Buffer.concat() | 🟢 Supported |
Buffer.from() | 🟢 Supported |
Buffer.isBuffer() | 🟢 Supported |
Buffer.isEncoding() | 🟢 Supported |
buf.compare() | 🟢 Supported |
buf.copy() | 🟢 Supported |
buf.equals() | 🟢 Supported |
buf.fill() | 🟢 Supported |
buf.indexOf() | 🟢 Supported |
buf.includes() | 🟢 Supported |
buf.lastIndexOf() | 🟢 Supported |
buf.length | 🟢 Supported |
buf.readInt*() | 🟡 Partially supported |
buf.subarray() | 🟢 Supported |
buf.slice() | 🟡 Supported (deprecated, use subarray()) |
buf.toString() | 🟢 Supported |
buf.write() | 🟢 Supported |
buf.writeInt*() | 🟡 Partially supported |
Buffer.isAscii() | 🔴 Not supported |
Buffer.isUtf8() | 🔴 Not supported |
Buffer.resolveObjectURL() | 🔴 Not supported |
Buffer.transcode() | 🔴 Not supported |