Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit e96565a

Browse files
ES2015 FTW!
1 parent c6aef9e commit e96565a

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/firebase.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ firebase.toJsObject = javaObj => {
282282
node[item.getKey()] = firebase.toJsObject(item.getValue());
283283
}
284284
} catch (e) {
285-
if (JSON.stringify(e).indexOf("Attempt to use cleared object reference") > -1) {
285+
if (JSON.stringify(e).includes("Attempt to use cleared object reference")) {
286286
console.log("Error while transforming Java to Js: " + e);
287287
} else {
288288
console.log("PLEASE REPORT THIS AT https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues: Tried to serialize an unsupported type: " + javaObj.getClass().getName() + ", error: " + e);
@@ -983,7 +983,7 @@ firebase.login = arg => {
983983
onVerificationFailed: firebaseException => {
984984
firebase._verifyPhoneNumberInProgress = false;
985985
const errorMessage = firebaseException.getMessage();
986-
if (errorMessage.indexOf("INVALID_APP_CREDENTIAL") > -1) {
986+
if (errorMessage.includes("INVALID_APP_CREDENTIAL")) {
987987
this.reject("Please upload the SHA1 fingerprint of your debug and release keystores to the Firebase console, see https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/docs/AUTHENTICATION.md#phone-verification");
988988
} else {
989989
this.reject(errorMessage);

src/mlkit/custommodel/custommodel-common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export abstract class MLKitCustomModel extends MLKitCameraView {
4848

4949
[labelsFileProperty.setNative](value: string) {
5050
this.labelsFile = value;
51-
if (value.indexOf("~/") === 0) {
51+
if (value.startsWith("~/")) {
5252
this.labels = getLabelsFromAppFolder(value);
5353
} else {
5454
// no dice loading from assets yet, let's advice users to use ~/ for now
@@ -91,4 +91,4 @@ export function getLabelsFromFile(labelsFile: string): Array<string> {
9191
lines.pop();
9292
}
9393
return lines;
94-
}
94+
}

src/mlkit/custommodel/index.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function getInterpreter(localModelFile?: string): any {
108108
} else {
109109
const firModelLocalBuilder = new com.google.firebase.ml.common.modeldownload.FirebaseLocalModel.Builder(localModelName);
110110

111-
if (localModelFile.indexOf("~/") === 0) {
111+
if (localModelFile.startsWith("~/")) {
112112
firModelLocalBuilder.setFilePath(fs.knownFolders.currentApp().path + localModelFile.substring(1));
113113
} else {
114114
// note that this doesn't seem to work, let's advice users to use ~/ for now
@@ -143,7 +143,7 @@ export function useCustomModel(options: MLKitCustomModelOptions): Promise<MLKitC
143143
const interpreter = getInterpreter(options.localModelFile);
144144

145145
let labels: Array<string>;
146-
if (options.labelsFile.indexOf("~/") === 0) {
146+
if (options.labelsFile.startsWith("~/")) {
147147
labels = getLabelsFromAppFolder(options.labelsFile);
148148
} else {
149149
// no dice loading from assets yet, let's advice users to use ~/ for now

src/mlkit/custommodel/index.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function getInterpreter(localModelFile: string): FIRModelInterpreter {
113113
localModelRegistrationSuccess = true;
114114
} else {
115115
let localModelFilePath: string;
116-
if (localModelFile.indexOf("~/") === 0) {
116+
if (localModelFile.startsWith("~/")) {
117117
localModelFilePath = fs.knownFolders.currentApp().path + localModelFile.substring(1);
118118
} else {
119119
localModelFilePath = NSBundle.mainBundle.pathForResourceOfType(
@@ -184,7 +184,7 @@ export function useCustomModel(options: MLKitCustomModelOptions): Promise<MLKitC
184184
});
185185

186186
let labels: Array<string>;
187-
if (options.labelsFile.indexOf("~/") === 0) {
187+
if (options.labelsFile.startsWith("~/")) {
188188
labels = getLabelsFromAppFolder(options.labelsFile);
189189
} else {
190190
const labelsFile = NSBundle.mainBundle.pathForResourceOfType(

0 commit comments

Comments
 (0)