Skip to content

Commit c5450ac

Browse files
committed
Directly export functions
1 parent 471b9ac commit c5450ac

File tree

1 file changed

+6
-8
lines changed
  • debug_toolbar/static/debug_toolbar/js

1 file changed

+6
-8
lines changed

debug_toolbar/static/debug_toolbar/js/utils.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const $$ = {
1+
export const $$ = {
22
on(root, eventName, selector, fn) {
33
root.removeEventListener(eventName, fn);
44
root.addEventListener(eventName, (event) => {
@@ -70,7 +70,7 @@ const $$ = {
7070
},
7171
};
7272

73-
async function ajax(url, init) {
73+
export async function ajax(url, init) {
7474
try {
7575
const response = await fetch(url, {
7676
credentials: "same-origin",
@@ -81,7 +81,7 @@ async function ajax(url, init) {
8181
return response.json();
8282
} catch (error) {
8383
throw new Error(
84-
u`The response is a invalid Json object : ${error}`
84+
`The response is a invalid Json object : ${error}`
8585
);
8686
}
8787
}
@@ -94,7 +94,7 @@ async function ajax(url, init) {
9494
}
9595
}
9696

97-
function ajaxForm(element) {
97+
export function ajaxForm(element) {
9898
const form = element.closest("form");
9999
const url = new URL(form.action);
100100
const formData = new FormData(form);
@@ -107,7 +107,7 @@ function ajaxForm(element) {
107107
return ajax(url, ajaxData);
108108
}
109109

110-
function replaceToolbarState(newRequestId, data) {
110+
export function replaceToolbarState(newRequestId, data) {
111111
const djDebug = document.getElementById("djDebug");
112112
djDebug.setAttribute("data-request-id", newRequestId);
113113
// Check if response is empty, it could be due to an expired requestId.
@@ -121,7 +121,7 @@ function replaceToolbarState(newRequestId, data) {
121121
}
122122
}
123123

124-
function debounce(func, delay) {
124+
export function debounce(func, delay) {
125125
let timer = null;
126126
let resolves = [];
127127

@@ -138,5 +138,3 @@ function debounce(func, delay) {
138138
return await new Promise((r) => resolves.push(r));
139139
};
140140
}
141-
142-
export { $$, ajax, ajaxForm, debounce, replaceToolbarState };

0 commit comments

Comments
 (0)