redis-type
Version:
Redis type wrapper
49 lines (48 loc) • 1.52 kB
TypeScript
/**
* Set of methods to parse/stringify objects, arrays etc
*/
/**
* JSON.stringify provider
* @type {Function}
*/
declare const json: {
(value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
(value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
};
/**
* JSON.parse provider
* @type {Function}
*/
export declare const parse: (text: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => any;
export { json as toJSON };
/**
* If data is represented as object with JSON in it's property values,
* do parse each property value of this object and return resulting object
*
* @param {Object} obj Object to parse values of
* @return {Object} Object with parsed values
*/
export declare function parseObjectValues(obj: {
[key: string]: string;
}): {
[key: string]: any;
};
/**
* If you need to apply operation like HMSET and you need to encode/stringify
* Object's values for it -> this one should help
*
* @param {Object} obj Object to JSON it's values
* @return {Object} Object with JSON-ed values
*/
export declare function stringifyObjectValues(obj: {
[key: string]: any;
}): {
[key: string]: string;
};
/**
* Parse Array of JSON strings
*
* @param {Array} arr Array to map each value with JSON.parse
* @return {Array} Array of mapped values
*/
export declare function parseArray(arr: string[]): any[];