Skip to content

Commit 0f7fa06

Browse files
committed
Translated SuperDebug from ts to js with jsdoc
1 parent ce2f471 commit 0f7fa06

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/lib/client/SuperDebug.svelte

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
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) {
@@ -32,9 +38,9 @@
3238
.replace(/&/g, '&amp;')
3339
.replace(/</g, '&lt;')
3440
.replace(/>/g, '&gt;');
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)) {
@@ -73,7 +79,11 @@
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
}

0 commit comments

Comments
 (0)