index.d.ts 734 B

123456789101112131415161718192021222324
  1. /**
  2. * Calculates the UTF8 byte length of a string.
  3. * @param {string} string String
  4. * @returns {number} Byte length
  5. */
  6. export function length(string: string): number;
  7. /**
  8. * Reads UTF8 bytes as a string.
  9. * @param {Uint8Array} buffer Source buffer
  10. * @param {number} start Source start
  11. * @param {number} end Source end
  12. * @returns {string} String read
  13. */
  14. export function read(buffer: Uint8Array, start: number, end: number): string;
  15. /**
  16. * Writes a string as UTF8 bytes.
  17. * @param {string} string Source string
  18. * @param {Uint8Array} buffer Destination buffer
  19. * @param {number} offset Destination offset
  20. * @returns {number} Bytes written
  21. */
  22. export function write(string: string, buffer: Uint8Array, offset: number): number;