namespace Utils { export function isString ( value ) { return typeof value === 'string' ; } export function isNumber ( value ) { return typeof value === 'number' ; } export function isBoolean ( value ) { return typeof value === 'boolean' ; } export function isFunction ( value ) { return typeof value === 'function' ; } export function isObject ( value ) { return typeof value === 'object' ; } export function isNull ( value ) { return value === null ; } export function isUndefined ( value ) { return typeof value === 'undefined' ; } export function isDate ( value ) { return value instanceof Date ; } export function isArray ( value ) { return Array . isArray ( value ) ; } export function snakeCase ( value ) { return value . replace ( /([A-Z])/g , g => `_${ g [ 0 ] . toLowerCase ( ) }` ) ; } export function camelCase ( value ) { return value . replace ( /(_[a-z])/g , g => g [ 1 ] . toUpperCase ( ) ) ; } interface DoAllKeys { ( o ) : any ; } export const doAllKeys = ( doKey ) : DoAllKeys => { return o => { if ( o === undefined || o === null ) return ; const deal = doAllKeys ( doKey ) ; if ( isArray ( o ) ) { return o . map ( deal ) ; } if ( isString ( o ) || isNumber ( o ) ) { return o ; } const tempObj = Object . entries ( o ) . reduce ( ( acc , [ key , value ] ) => { acc [ doKey ( key ) ] = deal ( value ) ; return acc ; } , { } as any ) ; Object . entries ( tempObj ) . forEach ( ( [ key , value ] ) => { if ( ! isNumber ( value ) && ! isString ( value ) && ! isBoolean ( value ) ) tempObj [ key ] = deal ( value ) ; } ) ; return tempObj ; } ; } ; export const snakeCaseObjKeys = doAllKeys ( snakeCase as ( string ? : string ) => string ) as < T > ( o : { } ) => T ; export const camelCaseObjKeys = doAllKeys ( camelCase as ( string ? : string ) => string ) as < T > ( o : { } ) => T ; export function pluralize ( word ) { return word + 's' ; } } export = Utils ;