SkillAgentSearch skills...

Zipread

Fast and memory efficient ZIP reader for Node.js

Install / Use

/learn @szastupov/Zipread
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

zipread

NPM version Build status Build status

zipread is a ZIP file reader designed for speed and memory efficiency. Unlike other modules, it doesn't read the whole file into memory and uses native ZLIB functions for decompression.

var zipread = require("zipread");
var zip = zipread("file.zip");

var contents = zip.readFileSync("some_file.txt").toString();

// Or for async version:
zip.readFile("some_file.txt", function (err, buf) {
	contents = buf.toString();
});

zipread/hooks

zipread also provides a set of fs hooks to require node modules directly from ZIP.

Create a modules archive:

$ (cd node_modules && zip -r ../mods.zip *)
$ rm -r node_modules

Require a module explicitly:

require("zipread/hooks"); // Install hooks
require("./mods.zip/request");	// Load 'request' from mods.zip

Or implicitly by setting NODE_PATH:

$ NODE_PATH=./mods.zip node ./yourapp.js

In this case, you still have to require the hook but the rest can be untouched:

require("zipread/hooks");
require("request");

A good use case for this would be shipping desktop applications. For example, Windows doesn't like long paths and putting your huge node_modules directory into a single archive should solve this problem.

View on GitHub
GitHub Stars12
CategoryDevelopment
Updated4y ago
Forks2

Languages

JavaScript

Security Score

65/100

Audited on Jul 12, 2021

No findings