File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 1- <script lang = " ts " >
1+ <script >
22 import { page } from ' $app/stores' ;
33
44 export let display = true ;
55 export let status = true ;
6- export let data: any ;
6+ /** @type {any} */
7+ export let data;
78 export let stringTruncate = 120 ;
8- export let ref: HTMLPreElement | undefined = undefined ;
9+ /** @type {HTMLPreElement | undefined} */
10+ export let ref = undefined ;
911 export let label = ' ' ;
1012 export let promise = false ;
1113
12- function syntaxHighlight(json : any ) {
13- json = JSON .stringify (
14+ /**
15+ * @param {any} json
16+ * @returns {string}
17+ */
18+ function syntaxHighlight (json ) {
19+ const encodedString = JSON .stringify (
1420 json,
1521 function (key , value ) {
1622 if (value === undefined ) {
3238 .replace (/ &/ g , ' &' )
3339 .replace (/ </ g , ' <' )
3440 .replace (/ >/ g , ' >' );
35- return json .replace (
41+ return encodedString .replace (
3642 / ("(\\ u[a-zA-Z0-9 ] {4} | \\ [^ u] | [^ \\ "] )* "(\s * :)? | \b (true| false| null)\b | -? \d + (?:\. \d * )? (?:[eE][+\- ] ? \d + )? )/ g ,
37- function (match : string ) {
43+ function (match ) {
3844 let cls = ' number' ;
3945 if (/ ^ "/ .test (match)) {
4046 if (/ :$ / .test (match)) {
7379 );
7480 }
7581
76- async function promiseSyntaxHighlight(json : any ) {
82+ /**
83+ * @param {any} json
84+ * @returns {Promise<string>}
85+ */
86+ async function promiseSyntaxHighlight (json ) {
7787 json = await json;
7888 return syntaxHighlight (json);
7989 }
You can’t perform that action at this time.
0 commit comments