GithubHelp home page GithubHelp logo

jaybazuzi / deno-zip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moncefplastin07/deno-zip

0.0 0.0 0.0 83 KB

Streaming cross-platform zip tool written for Deno ๐Ÿฆ•.

License: MIT License

TypeScript 100.00%

deno-zip's Introduction

Deno Zip archive

Streaming cross-platform zip tool written for Deno ๐Ÿฆ•.

the module require permision below

  • --allow-run: for running unzipping command in command prompt
  • --allow-read: check the existence of the file before starting the decompression process.

import the module in your deno app

import {
  compress,
  decompress
} from "https://deno.land/x/[email protected]/mod.ts";

Usage:

Compressing

Compress files and folders to zip file with compress method addin: v1.2.0

interface CompressOptions {
  overwrite?: boolean;
}
compress(files:string | string[],
  archiveName: string = "./archive.zip",
  options?: CompressOptions):Promise<boolean>
decompress(filePath:string, [destinationPath]:string = './', options:{}): Promise<string | false>

arguments

  • files: (string) of one file or more or array of folders and files paths
  • archiveName: (string) string of name and destination path of zip file (Where do you want the get compressed zip file) by default is './archive.zip' (current working directory (CWD))
  • options: object of compressing options
  • overwrite: boolean

Examples:

// unZip From File
console.log(await compress("./myfiles")); //=> boolean
console.log(await compress("./mypicter.png", "new-dir/mypicter.zip")); //=> boolean
console.log(await compress(["./mypicters", "./textpalne.txt"], "compressed.zip", {overwrite:true})); //=> boolean

Decompressing

decompress(filePath:string, destinationPath:string = './', options:{}): Promise<string | false>

arguments

  • filePath: string of zip file path.
  • destinationPath: (null|string) null or string of destination path (Where do you want the unzipped files to be) as default is './' (current working directory (CWD))
  • options: object of unzipping options

return Promise<string | false> The destination path or false if the extraction process fails.

Examples:

// unZip From File
console.log(await decompress("myfile.zip")); //=> ./
console.log(await decompress("myfile.zip", "new-dir")); //=> new-dir
console.log(
  await decompress("myfile.zip", null, {
    includeFileName: true,
  }),
); //=> myfile
console.log(
  await decompress("myfile.zip", "new-dir", {
    includeFileName: true,
  }),
); //=> new-dir\myfile

Contribute with us from Here

deno-zip's People

Contributors

moncefplastin07 avatar dazhenhan avatar invalidcards avatar arnu515 avatar hazelnutcloud avatar jiawei397 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.