global: snapshot

This commit is contained in:
nym21
2026-03-22 12:19:06 +01:00
parent f731f0d9d0
commit 514fdc40ee
35 changed files with 732 additions and 745 deletions

View File

@@ -1,6 +1,6 @@
/**
* Typed Object.entries that preserves key types
* @template {Record<string, any>} T
* @template {Record<string, unknown>} T
* @param {T} obj
* @returns {[keyof T & string, T[keyof T & string]][]}
*/

View File

@@ -183,8 +183,8 @@ export function createRadios({
choices,
initialValue,
onChange,
toKey = /** @type {(choice: T) => string} */ ((/** @type {any} */ c) => c),
toLabel = /** @type {(choice: T) => string} */ ((/** @type {any} */ c) => c),
toKey = /** @type {(choice: T) => string} */ ((c) => String(c)),
toLabel = /** @type {(choice: T) => string} */ ((c) => String(c)),
toTitle,
}) {
const field = window.document.createElement("div");
@@ -247,8 +247,8 @@ export function createSelect({
initialValue,
onChange,
sorted,
toKey = /** @type {(choice: T) => string} */ ((/** @type {any} */ c) => c),
toLabel = /** @type {(choice: T) => string} */ ((/** @type {any} */ c) => c),
toKey = /** @type {(choice: T) => string} */ ((c) => String(c)),
toLabel = /** @type {(choice: T) => string} */ ((c) => String(c)),
}) {
const choices = sorted
? unsortedChoices.toSorted((a, b) => toLabel(a).localeCompare(toLabel(b)))

View File

@@ -22,7 +22,7 @@ export function idle(callback) {
/**
*
* @template {(...args: any[]) => any} F
* @template {(...args: never[]) => unknown} F
* @param {F} callback
* @param {number} [wait]
*/
@@ -51,7 +51,7 @@ export function throttle(callback, wait = 1000) {
}
/**
* @template {(...args: any[]) => any} F
* @template {(...args: never[]) => unknown} F
* @param {F} callback
* @param {number} [wait]
* @returns {((...args: Parameters<F>) => void) & { cancel: () => void }}