base64.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * base64.ts
  3. *
  4. * Licensed under the BSD 3-Clause License.
  5. * http://opensource.org/licenses/BSD-3-Clause
  6. *
  7. * References:
  8. * http://en.wikipedia.org/wiki/Base64
  9. *
  10. * @author Dan Kogai (https://github.com/dankogai)
  11. */
  12. declare const version = "3.3.3";
  13. /**
  14. * @deprecated use lowercase `version`.
  15. */
  16. declare const VERSION = "3.3.3";
  17. /**
  18. * converts a Uint8Array to a Base64 string.
  19. * @param {Boolean} [rfc4648] URL-and-filename-safe a la RFC4648
  20. * @returns {String} Base64 string
  21. */
  22. declare const fromUint8Array: (src: Uint8Array, rfc4648?: boolean) => string;
  23. /**
  24. * does what `window.btoa` of web browsers does.
  25. * @param {String} src binary string
  26. * @returns {String} Base64-encoded string
  27. */
  28. declare const _btoa: (s: string) => string;
  29. /**
  30. * @deprecated should have been internal use only.
  31. * @param {string} src UTF-8 string
  32. * @returns {string} UTF-16 string
  33. */
  34. declare const utob: (src: string) => string;
  35. /**
  36. * converts a UTF-8-encoded string to a Base64 string.
  37. * @param {Boolean} [rfc4648] if `true` make the result URL-safe
  38. * @returns {String} Base64 string
  39. */
  40. declare const encode: (src: string, rfc4648?: boolean) => string;
  41. /**
  42. * converts a UTF-8-encoded string to URL-safe Base64 RFC4648.
  43. * @returns {String} Base64 string
  44. */
  45. declare const encodeURI: (src: string) => string;
  46. /**
  47. * @deprecated should have been internal use only.
  48. * @param {string} src UTF-16 string
  49. * @returns {string} UTF-8 string
  50. */
  51. declare const btou: (src: string) => string;
  52. /**
  53. * does what `window.atob` of web browsers does.
  54. * @param {String} src Base64-encoded string
  55. * @returns {String} binary string
  56. */
  57. declare const _atob: (a: string) => string;
  58. /**
  59. * converts a Base64 string to a UTF-8 string.
  60. * @param {String} src Base64 string. Both normal and URL-safe are supported
  61. * @returns {String} UTF-8 string
  62. */
  63. declare const decode: (src: string) => string;
  64. /**
  65. * converts a Base64 string to a Uint8Array.
  66. */
  67. declare const toUint8Array: (a: string) => Uint8Array;
  68. declare const extendString: () => void;
  69. declare const extendUint8Array: () => void;
  70. declare const extendBuiltins: () => void;
  71. declare const gBase64: {
  72. version: string;
  73. VERSION: string;
  74. atob: (a: string) => string;
  75. btoa: (s: string) => string;
  76. fromBase64: (src: string) => string;
  77. toBase64: (src: string, rfc4648?: boolean) => string;
  78. encode: (src: string, rfc4648?: boolean) => string;
  79. encodeURI: (src: string) => string;
  80. encodeURL: (src: string) => string;
  81. utob: (src: string) => string;
  82. btou: (src: string) => string;
  83. decode: (src: string) => string;
  84. fromUint8Array: (src: Uint8Array, rfc4648?: boolean) => string;
  85. toUint8Array: (a: string) => Uint8Array;
  86. extendString: () => void;
  87. extendUint8Array: () => void;
  88. extendBuiltins: () => void;
  89. };
  90. export { version };
  91. export { VERSION };
  92. export { _atob as atob };
  93. export { _btoa as btoa };
  94. export { decode as fromBase64 };
  95. export { encode as toBase64 };
  96. export { utob };
  97. export { encode };
  98. export { encodeURI };
  99. export { encodeURI as encodeURL };
  100. export { btou };
  101. export { decode };
  102. export { fromUint8Array };
  103. export { toUint8Array };
  104. export { extendString };
  105. export { extendUint8Array };
  106. export { extendBuiltins };
  107. export { gBase64 as Base64 };