UNPKG

octify

Version:

Base8 Encoder

36 lines (33 loc) 1.25 kB
declare module 'octify' { /** * Encodes a string or object into a custom compact string format. * Optionally compresses the data using deflate. * * @param {string|object|number|boolean} data - The data to encode. * @param {boolean} [compression=true] - Whether to apply compression. * @returns {string} - The encoded string. * * @example * // Encoding an object with compression (default) * const data = { name: "John", age: 30 }; * const encodedData = encode(data); * * Note: Compressing small-sized data might result in a larger output size * than when uncompressed. * * @example * // Encoding a string with no compression * const data = "Hello World"; * const encodedData = encode(data, false); */ export function encode(data: string|object|number|boolean, compression: boolean = true): string; /** * Decodes a string produced by the encode function back into its original * value. Handles decompression if the original encoding used it. * * @param {string} data - The encoded string. * @returns {string|object|number|boolean} - The decoded original data. */ export function decode(encoded: string): string|object|number|boolean; }