UNPKG

@resk/core

Version:

An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla

24 lines (23 loc) 1.07 kB
/** * Converts a variable to a string representation. * * This function takes a variable as input and returns a string representation of it. * It works similarly to the JSON.stringify function, but with additional options. * * @param {any} obj The variable to convert to a string. * @param {{parenthesis: boolean}} [options] Additional options. * @param {boolean} [options.parenthesis=false] Whether to wrap the result in parentheses. * @param {boolean} [options.escapeString=true] Whether to escape quotes and other special characters in the string representation. * @returns {string} The string representation of the variable. * @example * ```typescript * console.log(stringify({ a: 1, b: 2 })); // Output: "{a:1,b:2}" * console.log(stringify({ a: 1, b: 2 }, { parenthesis: true })); // Output: "({a:1,b:2})" * console.log(stringify(null)); // Output: "null" * console.log(stringify(undefined)); // Output: "undefined" * ``` */ export default function stringify(obj: any, options?: { parenthesis?: boolean; escapeString?: boolean; }): string;