GithubHelp home page GithubHelp logo

ewwink / unzipjs Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 25 KB

2 kB Unzip (decompress) library for Javascript, no external dependency, work in Browser and Node.js

License: GNU General Public License v3.0

browser javascript nodejs unzip unzipper unzipping-files node-unzip

unzipjs's Introduction

unzipjs

Simple javascript library to Unzip/decompress a zipped file in Browser or Node.js.

I use this on Cloudflare workers because CF not natively support node.js, even you can install node zip library on CF it produce large bundled file, around 300 kB.

The method return array of object

[
  {
    name: "filename", 
    buffer: arrayBuffer, 
    toString: function() // convert buffer to string
  }
]

Installation

Download the files in dist directory

Browser

<script src="unzipjs.min.js"></script>

Nodejs

const unzipjs = require("/.unzipjs")
# or
import unzipjs from "/.unzipjs"

Unzip File

const fs = equire("fs")
const arraybuffer = fs.readFileSync('localfile.zip')

Unzip HTTP Response buffer

const arraybuffer = await fetch('https://example/file.zip').then(
  res => res.arrayBuffer()
);

Then

let unzipped = unzipjs.parse(arraybuffer);
for (let item of unzipped) {
   console.log(item.name)
   console.log(item.toString()) // if file not valid UTF8 return empty 
   console.log(item.buffer.length)
}

Limitation

  • No create .zip function
  • No save to file function

credit: UZIP

unzipjs's People

Contributors

ewwink avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.