
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@tokenizer/inflate
Advanced tools
@tokenizer/inflate is a package designed for handling and extracting data from ZIP files efficiently using a tokenizer-based approach.
The library provides a customizable way to parse ZIP archives and extract compressed data while minimizing memory usage.
npm install @tokenizer/inflate
The following example demonstrates how to use the library to extract .txt files and stop processing when encountering a .stop file.
import { ZipHandler } from '@tokenizer/inflate';
import { fromFile } from 'strtok3';
const fileFilter = (file) => {
console.log(`Processing file: ${file.filename}`);
if (file.filename?.endsWith(".stop")) {
console.log(`Stopping processing due to file: ${file.filename}`);
return { handler: false, stop: true }; // Stop the unzip process
}
if (file.filename?.endsWith(".txt")) {
return {
handler: async (data) => {
console.log(`Extracted text file: ${file.filename}`);
console.log(new TextDecoder().decode(data));
},
};
}
return { handler: false }; // Ignore other files
};
async function extractFiles(zipFilePath) {
const tokenizer = await fromFile(zipFilePath);
const zipHandler = new ZipHandler(tokenizer);
await zipHandler.unzip(fileFilter);
}
extractFiles('example.zip').catch(console.error);
ZipHandlerA class for handling ZIP file parsing and extraction.
new ZipHandler(tokenizer: ITokenizer)
isZip(): Promise<boolean>
Determines whether the input file is a ZIP archive.
unzip(fileCb: InflateFileFilter): Promise<void>
Extracts files from the ZIP archive, applying the provided InflateFileFilter callback to each file.
InflatedDataHandler
InflateFileFiltertype InflateFileFilter = (file: IFullZipHeader) => InflateFileFilterResult;
Callback function to determine whether a file should be handled or ignored.
InflateFileFilterResulttype InflateFileFilterResult = {
handler: InflatedDataHandler | false; // Handle file data or ignore
stop?: boolean; // Stop processing further files
};
Returned from InflateFileFilter to control file handling and extraction flow.
InflatedDataHandlertype InflatedDataHandler = (fileData: Uint8Array) => Promise<void>;
Handler for processing uncompressed file data.
This module is a pure ECMAScript Module (ESM). The distributed JavaScript codebase is compliant with the ECMAScript 2020 (11th Edition) standard. If used with Node.js, it requires version ≥ 18.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
Tokenized zip support
The npm package @tokenizer/inflate receives a total of 9,152,442 weekly downloads. As such, @tokenizer/inflate popularity was classified as popular.
We found that @tokenizer/inflate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.