Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update inspect-source.js #1382

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/core-js/internals/inspect-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ var functionToString = uncurryThis(Function.toString);
// this helper broken in `[email protected]`, so we can't use `shared` helper
if (!isCallable(store.inspectSource)) {
store.inspectSource = function (it) {
return functionToString(it);
try {
return isCallable(it) ? functionToString(it) : '';
Copy link
Owner

@zloirock zloirock Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should throw an error for non-callable objects. As I wrote, take a look at #1381 (comment)

} catch (error) {
// Fallback to an empty string if `functionToString` fails
return '';
}
};
}

Expand Down