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

Open-graph meta data tags introdution

What is 'this.' keyword in JavaScript

what is 'array.includes' function in JavaScript

What is a bin directory

How to build a twitter retweet bot using JavaScript