Skip to content

Instantly share code, notes, and snippets.

@brablc
Last active March 16, 2024 02:05
Show Gist options
  • Save brablc/13d742bdd9cf25977a7eb18d74a4fb14 to your computer and use it in GitHub Desktop.
Save brablc/13d742bdd9cf25977a7eb18d74a4fb14 to your computer and use it in GitHub Desktop.
Diogenes JS
<script>
function $debug(...args) {
console.log('debug', ...args);
}
function $on(eventName, callback) {
document.currentScript.parentElement.addEventListener(eventName, callback);
}
function $send(element, name, detail) {
let event = new CustomEvent(name, { detail: detail, bubbles: true });
element?.dispatchEvent(event);
}
function $sleep(ms, e) {
return new Promise((resolve) => setTimeout(() => resolve(e), ms));
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment