Decompress with NRV2E algorithm
npm install nrv2e-decompress




Decompress with NRV2E algorithm.
This is ESM module which requires ES2020 and Node >= 14.
``shell`
npm install nrv2e-decompress
_Additionally for Typescript:_
`shell`
npm install -D @types/node
`js`
import nrv2eDecompress from "nrv2e-decompress"
`js`
nrv2eDecompress(input, output, bufferBits)
_Arguments:_
- input is a Buffer with compressed dataoutput
- is a Buffer from decompressed data and it have to be pre-allocated,Buffer.alloc
ie. with methodbufferBits
- is a number of control buffer bits: 8, 16 or 32 (optional:8
default: )
_Example:_
`js
// Polish vehicle registration certificate scanned from Aztec 2D barcode
const b64Input = "BgQAANtYAA..."
const binInput = Buffer.from(b64Input, "base64")
// 4 first bytes in Aztec code are output length
const outputLength = binInput.readUInt32LE(0)
const utf16Output = Buffer.alloc(outputLength)
const compressedInput = binInput.slice(4)
nrv2eDecompress(compressedInput, utf16Output)
const textOutput = utf16Output.toString("utf16le")
``
Copyright (c) 2018-2025 Piotr Roszatycki
This code is based on UCL data compression library:
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.