Skip to content

Commit be8de1c

Browse files
committed
converted to TS
1 parent 2c87bd4 commit be8de1c

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"name": "@ami3goltd/react-native-honeywell-scanner",
33
"title": "React Native Honeywell Scanner",
44
"version": "0.0.1",
5-
"description": "Module for Honeywell scanner",
6-
"main": "index.js",
5+
"description": "Bridge to use the Honeywell scanner",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
78
"scripts":
89
{
9-
"test": "echo \"Error: no test specified\" && exit 1"
10+
"test": "echo \"Error: no test specified\" && exit 1",
11+
"build": "tsc"
1012
},
1113
"repository":
1214
{
@@ -34,12 +36,12 @@
3436
"readmeFilename": "README.md",
3537
"peerDependencies":
3638
{
37-
"react": "^16.12.0",
38-
"react-native": "^0.61.5"
39+
"react": "^16.13.1",
40+
"react-native": "^0.63.3"
3941
},
4042
"devDependencies":
4143
{
42-
"react": "^16.12.0",
43-
"react-native": "^0.61.5"
44+
"react": "^16.13.1",
45+
"react-native": "^0.63.3"
4446
}
4547
}

index.js renamed to src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const ReactNative = require('react-native');
2-
const { NativeModules, DeviceEventEmitter } = ReactNative;
3-
const HoneywellScanner = NativeModules.HoneywellScanner || {};
1+
import { NativeModules, DeviceEventEmitter } from 'react-native';
2+
3+
const { HoneywellScanner } = NativeModules;
44

55
/**
66
* Listen for available events
@@ -11,11 +11,13 @@ const HoneywellScanner = NativeModules.HoneywellScanner || {};
1111
var subscriptionBarcodeReadSuccess = null;
1212
var subscriptionBarcodeReadFail = null;
1313

14-
HoneywellScanner.onBarcodeReadSuccess = (handler) => {
14+
HoneywellScanner.onBarcodeReadSuccess = (handler) =>
15+
{
1516
subscriptionBarcodeReadSuccess = DeviceEventEmitter.addListener(HoneywellScanner.BARCODE_READ_SUCCESS, handler)
1617
}
1718

18-
HoneywellScanner.onBarcodeReadFail = (handler) => {
19+
HoneywellScanner.onBarcodeReadFail = (handler) =>
20+
{
1921
subscriptionBarcodeReadFail = DeviceEventEmitter.addListener(HoneywellScanner.BARCODE_READ_FAIL, handler)
2022
}
2123

@@ -24,10 +26,12 @@ HoneywellScanner.onBarcodeReadFail = (handler) => {
2426
* @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
2527
* @param {Function} handler Event handler
2628
*/
27-
HoneywellScanner.offBarcodeReadSuccess = () => {
29+
HoneywellScanner.offBarcodeReadSuccess = () =>
30+
{
2831
subscriptionBarcodeReadSuccess.remove()
2932
};
30-
HoneywellScanner.offBarcodeReadFail = () => {
33+
HoneywellScanner.offBarcodeReadFail = () =>
34+
{
3135
subscriptionBarcodeReadFail.remove()
3236
};
3337

tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions":
3+
{
4+
"module": "commonjs",
5+
"target": "es2015",
6+
"declaration": true,
7+
"outDir": "./dist"
8+
}
9+
}

0 commit comments

Comments
 (0)