Skip to content

A javascript library that can stream zip files requires a WASM environment.

License

Notifications You must be signed in to change notification settings

hpp2334/slight-stream-archiver

Repository files navigation

Slight Stream Archiver

Main npm version codecov

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

About

A javascript library that can stream zip files requires a WASM environment.

Resources

License

Stars

Watchers

Forks