Last active
August 11, 2020 04:03
-
-
Save sebmarkbage/bdefa100f19345229d526d0fdd22830f to your computer and use it in GitHub Desktop.
Revisions
-
sebmarkbage revised this gist
May 15, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ The current execution context has a "custom stack" context with two internal slo `console.endStack` - Clear the `[[Custom Stack Start]]` and `[[Custom Stack Override]]` stacks. `console.trace`, `console.warn`, `console.error` etc. - For any function that logs stacks associated with the call. If there is something in the `[[Custom Stack Start]]` slot. Find the current stack from the current execution context. Find the common ancestor between `[[Custom Stack Start]]` and the current stack. Remove all the common ancestors. Replace them with `[[Custom Stack Override]]` in the root of the stack. If a break point happens, e.g. due to an error being thrown, `debugger` call or custom break points. If there is something in the `[[Custom Stack Start]]` slot, use the same mechanism as `console.log` to determine the current stack to visualize in a debugger instead of the native stack. The `scope` property contains an object. Every "own" property is considered to be a variable with that name in scope of that stack frame. Useful for debugging. -
sebmarkbage renamed this gist
May 15, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
sebmarkbage renamed this gist
May 15, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ function bar(x) { stack: [ { name: 'bar', fileName: 'Bar.js', lineNumber: 10, columnNumber: 5, } @@ -29,5 +29,5 @@ var continuation = bar(false); invokeCallback(continuation); // Logs: // You must provide the x argument. // at foo (Example.js:3:4) // at bar (Bar.js:10:5) -
sebmarkbage revised this gist
May 15, 2017 . 2 changed files with 33 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ function foo(x) { if (!x) { console.warn('You must provide the x argument.'); } } function bar(x) { return { stack: [ { name: 'bar', fileName: 'bar.js', lineNumber: 10, columnNumber: 5, } ], callback: foo.bind(null, x) }; } function invokeCallback(continuation) { console.stack(continuation.stack); continuation.callback(); console.endStack(); } var continuation = bar(false); invokeCallback(continuation); // Logs: // You must provide the x argument. // at foo (Examples.js:3:4) // at bar (bar.js:10:5) -
sebmarkbage revised this gist
May 15, 2017 . 2 changed files with 11 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,16 @@ type FrameScope = { [key:string]: mixed }; type StackFrame = { name?: string, fileName?: string, lineNumber?: number, columnNumber?: number, scope?: FrameScope }; type StackFrames = Array<StackFrame>; type ExtendedConsoleAPI = { ...ConsoleAPI, stack(frames: StackFrames) : void, endStack() : void }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,8 @@ The current execution context has a "custom stack" context with two internal slo `console.endStack` - Clear the `[[Custom Stack Start]]` and `[[Custom Stack Override]]` stacks. `console.log`, `console.warn`, `console.error` etc. - For any function that logs stacks associated with the call. If there is something in the `[[Custom Stack Start]]` slot. Find the current stack from the current execution context. Find the common ancestor between `[[Custom Stack Start]]` and the current stack. Remove all the common ancestors. Replace them with `[[Custom Stack Override]]` in the root of the stack. If a break point happens, e.g. due to an error being thrown, `debugger` call or custom break points. If there is something in the `[[Custom Stack Start]]` slot, use the same mechanism as `console.log` to determine the current stack to visualize in a debugger instead of the native stack. The `scope` property contains an object. Every "own" property is considered to be a variable with that name in scope of that stack frame. Useful for debugging. TODO: Consider what should happen to `new Error().stack` if the error is created within a custom scope. -
sebmarkbage created this gist
May 15, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ type StackFrame = { name?: string, fileName?: string, lineNumber?: number, columnNumber?: number }; type StackFrames = Array<StackFrame>; type ExtendedConsoleAPI = { ...ConsoleAPI, stack(frames: StackFrames) : void, endStack() : void, }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ The current execution context has a "custom stack" context with two internal slots `[[Custom Stack Start]]` and `[[Custom Stack Override]]`. `console.stack` - Assert that the first argument is an array. Store the current stack frame context at the VM level (same as `new Error().stack`) in the current execution context's `[[Custom Stack Start]]` slot. Store the first argument array in the current execution context's `[[Custom Stack Override]]` slot. `console.endStack` - Clear the `[[Custom Stack Start]]` and `[[Custom Stack Override]]` stacks. `console.log`, `console.warn`, `console.error` etc. - For any function that logs stacks associated with the call. If there is something in the `[[Custom Stack Start]]` slot. Find the current stack from the current execution context. Find the common ancestor between `[[Custom Stack Start]]` and the current stack. Remove all the common ancestors and replace them with [[Custom Stack Override]].