GUIDES Binary Data Decompress Binary Data – One Buffer
About
Binary Data
Index
Convert String to ArrayBuffer
Convert ArrayBuffer to String
Convert ArrayBuffers to String
Handle Errors Converting ArrayBuffer to String
Immutable ArrayBuffers
Resize an ArrayBuffer
Combine ArrayBuffers
Convert Base64 to Binary Data
Convert Binary Data to Base64
Convert Binary Data to Hex
Convert Hex to Binary Data
Calculate CRC for Binary Data
Compress Binary Data – One Buffer
Compress Binary Data – Streaming
Decompress Binary Data – One Buffer
Decompress Binary Data – Streaming
Callbacks
Index
One-Time Callback
Repeating Callback
Repeating Callback with Initial Delay
Immediate Callback
Reschedule Callback
Cancel Callback
Suspend Callback
What About setTimeout?
Optimizing Embedded JavaScript
Index
When to Optimize
Know Where to Optimize
Looping through an Array
Iterating Over a String
Building a String
Avoid Copying Buffers
Accessing Properties
Map versus Object
Appending to an Array
Operating on Bits
Defining Class Methods
Reducing Stack Use
Time
Index
Get Unix Time
Get Time of Day
Get Date
Get Time Since System Start
Get Microseconds
Set System Date and Time
Set Real-Time Clock Time
Get Time and Date from Network
Get Time and Date from Real-Time Clock
Sleep

Decompress Binary Data – One Buffer

The Inflate module provides zlib decompression using a subset of the Pako API.

Decompress a single binary data buffer. The second argument to push() is true to indicate this is the only buffer to decompress.

The compressedData bytes may be generated using Deflate.

const compressedData = Uint8Array.of(
		0x78, 0xda, 0x63, 0x60, 0x64, 0x62, 0x66, 0x61,
		0x65, 0x63, 0x67, 0x80, 0xd2, 0x00, 0x01, 0x98,
		0x00, 0x39);

const inflator = new Inflate();

inflator.push(compressedData, true);
// => inflator.result is a Uint8Array with decompressed data
// => decompressed data is [0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]

inflator.close();