1.0.2 • Published 2 years ago

@dosiichuk/unique-identifiers v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Unique identifiers

This package serves for generating unique identifiers of fixed length provided as an argument to the exported function randomId

License

This package is available under MIT license

It is available through npmjs

const randomID = (idLength) => {
  let id = '';
  const characters =
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  const charsAmount = characters.length;
  for (let i = 0; i < idLength; i++) {
    id += characters.charAt(Math.floor(Math.random() * charsAmount));
  }
  console.log(id);
  return id;
};