forked from Wraptime/react-native-get-real-path
-
Notifications
You must be signed in to change notification settings - Fork 2
/
GRP.common.js
35 lines (26 loc) · 823 Bytes
/
GRP.common.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
'use strict';
// This file supports both iOS and Android
// Stop bluebird going nuts because it can't find "self"
if (typeof self === 'undefined') {
global.self = global;
}
var GRP = require('react-native').NativeModules.GRP;
var NativeAppEventEmitter = require('react-native').NativeAppEventEmitter;
var Promise = require('bluebird');
var _getRealPathFromURI = Promise.promisify(GRP ? GRP.getRealPathFromURI : (fileUri) => { return fileUri; });
var convertError = (err) => {
if (err.isOperational && err.cause) {
err = err.cause;
}
var error = new Error(err.description || err.message);
error.code = err.code;
throw error;
};
var RNGRP = {
getRealPathFromURI(fileUri) {
return _getRealPathFromURI(fileUri)
.then(path => path)
.catch(convertError);
}
};
module.exports = RNGRP;