Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nativescript-zip

triniwiz59Apache-2.04.0.2TypeScript support: included

A simple utility class for zipping and unzipping files in NativeScript

NativeScript, JavaScript, Android, iOS, Zip

readme

npm npm Build Status

NativeScript Zip

Installation

NativeScript 4x

  • tns plugin add nativescript-zip

NativeScript 2x & 3x

  • tns plugin add nativescript-zip@2.0.4

Usage

Zip

import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let path = fs.path.join(fs.knownFolders.temp().path, "stuff");
let dest = fs.path.join(fs.knownFolders.documents().path, "/assets");
Zip.zip({
    folder: path,
    destination: dest
});

Progress

import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let path = fs.path.join(fs.knownFolders.temp().path, "stuff");
let dest = fs.path.join(fs.knownFolders.documents().path, "/assets");
Zip.zip({
    folder: path,
    destination: dest,
    onProgress: onZipProgress
});

function onZipProgress(percent: number) {
    console.log(`unzip progress: ${percent}`);
}

Unzip

import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let zipPath = fs.path.join(fs.knownFolders.temp().path, "stuff.zip");
let dest = fs.path.join(fs.knownFolders.documents().path, "/assets");
Zip.unzip({
    archive: zipPath,
    destination: dest
});

Progress

import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let zipPath = fs.path.join(fs.knownFolders.temp().path, "stuff.zip");
let dest = fs.path.join(fs.knownFolders.documennts().path, "/assets");
Zip.unzip({
    archive: zipPath,
    destination: dest,
    onProgress: onUnZipProgress
});

function onUnZipProgress(percent: number) {
    console.log(`unzip progress: ${percent}`);
}

TODO

  • <input checked="" disabled="" type="checkbox"> Compress method
  • <input checked="" disabled="" type="checkbox"> Progress