Skip to content

Commit

Permalink
refactor: expose only index.js file
Browse files Browse the repository at this point in the history
Remove the old school index.ios.js and index.android.js which could lead to some bad Developer Experience
  • Loading branch information
PierreCapo committed May 6, 2020
1 parent 363fdcc commit 54dce2a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 54 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ PODS:
- React-jsinspector (0.62.0)
- react-native-cameraroll (1.5.2):
- React
- react-native-image-resizer (1.2.0):
- react-native-image-resizer (1.2.2):
- React
- React-RCTActionSheet (0.62.0):
- React-Core/RCTActionSheetHeaders (= 0.62.0)
Expand Down Expand Up @@ -435,7 +435,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 8bf0b2707f05865113415088c398a7f98c0cf546
React-jsinspector: 8e5913c4c6c54f0d3f9c9fc630c465a89cded65d
react-native-cameraroll: 4360c9faab50dc6844f56d222c2d0c7ef5f1fe92
react-native-image-resizer: efae8dd718cbd47755df95aa45ad859e701ad7d8
react-native-image-resizer: e794dc2dbd0db0a1062ac5fa425d5df04c1970ca
React-RCTActionSheet: 674afbc8b9c76e0a83520e0a51da29a70802c03f
React-RCTAnimation: f5f24330d09ee677fb49e0782f8321868f4df431
React-RCTBlob: b773ce6138ab0d172ebd8a455fd4efd200a92549
Expand Down
22 changes: 0 additions & 22 deletions index.android.js

This file was deleted.

29 changes: 0 additions & 29 deletions index.ios.js

This file was deleted.

65 changes: 65 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { NativeModules, Platform } from 'react-native';

const ImageResizerAndroid = NativeModules.ImageResizerAndroid;

let exportObject = {};

if (Platform.OS === 'android') {
exportObject = {
createResizedImage: (
imagePath,
newWidth,
newHeight,
compressFormat,
quality,
rotation = 0,
outputPath,
keepMeta = false
) => {
return new Promise((resolve, reject) => {
ImageResizerAndroid.createResizedImage(
imagePath,
newWidth,
newHeight,
compressFormat,
quality,
rotation,
outputPath,
keepMeta,
resolve,
reject
);
});
},
};
} else {
exportObject = {
createResizedImage: (path, width, height, format, quality, rotation = 0, outputPath, keepMeta = false) => {
if (format !== 'JPEG' && format !== 'PNG') {
throw new Error('Only JPEG and PNG format are supported by createResizedImage');
}

return new Promise((resolve, reject) => {
NativeModules.ImageResizer.createResizedImage(
path,
width,
height,
format,
quality,
rotation,
outputPath,
keepMeta,
(err, response) => {
if (err) {
return reject(err);
}

resolve(response);
}
);
});
},
};
}

export default exportObject;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "react-native-image-resizer",
"version": "1.2.1",
"version": "1.2.2",
"description": "Rescale local images with React Native",
"main": "./index.js",
"types": "./index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/bamlab/react-native-image-resizer.git"
Expand Down

0 comments on commit 54dce2a

Please sign in to comment.