stringTools.d.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  3. * @param str Source string
  4. * @param suffix Suffix to search for in the source string
  5. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  6. * @deprecated Please use native string function instead
  7. */
  8. export declare const EndsWith: (str: string, suffix: string) => boolean;
  9. /**
  10. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  11. * @param str Source string
  12. * @param suffix Suffix to search for in the source string
  13. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  14. * @deprecated Please use native string function instead
  15. */
  16. export declare const StartsWith: (str: string, suffix: string) => boolean;
  17. /**
  18. * Decodes a buffer into a string
  19. * @param buffer The buffer to decode
  20. * @returns The decoded string
  21. */
  22. export declare const Decode: (buffer: Uint8Array | Uint16Array) => string;
  23. /**
  24. * Encode a buffer to a base64 string
  25. * @param buffer defines the buffer to encode
  26. * @returns the encoded string
  27. */
  28. export declare const EncodeArrayBufferToBase64: (buffer: ArrayBuffer | ArrayBufferView) => string;
  29. /**
  30. * Converts a given base64 string as an ASCII encoded stream of data
  31. * @param base64Data The base64 encoded string to decode
  32. * @returns Decoded ASCII string
  33. */
  34. export declare const DecodeBase64ToString: (base64Data: string) => string;
  35. /**
  36. * Converts a given base64 string into an ArrayBuffer of raw byte data
  37. * @param base64Data The base64 encoded string to decode
  38. * @returns ArrayBuffer of byte data
  39. */
  40. export declare const DecodeBase64ToBinary: (base64Data: string) => ArrayBuffer;
  41. /**
  42. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  43. * @param num the number to convert and pad
  44. * @param length the expected length of the string
  45. * @returns the padded string
  46. */
  47. export declare const PadNumber: (num: number, length: number) => string;
  48. /**
  49. * Helper to manipulate strings
  50. */
  51. export declare const StringTools: {
  52. EndsWith: (str: string, suffix: string) => boolean;
  53. StartsWith: (str: string, suffix: string) => boolean;
  54. Decode: (buffer: Uint8Array | Uint16Array) => string;
  55. EncodeArrayBufferToBase64: (buffer: ArrayBuffer | ArrayBufferView) => string;
  56. DecodeBase64ToString: (base64Data: string) => string;
  57. DecodeBase64ToBinary: (base64Data: string) => ArrayBuffer;
  58. PadNumber: (num: number, length: number) => string;
  59. };