slight-stream-archiver
v0.2.2
Published
A javascript library that can stream zip files requires a WASM environment
Downloads
192
Readme
Slight Stream Archiver
Introduction
A javascript library that can stream zip files requires a WASM environment. It wraps zip-rs to implement streaming archives.
Currently, zip is supported only.
Installation
npm i slight-stream-archiver
Example
import { ensureWasmLoaded, StreamZip, createJsonStringifyDataGenerator, createStringDataGenerator } from 'slight-stream-archiver'
async function work() {
// Initial WASM
await ensureWasmLoaded()
const zip = new StreamZip()
// add a.txt
zip.addFile('READMD.md', createStringDataGenerator('Hello World'))
// add folder "src"
zip.addFolder('src')
// add file "/src/package.json"
zip.addFile('src/package.json', createJsonStringifyDataGenerator({
name: "playground"
}))
// add file "/src/index.js"
zip.addFile('src/index.js', createStringDataGenerator("const a = 1;"))
// archive
const buf = zip.finish()
// ...
}
License
MIT