/
githubmirror
/
tldraw
Обзор
Документация
Войти
/
githubmirror
/
tldraw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/utils/src/lib/iterable.ts
20 строк
492 B
Steve Ruiz
Automate docs, sort of (#6722)
06 окт 2025, 12:57
Не верифицирован
06 окт 2025, 12:57
4197e7a
Код
Авторство
О чём код?
/** * Get the first item from an iterable Set or Map. * * @param value - The iterable Set or Map to get the first item from * @returns The first value from the Set or Map * @example * ```ts * const A = getFirstFromIterable(new Set([1, 2, 3])) // 1 * const B = getFirstFromIterable( * new Map([ * ['a', 1], * ['b', 2], * ]) * ) // 1 * ``` * @public */ export function getFirstFromIterable<T = unknown>(set: Set<T> | Map<any, T>): T { return set.values().next().value! }