Skip to content

Commit f4ff4f2

Browse files
committed
Simplify toSource.
1 parent 06412d5 commit f4ff4f2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lodash.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5291,8 +5291,8 @@
52915291
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
52925292
getTag = function(value) {
52935293
var result = objectToString.call(value),
5294-
Ctor = result == objectTag ? value.constructor : null,
5295-
ctorString = toSource(Ctor);
5294+
Ctor = result == objectTag ? value.constructor : undefined,
5295+
ctorString = Ctor ? toSource(Ctor) : undefined;
52965296

52975297
if (ctorString) {
52985298
switch (ctorString) {
@@ -5791,12 +5791,15 @@
57915791
* @returns {string} Returns the source code.
57925792
*/
57935793
function toSource(func) {
5794-
if (isFunction(func)) {
5794+
if (func != null) {
57955795
try {
57965796
return funcToString.call(func);
57975797
} catch (e) {}
5798+
try {
5799+
return (func + '');
5800+
} catch (e) {}
57985801
}
5799-
return toString(func);
5802+
return '';
58005803
}
58015804

58025805
/**

0 commit comments

Comments
 (0)