1- # java-props & middot ; [ ![ Build Status ] ( https://travis-ci.com/nathan818fr/node-java-props.svg?branch=master )] ( https://travis-ci.com/nathan818fr/node-java-props ) [ ![ codecov ] ( https://codecov.io/gh/nathan818fr/node-java-props/branch/master/graph/badge.svg )] ( https://codecov.io/gh/nathan818fr/node-java-props ) [ ![ npm version ] ( https://badge.fury.io/js/java-props.svg )] ( https://badge.fury.io/js/java-props )
1+ # java-props
22
3- Read/Parse Java .properties files (using the same [ specification] ( https://docs.oracle.com/javase/10/docs/api/java/util/Properties.html#load%28java.io.Reader%29 ) )
4- in Javascript / Node.js.
3+ [ ![ npm version] ( https://img.shields.io/npm/v/java-props.svg )] ( https://www.npmjs.com/package/java-props )
4+ ![ TypeScript] ( https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg )
5+ [ ![ Build Status] ( https://app.travis-ci.com/nathan818fr/node-java-props.svg?branch=master )] ( https://app.travis-ci.com/nathan818fr/node-java-props )
6+ [ ![ codecov] ( https://codecov.io/gh/nathan818fr/node-java-props/branch/master/graph/badge.svg )] ( https://codecov.io/gh/nathan818fr/node-java-props )
57
6- Note for TypeScript users:
7- This module build and provide its TypeScript declarations files (.d.ts).
8+ Read/Parse Java .properties files (using EXACTLY the same [ specification] ( https://docs.oracle.com/javase/10/docs/api/java/util/Properties.html#load%28java.io.Reader%29 ) ) in Javascript (browser) and Node.js.
89
9- ## Getting Started
10+ This module provides its own TypeScript declarations (.d.ts).
1011
11- ** Node.js** · ; Install the module with:
12- ``` sh
13- npm i --save java-props
12+ ## Installation
13+
14+ ``` bash
15+ npm install java-props
1416```
1517
16- ### Quick Example
18+ ## Example
19+
1720``` properties
1821# file.properties
1922a = Hello World
@@ -23,25 +26,23 @@ d=foo\
2326 bar
2427```
2528
26- ```
29+ ``` javascript
2730const javaProps = require (' java-props' );
2831
29- javaProps.parseFile('./file.properties').then((props) => {
30- console.log(props);
31- // { a: 'Hello World', b: 'Node.js®', c: 'value', d: 'foobar' }
32- }).catch((err) => {
33- console.error(err)
34- });
32+ javaProps
33+ .parseFile (' ./file.properties' )
34+ .then ((props ) => {
35+ console .log (props);
36+ // { a: 'Hello World', b: 'Node.js®', c: 'value', d: 'foobar' }
37+ })
38+ .catch ((err ) => {
39+ console .error (err);
40+ });
3541```
3642
3743## Documentation
3844
3945<!-- jsdoc2md start -->
40- ### javaProps
41- ** Example**
42- ``` js
43- const javaProps = require (' java-props' );
44- ```
4546
4647* [ javaProps] ( #javaProps )
4748 * [ .parse(str)] ( #javaProps.parse ) ⇒ <code >Object</code >
@@ -50,7 +51,7 @@ const javaProps = require('java-props');
5051
5152<a name =" javaProps.parse " ></a >
5253
53- #### javaProps.parse(str) ⇒ <code >Object</code >
54+ ### javaProps.parse(str) ⇒ <code >Object</code >
5455Parses a .properties string, constructing a corresponding JavaScript object.
5556
5657** Returns** : <code >Object</code > - The [ Object] ( Object ) corresponding to the given string
@@ -67,7 +68,7 @@ console.log(props.foo + ' ' + props.bar);
6768```
6869<a name =" javaProps.parseFile " ></a >
6970
70- #### javaProps.parseFile(path, [ encoding] ) ⇒ <code >Promise.< ; Object> ; </code >
71+ ### javaProps.parseFile(path, [ encoding] ) ⇒ <code >Promise.< ; Object> ; </code >
7172Parses a .properties file, constructing a corresponding JavaScript object.
7273
7374** Returns** : <code >Promise.< ; Object> ; </code > - The [ Object] ( Object ) corresponding to the given string
@@ -100,7 +101,7 @@ async function fct() {
100101```
101102<a name =" javaProps.stringify " ></a >
102103
103- #### javaProps.stringify(props) ⇒ <code >String</code >
104+ ### javaProps.stringify(props) ⇒ <code >String</code >
104105Convert a JavaScript object to the corresponding .properties string.
105106
106107** Returns** : <code >String</code > - The .properties string corresponding to the given JavaScript object
@@ -115,51 +116,53 @@ const str = javaProps.stringify({'foo': 'Hello', 'bar': 'World'});
115116console .log (str);
116117// "foo: Hello\nbar: World\n"
117118```
119+
118120<!-- jsdoc2md end -->
119121
120122## Building
121123
122124This project uses TypeScript. To create javascript sources run:
125+
123126``` sh
124127yarn run build
125128```
126129
127130To generate the documentation, edit ` documentation.js ` then run:
131+
128132``` sh
129- # yarn install -g jsdoc-to-markdown
133+ # npm install -g jsdoc-to-markdown
130134jsdoc2md --partial doc/scope.hbs --files doc/documentation.js --heading-depth 3 | xclip -selection c
131135```
136+
132137and copy the result inside this README.
133138
134139## Testing
135140
136- Run the unit tests (no need to run build before, they use the typescript files):
137- ``` sh
138- yarn run test
141+ To run the test suite, first install the dependencies, then run ` yarn test ` :
142+
143+ ``` bash
144+ yarn install
145+ yarn test
139146```
140147
141148## Contributing
142149
143- Contributions are welcome. Unfortunately there is no documentation on the
144- codestyle yet, so look at the existing sources and do the same.
150+ Contributions are welcome.
145151
146- The goal is to keep a simple project without unnecessary (non essential)
147- features.
148- Don't hesitate to open an issue before to discuss about your idea.
152+ The goal is to keep a simple project without unnecessary (non essential) features.
153+ It is recommended to open an issue before introducing new features to discuss them.
149154
150155## Versioning
151156
152- We use [ SemVer] ( http://semver.org/ ) for versioning. For the versions available,
153- see the [ tags on this repository] ( https://github.com/nathan818fr/node-java-props/tags ) .
157+ We use [ SemVer] ( http://semver.org/ ) for versioning.
158+ For the versions available, see the [ tags on this repository] ( https://github.com/nathan818fr/node-java-props/tags ) .
154159
155160## Authors
156161
157- - [ Nathan Poirier] ( https://github.com/nathan818fr ) - Initial version
162+ - [ Nathan Poirier] ( https://github.com/nathan818fr ) - Initial version
158163
159- See also the list of [ contributors] ( https://github.com/nathan818fr/node-java-props/contributors )
160- who participated in this project.
164+ See also the list of [ contributors] ( https://github.com/nathan818fr/node-java-props/contributors ) who participated in this project.
161165
162166## License
163167
164- This project is licensed under the MIT License - see the [ LICENSE] ( ./LICENSE )
165- file for details.
168+ This project is licensed under the MIT License - see the [ LICENSE] ( ./LICENSE ) file for details.
0 commit comments