website: snapshot

This commit is contained in:
nym21
2026-02-02 18:39:42 +01:00
parent cf4bc470e4
commit b23d20ea05
44 changed files with 2637 additions and 2800 deletions

View File

@@ -18,3 +18,20 @@ export function range(start, end) {
export function randomFromArray(array) {
return array[Math.floor(Math.random() * array.length)];
}
/**
* Typed Object.entries that preserves key types
* @template {Record<string, any>} T
* @param {T} obj
* @returns {[keyof T & string, T[keyof T & string]][]}
*/
export const entries = (obj) => /** @type {[keyof T & string, T[keyof T & string]][]} */ (Object.entries(obj));
/**
* Type-safe includes that narrows the value type
* @template T
* @param {readonly T[]} arr
* @param {unknown} value
* @returns {value is T}
*/
export const includes = (arr, value) => arr.includes(/** @type {T} */ (value));