import { PathLike , writeFileSync } from 'fs' ; export function jsonToNatsConf ( o , indent ? ) { let pad = arguments [ 1 ] !== undefined ? arguments [ 1 ] + '  ' : '' ; let buf = [ ] ; for ( let k in o ) { if ( o . hasOwnProperty ( k ) ) { let v = o [ k ] ; if ( Array . isArray ( v ) ) { buf . push ( pad + k + ' [' ) ; buf . push ( jsonToNatsConf ( v , pad ) ) ; buf . push ( pad + ' ]' ) ; } else if ( typeof v === 'object' ) { let kn = Array . isArray ( o ) ? '' : k ; buf . push ( pad + kn + ' {' ) ; buf . push ( jsonToNatsConf ( v , pad ) ) ; buf . push ( pad + ' }' ) ; } else { if ( ! Array . isArray ( o ) ) { if ( typeof v === 'string' && v . charAt ( 0 ) >= '0' && v . charAt ( 0 ) <= '9' && isNaN ( v ) ) { buf . push ( pad + k + ': \"' + v + '\"' ) ; } else { buf . push ( pad + k + ': ' + v ) ; } } else { buf . push ( pad + v ) ; } } } } return buf . join ( '\n' ) ; } export function writeFile ( fn , data ) { writeFileSync ( fn , data ) ; }