File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,25 @@ const urlRegex = (() => {
8989} ) ( ) ;
9090
9191const padutils = {
92+ /**
93+ * Prints a warning message followed by a stack trace (to make it easier to figure out what code
94+ * is using the deprecated function).
95+ *
96+ * Most browsers include UI widget to examine the stack at the time of the warning, but this
97+ * includes the stack in the log message for a couple of reasons:
98+ * - This makes it possible to see the stack if the code runs in Node.js.
99+ * - Users are more likely to paste the stack in bug reports they might file.
100+ *
101+ * @param {...* } args - Passed to `console.warn`, with a stack trace appended.
102+ */
103+ warnWithStack : ( ...args ) => {
104+ const err = new Error ( ) ;
105+ if ( Error . captureStackTrace ) Error . captureStackTrace ( err , padutils . warnWithStack ) ;
106+ err . name = '' ;
107+ if ( err . stack ) args . push ( err . stack ) ;
108+ console . warn ( ...args ) ;
109+ } ,
110+
92111 escapeHtml : ( x ) => Security . escapeHTML ( String ( x ) ) ,
93112 uniqueId : ( ) => {
94113 const pad = require ( './pad' ) . pad ; // Sidestep circular dependency
You can’t perform that action at this time.
0 commit comments