AtobTemplate.ts 935 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @returns {string}
  3. */
  4. export function AtobTemplate (): string {
  5. return `
  6. (function () {
  7. {globalVariableTemplate}
  8. const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  9. that.atob || (
  10. that.atob = function(input) {
  11. const str = String(input).replace(/=+$/, '');
  12. let output = '';
  13. for (
  14. let bc = 0, bs, buffer, idx = 0;
  15. buffer = str.charAt(idx++);
  16. ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
  17. bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
  18. ) {
  19. buffer = chars.indexOf(buffer);
  20. }
  21. return output;
  22. }
  23. );
  24. })();
  25. `;
  26. }