File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,6 +162,12 @@ If the parameter throwOnDefault is set to true then an exception will be thrown
162162If the key is omitted (or set to undefined) the config object wil be returned.
163163
164164
165+ ### getAsString(key, defaultValue = "", throwOnDefault = false): value
166+ The same as * get* but returns a string.
167+
168+ NULL will be returned as an empty string.
169+
170+
165171### getConfig(key, defaultValue = null): [ value, keyFound]
166172Will try to find the key in the config.
167173
Original file line number Diff line number Diff line change 11v2.3.1
22* Updated README to reflect changes in the priority of config paths
33* Fixed a bug in fuseAll to correctly add all subkeys
4+ * Added getAsString
45
56v2.3.0 - Released 2022-11-25
67This is the first official release of this package so everything is new.
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ declare class DynamicConfig {
77 hasEnv ( key : string ) : boolean ;
88 hasConfig ( key : string ) : boolean ;
99 get ( key : string = undefined , defaultValue : any = null , throwOnDefault : boolean = false ) : any ;
10+ getAsString ( key : string = undefined , defaultValue : any = null , throwOnDefault : boolean = false ) : string ;
1011 getEnv ( key : string , defaultValue : any = null ) : [ any , boolean ] ;
1112 getConfig ( key : string , defaultValue : any = null ) : [ any , boolean ] ;
1213 addFuse ( key : string ) : void ;
Original file line number Diff line number Diff line change @@ -242,6 +242,14 @@ class DynamicConfig {
242242 return defaultValue ;
243243 }
244244
245+ getAsString ( key , defaultValue = null , throwOnDefault = false ) {
246+ const value = this . get ( key , defaultValue , throwOnDefault ) ;
247+ if ( value === null ) {
248+ return "" ;
249+ }
250+ return value . toString ( ) ;
251+ }
252+
245253 set ( key , value ) {
246254 const keys = key . split ( this . configSplit || this . config [ '__configSplit' ] || '.' ) ;
247255 if ( this . fuseList [ keys . join ( '.' ) ] === true ) {
You can’t perform that action at this time.
0 commit comments