Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 1021 Bytes

README.md

File metadata and controls

32 lines (21 loc) · 1021 Bytes

node-mozlz4a

Library to operate Mozilla Firefox's compressed files (jsonlz4 etc.)

Spec of the format is described at Firefox's source code

Usage

Via command line

This package provides two utility commands mozlz4a-decompress and mozlz4a-compress to compress/decompress files.

$ mozlz4a-decompress ./sessionstore.jsonlz4 > ./sessionstore.json
$ mozlz4a-compress ./sessionstore.json > ./sessionstore.jsonlz4

As a library

var mozlz4a = require('mozlz4a');

var compressed = fs.readFileSync('sessionstore.jsonlz4');
var content = mozlz4a.decompress(compressed); // returns a Buffer
var sessions = JSON.parse(content.toString('UTF-8'));

...

var updatedContent = Buffer.from(JSON.stringify(sessions));
var compressed = mozlz4a.compress(updatedContent); // requires Buffer, returns Buffer
fs.writeFileSync('sessionstore.jsonlz4.updated', compressed);