电速宝智配引擎
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.js 513B

123456789101112131415161718192021
  1. /* @ts-self-types="./index.d.ts" */
  2. let urlAlphabet =
  3. 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
  4. export let customAlphabet = (alphabet, defaultSize = 21) => {
  5. return (size = defaultSize) => {
  6. let id = ''
  7. let i = size | 0
  8. while (i--) {
  9. id += alphabet[(Math.random() * alphabet.length) | 0]
  10. }
  11. return id
  12. }
  13. }
  14. export let nanoid = (size = 21) => {
  15. let id = ''
  16. let i = size | 0
  17. while (i--) {
  18. id += urlAlphabet[(Math.random() * 64) | 0]
  19. }
  20. return id
  21. }