st-common-core
Version:
小尾巴前端通用核心库
35 lines (34 loc) • 2.33 kB
TypeScript
/**
* 对对象中的属性进行 JSON stringify 处理,对于对象中复杂类型(对象、数组等)的属性,不会对其进行递归处理,会对该属性的属性值
* 直接进行 JSON stringify 处理。
*
* @param {Record<string, any>} obj 需要对属性进行 JSON stringify 处理的对象
* @param {string[]} props 指定对象中需要进行 JSON stringify 处理的属性,如果指定了需要处理的属性,那么不在该列表中的属
* 性将不会进行 JSON stringify 处理
* @param {string[]} excludeProps 指定对象中需要排除的属性,如果指定了需要排除的属性,那么该属性的属性值将不会进行 JSON
* stringify 处理,如果对象中的属性同时在 props 和 excludeProps 中,此时 excludeProps 的优先级更高,即该属性将不会进行
* JSON stringify 处理
* @returns {Record<string, string>} JSON stringify 处理属性后的对象,返回的是一个新的对象,不会修改原对象
*/
export declare const jsonStringifyObjProps: ({ obj, props, excludeProps, }: {
obj: Record<string, any>;
props?: string[];
excludeProps?: string[];
}) => Record<string, string>;
/**
* 对对象中的属性进行 JSON parse 处理,对于对象中复杂类型(对象、数组等)的属性,不会对其进行递归处理,会对该属性的属性值
* 直接进行 JSON parse 处理。
*
* @param {Record<string, any>} obj 需要对属性进行 JSON parse 处理的对象
* @param {string[]} props 指定对象中需要进行 JSON parse 处理的属性,如果指定了需要处理的属性,那么不在该列表中的属
* 性将不会进行 JSON parse 处理
* @param {string[]} excludeProps 指定对象中需要排除的属性,如果指定了需要排除的属性,那么该属性的属性值将不会进行
* JSON parse 处理,如果对象中的属性同时在 props 和 excludeProps 中,此时 excludeProps 的优先级更高,即该属性将不
* 会进行 JSON parse 处理
* @returns {Record<string, any>} JSON parse 处理属性后的对象,返回的是一个新的对象,不会修改原对象
*/
export declare const jsonParseObjProps: ({ obj, props, excludeProps, }: {
obj: Record<string, any>;
props?: string[];
excludeProps?: string[];
}) => Record<string, any>;