Skip to content

Commit 37c6ae6

Browse files
authored
Merge pull request #1215 from NativeScript/vmutafov/remove-regex-check
Remove unnecessary use of regex
2 parents 8ee88c2 + 98eeff7 commit 37c6ae6

File tree

9 files changed

+9
-18
lines changed

9 files changed

+9
-18
lines changed

test-app/app/src/main/assets/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/decorated_double_assignment_ts/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/decorated_extends_ts/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/directory_with_dashes/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/extends/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/extends_with_interfaces/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/extends_with_interfaces_ts/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/file_names_with_dots/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

test-app/build-tools/jsparser/tests/cases/mini_app/internal/ts_helpers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
};
4949

5050
var __extends = function (Child, Parent) {
51-
const NATIVE_CODE_REGEX = /\{\s*\[native code\]\s*\}/g;
52-
var extendNativeClass = !!Parent.extend && NATIVE_CODE_REGEX.test(Parent.extend.toString());
51+
var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
5352
if (!extendNativeClass) {
5453
__extends_ts(Child, Parent);
5554
return;

0 commit comments

Comments
 (0)