Skip to content

Fall back on console.log when node-inspect-extracted fails #372

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion docs/js/online.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ $(document).ready(function() {
return problems;
});

function inspect(obj, opts) {
if (typeof util === 'object') {
return util.inspect(obj, opts);
}
console.warn("node-util-inspect not supported on this browser")
console.log(obj)
return String(obj) + " // See browser console"
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to swap hint and object representation, so the hint is always be visible in case of big objects

Suggested change
return String(obj) + " // See browser console"
return "// See browser console. Stringifyed result:\n" + String(obj)

}
function convertLocation(location) {
return CodeMirror.Pos(location.line - 1, location.column - 1);
}
Expand Down Expand Up @@ -165,7 +173,7 @@ $(document).ready(function() {
newInput.length,
timeAfter - timeBefore
));
$("#output").removeClass("disabled").text(util.inspect(output, {
$("#output").removeClass("disabled").text(inspect(output, {
depth: Infinity,
color: false,
maxArrayLength: Infinity,
Expand Down
6 changes: 3 additions & 3 deletions docs/online.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"/vendor/codemirror/lint.css"
]
scripts: [
"https://unpkg.com/jquery@1.12.4/dist/jquery.min.js",
"https://unpkg.com/[email protected].2/dist/FileSaver.min.js",
"https://unpkg.com/node-inspect-extracted@1.1.0/dist/inspect.js",
"https://unpkg.com/jquery@3.6.3/dist/jquery.js",
"https://unpkg.com/[email protected].5/dist/FileSaver.min.js",
"https://unpkg.com/node-inspect-extracted@2.0.0/dist/inspect.js",
"/vendor/peggy/peggy.min.js",
"/vendor/codemirror/codemirror.js",
"/vendor/codemirror/lint.js",
Expand Down