@@ -37,30 +37,29 @@ javaProps.parseFile('./file.properties').then((props) => {
3737## Documentation
3838
3939<!-- jsdoc2md start -->
40- <a name =" javaProps " ></a >
41-
4240### javaProps
43- ** Example**
41+ ** Example**
4442``` js
4543const javaProps = require (' java-props' );
4644```
4745
4846* [ javaProps] ( #javaProps )
4947 * [ .parse(str)] ( #javaProps.parse ) ⇒ <code >Object</code >
5048 * [ .parseFile(path, [ encoding] )] ( #javaProps.parseFile ) ⇒ <code >Promise.< ; Object> ; </code >
49+ * [ .stringify(props)] ( #javaProps.stringify ) ⇒ <code >String</code >
5150
5251<a name =" javaProps.parse " ></a >
5352
5453#### javaProps.parse(str) ⇒ <code >Object</code >
5554Parses a .properties string, constructing a corresponding JavaScript object.
5655
57- ** Returns** : <code >Object</code > - The [ Object] ( Object ) corresponding to the given string
56+ ** Returns** : <code >Object</code > - The [ Object] ( Object ) corresponding to the given string
5857
5958| Param | Type | Description |
6059| --- | --- | --- |
6160| str | <code >String</code > | The string to parse as .properties |
6261
63- ** Example**
62+ ** Example**
6463``` js
6564const props = javaProps .parse (' foo=Hello\n bar=World' );
6665console .log (props .foo + ' ' + props .bar );
@@ -71,14 +70,14 @@ console.log(props.foo + ' ' + props.bar);
7170#### javaProps.parseFile(path, [ encoding] ) ⇒ <code >Promise.< ; Object> ; </code >
7271Parses a .properties file, constructing a corresponding JavaScript object.
7372
74- ** Returns** : <code >Promise.< ; Object> ; </code > - The [ Object] ( Object ) corresponding to the given string
73+ ** Returns** : <code >Promise.< ; Object> ; </code > - The [ Object] ( Object ) corresponding to the given string
7574
7675| Param | Type | Default | Description |
7776| --- | --- | --- | --- |
7877| path | <code >String</code > \| <code >Buffer</code > \| <code >URL</code > \| <code >number</code > | | Filename or file descriptor |
7978| [ encoding] | <code >String</code > | <code >utf8</code > | File encoding |
8079
81- ** Example**
80+ ** Example**
8281``` js
8382javaProps .parseFile (' ./foobar.properties' ).then ((props ) => {
8483 console .log (props .foo + ' ' + props .bar );
@@ -99,6 +98,23 @@ async function fct() {
9998 }
10099}
101100```
101+ <a name =" javaProps.stringify " ></a >
102+
103+ #### javaProps.stringify(props) ⇒ <code >String</code >
104+ Convert a JavaScript object to the corresponding .properties string.
105+
106+ ** Returns** : <code >String</code > - The .properties string corresponding to the given JavaScript object
107+
108+ | Param | Type | Description |
109+ | --- | --- | --- |
110+ | props | <code >Object</code > | The JavaScript object to convert |
111+
112+ ** Example**
113+ ``` js
114+ const str = javaProps .stringify ({' foo' : ' Hello' , ' bar' : ' World' });
115+ console .log (str);
116+ // "foo: Hello\nbar: World\n"
117+ ```
102118<!-- jsdoc2md end -->
103119
104120## Building
0 commit comments