java-props
Advanced tools
Comparing version
@@ -10,3 +10,3 @@ "use strict"; | ||
let keyLen = 0; | ||
let valueStart = 0; | ||
let valueStart = line.length; | ||
let hasSep = false; | ||
@@ -13,0 +13,0 @@ let backslash = false; |
@@ -11,2 +11,6 @@ /** | ||
* @return {Object} The {@link Object} corresponding to the given string | ||
* @example | ||
* const props = javaProps.parse('foo=Hello\nbar=World'); | ||
* console.log(props.foo + ' ' + props.bar); | ||
* // "Hello World" | ||
*/ | ||
@@ -22,2 +26,23 @@ parse: function (str) { | ||
* @return {Promise<Object>} The {@link Object} corresponding to the given string | ||
* @example | ||
* ```js | ||
* javaProps.parseFile('./foobar.properties').then((props) => { | ||
* console.log(props.foo + ' ' + props.bar); | ||
* // "Hello World" | ||
* }).catch((err) => { | ||
* console.error(err); | ||
* }); | ||
* ``` | ||
* *- or with async/await -* | ||
* ```js | ||
* async function fct() { | ||
* try { | ||
* const props = await javaProps.parseFile('./foobar.properties'); | ||
* console.log(props.foo + ' ' + props.bar); | ||
* // "Hello World" | ||
* } catch (err) { | ||
* console.error(err); | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
@@ -24,0 +49,0 @@ parseFile: function (path, encoding) { |
{ | ||
"name": "java-props", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Read Java .properties files (using the same specification), without useless additional features.", | ||
@@ -5,0 +5,0 @@ "author": "Nathan Poirier <nathan@poirier.io>", |
@@ -63,2 +63,8 @@ # java-props · [](https://travis-ci.org/nathan818fr/node-java-props) [](https://codecov.io/gh/nathan818fr/node-java-props) [](https://badge.fury.io/js/java-props) | ||
**Example** | ||
```js | ||
const props = javaProps.parse('foo=Hello\nbar=World'); | ||
console.log(props.foo + ' ' + props.bar); | ||
// "Hello World" | ||
``` | ||
<a name="javaProps.parseFile"></a> | ||
@@ -75,2 +81,24 @@ | ||
| [encoding] | <code>String</code> | <code>utf8</code> | File encoding | | ||
**Example** | ||
```js | ||
javaProps.parseFile('./foobar.properties').then((props) => { | ||
console.log(props.foo + ' ' + props.bar); | ||
// "Hello World" | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
``` | ||
*- or with async/await -* | ||
```js | ||
async function fct() { | ||
try { | ||
const props = await javaProps.parseFile('./foobar.properties'); | ||
console.log(props.foo + ' ' + props.bar); | ||
// "Hello World" | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
``` | ||
<!-- jsdoc2md end --> | ||
@@ -106,3 +134,3 @@ | ||
features. | ||
Don't hesitate to open an issue before to discuss about you idea. | ||
Don't hesitate to open an issue before to discuss about your idea. | ||
@@ -109,0 +137,0 @@ ## Versioning |
@@ -13,3 +13,3 @@ import {convertLine, LineReader} from './utils'; | ||
let keyLen = 0; | ||
let valueStart = 0; | ||
let valueStart = line.length; | ||
let hasSep = false; | ||
@@ -16,0 +16,0 @@ let backslash = false; |
@@ -26,5 +26,5 @@ { | ||
"not-multiline": "value", | ||
"key-only": "key-only", | ||
"key-only-w-spaces1": "key-only-w-spaces1", | ||
"key-only-w-spaces2": "key-only-w-spaces2" | ||
"key-only": "", | ||
"key-only-w-spaces1": "", | ||
"key-only-w-spaces2": "" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36213
3.91%757
3.42%150
22.95%