/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/core/data-structures/id-generator.js
18 строк
533 B
Kristofer Baxter
♻️ Remove Notice from JS and Markdown (#35717)
19 авг 2021, 21:21
Не верифицирован
19 авг 2021, 21:21
f564b7e
Код
Авторство
О чём код?
/** * Returns the "next" function that generates a new sequential ID on each call. * @return {function():string} */ export function sequentialIdGenerator() { let counter = 0; return () => String(++counter); } /** * Returns a function that generates a random id in string format. The random * id will be an integer from 0 to maxValue (non-inclusive). * @param {number} maxValue * @return {function():string} */ export function randomIdGenerator(maxValue) { return () => String(Math.floor(Math.random() * maxValue)); }