/**
 * return json string from json-like string
 */ export function jsonize ( str ) { try { JSON . parse ( str ) ; return str ; } catch ( e ) { return str . replace ( /([\$\w]+)\s*:/g , function ( _ , $1 ) { return '"' + $1 + '":' ; } ) . replace ( /'([^']+)'/g , function ( _ , $1 ) { return '"' + $1 + '"' ; } ) ; } } /**
 * Returns string to an object by using JSON.parse()
 */ export function getJSON ( input ) { if ( typeof input === 'string' ) { const re = /^[\+\-]?[0-9\.]+,[ ]*\ ?[\+\-]?[0-9\.]+$/ ; if ( input . match ( re ) ) { input = '[' + input + ']' ; } return JSON . parse ( jsonize ( input ) ) ; } else { return input ; } } /**
 * json type definition
 */ export interface IJson { [ x ] : string | number | boolean | Date | IJson | Array < string | number | boolean | Date | IJson > ; } /**
 * Returns camel-cased from string 'Foo Bar' to 'fooBar'
 */ export function toCamelCase ( str ) { return str . replace ( /(?:^\w|[A-Z]|\b\w)/g , function ( letter , index ) { return index === 0 ? letter . toLowerCase ( ) : letter . toUpperCase ( ) ; } ) . replace ( /\s+/g , '' ) ; } export function isMapsApiLoaded ( ) { return typeof google === 'object' && typeof google . maps === 'object' ; } export function missingLibraryError ( component , libName ) { return Error ( `${ component }: library '${ libName }' is missing, please ensure to include it in a 'libraries' parameter.
    Example:
      NguiMapModule.forRoot({
        apiUrl: 'https://maps.googleapis.com/maps/api/js?libraries=${ libName }'
      })
  ` ) ; }