forked from mockingbot/react-native-zip-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (32 loc) · 954 Bytes
/
Copy pathindex.js
File metadata and controls
39 lines (32 loc) · 954 Bytes
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
'use strict'
var React = require('react-native')
var { DeviceEventEmitter, NativeAppEventEmitter, Platform } = React
var RNZipArchive = React.NativeModules.RNZipArchive
var _unzip = RNZipArchive.unzip
var _zip = RNZipArchive.zip
var _unzipAssets = RNZipArchive.unzipAssets ? RNZipArchive.unzipAssets : undefined
var _error = (err) => {
throw err
}
var ZipArchive = {
unzip(source, target) {
return _unzip(source, target)
.catch(_error)
},
zip(source, target) {
return _zip(source, target)
.catch(_error)
},
unzipAssets(source, target) {
if (!_unzipAssets) {
throw new Error("unzipAssets not supported on this platform");
}
return _unzipAssets(source, target)
.catch(_error)
},
subscribe(callback) {
var emitter = Platform.OS == 'ios' ? NativeAppEventEmitter : DeviceEventEmitter;
return emitter.addListener("zipArchiveProgressEvent", callback);
}
}
module.exports = ZipArchive