How to create zip archives in nodejs

I'm going to compile ways in which you can create archives compressed using zip algorithm in nodejs or a similar JavaScript runtime.

node-zip is an open source zip archiving utility authord by daraosn and folked from jszip capable of compresding files into a zip archive and extracting zip archives in JavaScript.

node-zip is available on npm you can install it in your terminal window by typing;

npm install node-zip

example usage

const  zip = new require('node-zip')()
zip.file('test.file', 'John Swana')

const data = zip.generate({base64:false,compression:'DEFLATE'})
console.log(data)

How to unzip a zip archive

const zip = new require('node-zip')(data, {base64: false, checkCRC32: true})
console.log(zip.files['test.file'])

Comments

Popular posts from this blog

How to resume a suspended web audio api context

Ways of iterating Object properties in JavaScript

Es6 new features summarized round up

How to use fetch api submit an html form

Introduction to Kotlin programing language