This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script lang="ts"> | |
let data = $state(null); | |
async function loadSmallData() { | |
const response = await fetch('https://meowfacts.herokuapp.com/?count=2'); | |
if (!response.ok) { | |
throw new Error(`Failed to fetch data: ${response.statusText}`); | |
} | |
data = (await response.json()).data; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"timezones": [{ | |
"name": "Pacific/Niue", | |
"offset": "(GMT-11:00) Niue" | |
}, { | |
"name": "Pacific/Pago_Pago", | |
"offset": "(GMT-11:00) Pago Pago" | |
}, { | |
"name": "Pacific/Honolulu", | |
"offset": "(GMT-10:00) Hawaii Time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div | |
class="sl-vue-tree" | |
:class="{ 'sl-vue-tree-root': isRoot }" | |
@mousemove="onMousemoveHandler" | |
@mouseleave="onMouseleaveHandler" | |
@dragend="onDragendHandler(null, $event)" | |
> | |
<div ref="nodes" class="sl-vue-tree-nodes-list"> | |
<div |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const categories = [ | |
{ | |
_id: 1, | |
index: 1000, | |
name: 'pictures', | |
level: 1, | |
children: [] | |
}, | |
{ | |
_id: 2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ASIDE: replace multiple ${} in a string with a JSON reference. | |
const replacer = (str: string, obj: object) : object => { | |
const keys = Object.keys(obj); | |
const func = Function(...keys, "return `" + str + "`;"); | |
return func(...keys.map(k => obj[k])); | |
} | |
let s = "I'm ${name} from ${country}" | |
let replaced = replacer(s, {name: 'SS', country: 'MSIA'}) | |
console.log(replaced) |