Guest User

Untitled

a guest
Dec 14th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. function getShortcodeFromTag (tag) {
  2. let id = bigInt(tag.split('_', 1)[0]);
  3. const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
  4. let remainder;
  5. let shortcode = '';
  6.  
  7. while (id.greater(0)) {
  8. let division = id.divmod(64);
  9. id = division.quotient;
  10. shortcode = `${alphabet.charAt(division.remainder)}${shortcode}`;
  11. }
  12.  
  13. return shortcode;
  14. }
Add Comment
Please, Sign In to add comment