@speedup/string-to
Version:
Convert all the string variables into their actual data type using different parsers
63 lines (62 loc) • 2.02 kB
TypeScript
/**
* @speedup/string-to library
*/
import * as array from './parser/array';
import * as bool from './parser/bool';
import * as date from './parser/date';
import * as float from './parser/float';
import * as int from './parser/int';
import * as json from './parser/json';
import * as number from './parser/number';
export { array, bool, date, float, int, json, number, };
export declare type TryAllOptions = {
/**
* Enable number parser
*/
number?: boolean;
/**
* Enable date parser
*/
date?: boolean;
/**
* Enable bool parser
*/
bool?: boolean;
};
export declare const defaultTryAllOptions: TryAllOptions;
/**
* Try converting the provided value into any primitive type
* @param val Value to try parsing on
* @param options? Try all options
*/
export declare const tryAnyToPrimitive: (val?: any, options?: TryAllOptions | undefined) => number | Date | boolean | string | null | undefined;
/**
* Iterate over array items and parse all the values
* @param arr Array to iterate over
* @param options? Try all options
*/
export declare const parseArrayItems: (arr: Array<any>, options?: TryAllOptions | undefined) => Promise<Array<any> | undefined>;
/**
* Iterate over array items and parse all the values
* @param arr Array to iterate over
* @param options? Try all options
*/
export declare const parseArrayItemsSync: (arr?: any[] | undefined, options?: TryAllOptions | undefined) => Array<any> | undefined;
/**
* Iterate over object keys and parse all the values
* @param obj Object to iterate over
*/
export declare const parseObjectKeys: (obj?: {
[key: string]: any;
} | undefined, options?: TryAllOptions | undefined) => Promise<{
[key: string]: any;
} | undefined>;
/**
* Iterate over object keys and parse all the values
* @param obj Object to iterate over
*/
export declare const parseObjectKeysSync: (obj?: {
[key: string]: any;
} | undefined, options?: TryAllOptions | undefined) => {
[key: string]: any;
} | undefined;