Socket
Socket
Sign inDemoInstall

fflate

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fflate

High performance (de)compression in an 8kB package


Version published
Weekly downloads
5.8M
decreased by-1.77%
Maintainers
1
Weekly downloads
 
Created

What is fflate?

The fflate npm package is a JavaScript library for performing various compression and decompression operations. It is designed to be fast and efficient, leveraging modern algorithms and techniques to handle ZIP, GZIP, and Zlib formats.

What are fflate's main functionalities?

Compression

This feature allows you to compress data using the deflate algorithm. The code sample demonstrates how to compress a Uint8Array of data.

const fflate = require('fflate');
const { deflate } = fflate;
const uncompressed = new Uint8Array([/* some data */]);
const compressed = deflate(uncompressed);

Decompression

This feature allows you to decompress data that was compressed using the deflate algorithm. The code sample shows how to decompress a Uint8Array of compressed data.

const fflate = require('fflate');
const { inflate } = fflate;
const compressed = new Uint8Array([/* some compressed data */]);
const decompressed = inflate(compressed);

ZIP File Creation

This feature allows you to create ZIP files. The code sample demonstrates how to zip multiple files represented as Uint8Arrays into a single ZIP file.

const fflate = require('fflate');
const { zip } = fflate;
const files = {
  'file.txt': new Uint8Array([/* file data */]),
  'another.txt': new Uint8Array([/* more file data */])
};
zip(files, (err, zipped) => {
  if (!err) console.log(zipped);
});

ZIP File Extraction

This feature allows you to extract files from a ZIP archive. The code sample shows how to unzip a Uint8Array of zipped data to retrieve the original files.

const fflate = require('fflate');
const { unzip } = fflate;
const zipData = new Uint8Array([/* some zipped data */]);
unzip(zipData, (err, unzipped) => {
  if (!err) console.log(unzipped);
});

Stream Compression and Decompression

This feature allows you to perform stream-based compression and decompression, which is useful for handling large datasets or files. The code sample demonstrates how to use the Deflate and Inflate classes to compress and decompress data in a streaming manner.

const fflate = require('fflate');
const { Deflate, Inflate } = fflate;
const deflateStream = new Deflate();
deflateStream.push(new Uint8Array([/* some data */]), true);
const compressed = deflateStream.result;
const inflateStream = new Inflate();
inflateStream.push(compressed, true);
const decompressed = inflateStream.result;

Other packages similar to fflate

Keywords

FAQs

Package last updated on 07 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc