Skip to content

Commit 45e6ba6

Browse files
authored
Merge pull request #77 from chirag04/es-6
es6 syntax
2 parents b550449 + 1d7e47b commit 45e6ba6

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

index.js

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,32 @@
1-
'use strict'
1+
import ReactNative from 'react-native'
22

3-
var React = require('react-native')
4-
var { DeviceEventEmitter, NativeAppEventEmitter, Platform } = React
3+
const {
4+
DeviceEventEmitter,
5+
NativeAppEventEmitter,
6+
Platform,
7+
NativeModules
8+
} = ReactNative
59

6-
var RNZipArchive = React.NativeModules.RNZipArchive
10+
const RNZipArchive = NativeModules.RNZipArchive
711

8-
var _unzip = RNZipArchive.unzip
9-
var _zip = RNZipArchive.zip
10-
var _unzipAssets = RNZipArchive.unzipAssets ? RNZipArchive.unzipAssets : undefined
11-
12-
var _error = (err) => {
13-
throw err
14-
}
15-
16-
var ZipArchive = {
12+
const ZipArchive = {
1713
unzip (source, target) {
18-
return _unzip(source, target)
19-
.catch(_error)
14+
return RNZipArchive.unzip(source, target)
2015
},
2116
zip (source, target) {
22-
return _zip(source, target)
23-
.catch(_error)
17+
return RNZipArchive.zip(source, target)
2418
},
2519
unzipAssets (source, target) {
26-
if (!_unzipAssets) {
20+
if (!RNZipArchive.unzipAssets) {
2721
throw new Error('unzipAssets not supported on this platform')
2822
}
2923

30-
return _unzipAssets(source, target)
31-
.catch(_error)
24+
return RNZipArchive.unzipAssets(source, target)
3225
},
3326
subscribe (callback) {
3427
var emitter = Platform.OS === 'ios' ? NativeAppEventEmitter : DeviceEventEmitter
3528
return emitter.addListener('zipArchiveProgressEvent', callback)
3629
}
3730
}
3831

39-
module.exports = ZipArchive
32+
export default ZipArchive

0 commit comments

Comments
 (0)