forked from mockingbot/react-native-zip-archive
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
57 lines (43 loc) · 1.67 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import ReactNative, { DeviceEventEmitter } from "react-native";
import RNZipArchive from "./src/NativeZipArchive"
const { NativeEventEmitter, NativeModules } = ReactNative;
// const RNZipArchive = NativeModules.RNZipArchive;
const rnzaEmitter = new NativeEventEmitter(RNZipArchive);
export const creteFile = (filePath, fileContent) => {
return RNZipArchive.creteFile(filePath, fileContent)
}
export const pathParameters = () => {
return RNZipArchive.pathParameters();
}
export const zip = (source, target) => {
return RNZipArchive.zip(source, target);
};
export const unzip = (source, target, charset = "UTF-8") => {
return RNZipArchive.unzip(source, target, charset);
};
export const zipWithPassword = (source, target, password, encryptionMethod = "") => {
return RNZipArchive.zipWithPassword(source, target, password, encryptionMethod)
};
export const unzipWithPassword = (source, target, password) => {
return RNZipArchive.unzipWithPassword(source, target, password);
};
export const isPasswordProtected = (source) => {
return RNZipArchive.isPasswordProtected(source);
};
export const subscribe = (callback) => {
const onZipArchiveProgressEvent = DeviceEventEmitter.addListener('zipArchiveProgressEvent', (progress) => {
callback({ progress });
if (progress === 100) {
onZipArchiveProgressEvent.remove();
}
})
};
export const unzipAssets = (source, target) => {
if (!RNZipArchive.unzipAssets) {
throw new Error("unzipAssets not supported on this platform");
}
return RNZipArchive.unzipAssets(source, target);
};
export const getUncompressedSize = (source, charset = "UTF-8") => {
return RNZipArchive.getUncompressedSize(source, charset);
};