/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/utils/data/uid.ts
65 строк
1 KB
Zyie
feat: simplified caching for text (#11505)
02 сен 2025, 15:27
Не верифицирован
02 сен 2025, 15:27
e301117
Код
Авторство
О чём код?
const uidCache: Record<string, number> = { default: -1, }; /** * The names of the unique identifiers. These are used to create unique identifiers for different types of objects. * @category utils * @internal */ export type UIDNames = | 'default' | 'resource' | 'texture' | 'textureSource' | 'textureResource' | 'batcher' // | 'graphicsContext' // | 'graphicsView' // | 'graphicsPath' // | 'fillGradient' // | 'fillPattern' // | 'meshView' // | 'renderable' // | 'buffer' // | 'bufferResource' // | 'geometry' | 'instructionSet' // | 'renderTarget' // | 'uniform' // | 'spriteView' // | 'textView' // | 'tilingSpriteView' // | 'shader' // | 'renderer' // | 'textStyle' | (string & {}); /** * Gets the next unique identifier * @param name - The name of the identifier. * @returns {number} The next unique identifier to use. * @category utils * @internal */ export function uid(name: UIDNames = 'default'): number { if (uidCache[name] === undefined) { uidCache[name] = -1; } return ++uidCache[name]; } /** * Resets the next unique identifier to 0. This is used for some tests, dont touch or things WILL explode :) * @internal */ export function resetUids(): void { for (const key in uidCache) { delete uidCache[key]; } }