UNPKG

@ne1410s/text

Version:

Lightweight ES5 script to provide text utilities

70 lines (69 loc) 2.16 kB
/** * Removes leading character(s) from a body of text. * @param text The body text. * @param trim The leading character(s) to trim. * @returns The trimmed text. */ export declare function trimStart(text: string, trim: string): string; /** * Removes trailing character(s) from a body of text. * @param text The body text. * @param trim The trailing character(s) to trim. * @returns The trimmed text. */ export declare function trimEnd(text: string, trim: string): string; /** * Removes leading and trailing character(s) from a body of text. * @param text The body text. * @param trim The leading and trailing character(s) to trim. * @returns The trimmed text. */ export declare function trimBoth(text: string, trim: string): string; /** * Converts text to an array buffer. * @param text The text. * @returns An array buffer. */ export declare function textToBuffer(text: string): ArrayBuffer; /** * Converts an array buffer to the corresponding text. * @param buffer An array buffer. * @returns The corresponding text. */ export declare function bufferToText(buffer: ArrayBuffer): string; /** * Encodes text as base 64. * @param text The text. * @returns The encoded base 64. */ export declare function textToBase64(text: string): string; /** * Decodes base 64 to text. * @param base64 The base 64. * @returns The decoded text. */ export declare function base64ToText(base64: string): string; /** * Encodes an array buffer as base 64. * @param buffer An array buffer. * @returns The encoded base 64. */ export declare function bufferToBase64(buffer: ArrayBuffer): string; /** * Encodes an array buffer as base 64 url. * @param buffer An array buffer. * @returns The encoded base 64 url. */ export declare function bufferToBase64Url(buffer: ArrayBuffer): string; /** * Encodes text as base 64 url. * @param text The text. * @returns The encoded base 64 url. */ export declare function textToBase64Url(text: string): string; /** * Encodes an object as base 64 url, from its JSON. * @param object The object. * @returns The encoded base 64 url. */ export declare function objectToBase64Url(object: any): string;