![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
It's a utility of zlib, gzip and zip format binary data.
chrome, firefox, Edge, safari, opera.
@type {string | number[] | ArrayBuffer | Uint8Array | Int8Array | Uint8ClampedArray}
jz.common.readFileAsArrayBuffer(blob).then(buffer => {
// ...
});
"UTF-8"
)jz.common.bytesToString(bytes).then(str => {
// ...
});
let concated = jz.common.concatBytes([bytes1, bytes2]);
// or
let concated = jz.common.concatBytes(bytes1, bytes2);
It loads files as Uint8Array
.
jz.common.load(['foo.png', 'bar.jpg']).then(([foo, bar]) => {
// ...
});
// or
jz.common.load('foo.png', 'bar.jpg').then(([foo, bar]) => {
// ...
});
6
, range is 0-9)0x8000
)0x8000
)6
)false
)0x8000
)jz.stream.core.deflate({
buffer: buffer,
streamFn: chunk => {
// ...
},
shareMemory: false,
});
false
)0x8000
)6
)0x8000
)0x8000
)6
)false
)0x8000
)false
)0x8000
)6
)0x8000
)0x8000
)6
)false
)0x8000
)false
)0x8000
)6
)0x8000
)var files = [
{
name: 'foo',
dir: [
// folder
{ name: 'hello.txt', buffer: 'Hello World!' }, // string
{ name: 'bar.js', buffer: buffer }, // ArrayBuffer
{ name: 'hoge.mp3', url: 'audiodata/hoge.mp3' }, // xhr
],
},
];
jz.zip
.pack({
files: files,
level: 5,
})
.then(buffer => {
// buffer is Uint8Array
});
// You cat set compression level to each files.
var files = [
{ name: 'mimetype', buffer: 'application/epub+zip', level: 0 }, //string
{
name: 'META-INF',
dir: [
//folder
{ name: 'container.xml', buffer: buffer, level: 0 }, //ArrayBuffer
],
},
{ name: 'package.opf', url: 'package.opf', level: 6 },
{ name: 'foo.xhtml', url: 'foo.xhtml', level: 9 }, //xhr
];
jz.zip.pack({ files }).then(buffer => {
// ...
});
"UTF-8"
)0x8000
)jz.zip
.unpack({
buffer: buffer,
encoding: 'Shift_JIS', // encoding of filenames
})
.then(reader => {
// reader is ZipArchiveReader. See below.
// get file names.
reader.getFileNames();
reader.readFileAsText(reader.getFileNames[0]).then(text => {
// ...
});
});
6
)false
)0x8000
)jz.stream.zip
.pack({
files: files,
streamFn: chunk => {
// ...
},
})
.then(() => {
// no args
});
It gets filenames in the zip archive.
Low level zip archive writer.
false
)0x8000
)const writer = new jz.zip.ZipArchiveWriter({ shareMemory: true, chunkSize: 0xf000 });
writer
.on('data', chunk => {
// chunk is Uint8Array.
})
.on('end', () => {
// ...
})
.write('foo/bar/baz.txt', buffer)
.write('a.mp3', mp3Buff)
.writeEnd();
Write the file. Directories are created automatically.
6
)writer.write('a/b/c/d/foo.txt', buffer, 7);
writer.writeDir('foo/');
// or
writer.writeDir('bar');
6
)writer.writeDir('a/');
writer.writeDir('a/b/');
writer.writeDir('a/b/c/');
writer.writeFile('a/b/c/foo.txt', buffer, 7);
Write central directory headers and the end central dirctory header.
writer.writeEnd();
You can import modules separately.
import {deflate} from "jsziptools/core";
import * as zip from "jsziptools/zip";
deflate(...);
zip.pack(...).then();
FAQs
It's a utility of zlib, gzip and zip format binary data.
The npm package jsziptools receives a total of 0 weekly downloads. As such, jsziptools popularity was classified as not popular.
We found that jsziptools demonstrated a not healthy version release cadence and project activity because the last version was released 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.