Skip to content

Commit 3d37ee4

Browse files
committed
fixed an error on the overload
1 parent d9dbcb0 commit 3d37ee4

File tree

3 files changed

+55
-7
lines changed

3 files changed

+55
-7
lines changed

dist/breinify-api.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16040,7 +16040,7 @@ dependencyScope.jQuery = $;;
1604016040
},
1604116041

1604216042
_$overload: function (pointer, args, context, wrapper) {
16043-
let regex = /function\s+(\w+)s*/;
16043+
let regex = /function\s+(\w+)\s*/;
1604416044
let types = [];
1604516045

1604616046
// create a string to identify the structure of the signature
@@ -16053,7 +16053,31 @@ dependencyScope.jQuery = $;;
1605316053
type = '([A-Za-z0-9_\\-]+)';
1605416054
containsRegEx = true;
1605516055
} else {
16056-
type = regex.exec(arg.constructor.toString())[1];
16056+
16057+
let ctor = arg.constructor;
16058+
let name = 'Object';
16059+
16060+
if (typeof ctor === 'function') {
16061+
if (ctor.name && typeof ctor.name === 'string' && ctor.name.length > 0) {
16062+
// preferred: use the constructor's name directly
16063+
name = ctor.name;
16064+
} else {
16065+
// fallback: parse from function source, but guarded
16066+
try {
16067+
let match = regex.exec(ctor.toString());
16068+
if (match && match[1]) {
16069+
name = match[1];
16070+
}
16071+
} catch (e) {
16072+
// ignore and keep 'Object'
16073+
}
16074+
}
16075+
} else {
16076+
// non-function or weird constructor – treat it as a generic Object
16077+
name = 'Object';
16078+
}
16079+
16080+
type = name;
1605716081
}
1605816082

1605916083
types.push(type);

dist/breinify-api.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Breinify.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
},
5757

5858
_$overload: function (pointer, args, context, wrapper) {
59-
let regex = /function\s+(\w+)s*/;
59+
let regex = /function\s+(\w+)\s*/;
6060
let types = [];
6161

6262
// create a string to identify the structure of the signature
@@ -69,7 +69,31 @@
6969
type = '([A-Za-z0-9_\\-]+)';
7070
containsRegEx = true;
7171
} else {
72-
type = regex.exec(arg.constructor.toString())[1];
72+
73+
let ctor = arg.constructor;
74+
let name = 'Object';
75+
76+
if (typeof ctor === 'function') {
77+
if (ctor.name && typeof ctor.name === 'string' && ctor.name.length > 0) {
78+
// preferred: use the constructor's name directly
79+
name = ctor.name;
80+
} else {
81+
// fallback: parse from function source, but guarded
82+
try {
83+
let match = regex.exec(ctor.toString());
84+
if (match && match[1]) {
85+
name = match[1];
86+
}
87+
} catch (e) {
88+
// ignore and keep 'Object'
89+
}
90+
}
91+
} else {
92+
// non-function or weird constructor – treat it as a generic Object
93+
name = 'Object';
94+
}
95+
96+
type = name;
7397
}
7498

7599
types.push(type);

0 commit comments

Comments
 (0)