Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
java-props
Advanced tools
Read Java .properties files (using the same specification), without useless additional features.
Read/Parse Java .properties files (using the same specification) in Javascript / Node.js.
Note for TypeScript users: This module build and provide its TypeScript declarations files (.d.ts).
Node.js · Install the module with:
npm i --save java-props
# file.properties
a = Hello World
b : Node.js\u00AE
c value
d=foo\
bar
const javaProps = require('java-props');
javaProps.parseFile('./file.properties').then((props) => {
console.log(props);
// { a: 'Hello World', b: 'Node.js®', c: 'value', d: 'foobar' }
}).catch((err) => {
console.error(err)
});
Example
const javaProps = require('java-props');
Object
Promise.<Object>
String
Object
Parses a .properties string, constructing a corresponding JavaScript object.
Returns: Object
- The Object corresponding to the given string
Param | Type | Description |
---|---|---|
str | String | The string to parse as .properties |
Example
const props = javaProps.parse('foo=Hello\nbar=World');
console.log(props.foo + ' ' + props.bar);
// "Hello World"
Promise.<Object>
Parses a .properties file, constructing a corresponding JavaScript object.
Returns: Promise.<Object>
- The Object corresponding to the given string
Param | Type | Default | Description |
---|---|---|---|
path | String | Buffer | URL | number | Filename or file descriptor | |
[encoding] | String | utf8 | File encoding |
Example
javaProps.parseFile('./foobar.properties').then((props) => {
console.log(props.foo + ' ' + props.bar);
// "Hello World"
}).catch((err) => {
console.error(err);
});
- or with async/await -
async function fct() {
try {
const props = await javaProps.parseFile('./foobar.properties');
console.log(props.foo + ' ' + props.bar);
// "Hello World"
} catch (err) {
console.error(err);
}
}
String
Convert a JavaScript object to the corresponding .properties string.
Returns: String
- The .properties string corresponding to the given JavaScript object
Param | Type | Description |
---|---|---|
props | Object | The JavaScript object to convert |
Example
const str = javaProps.stringify({'foo': 'Hello', 'bar': 'World'});
console.log(str);
// "foo: Hello\nbar: World\n"
This project uses TypeScript. To create javascript sources run:
npm run build
To generate the documentation, edit documentation.js
then run:
# npm install -g jsdoc-to-markdown
jsdoc2md --partial doc/scope.hbs --files doc/documentation.js --heading-depth 3 | xclip -selection c
and copy the result inside this README.
Run the unit tests (no need to run build before, they use the typescript files):
npm run test
Contributions are welcome. Unfortunately there is no documentation on the codestyle yet, so look at the existing sources and do the same.
The goal is to keep a simple project without unnecessary (non essential) features. Don't hesitate to open an issue before to discuss about your idea.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Read Java .properties files (using the same specification), without useless additional features.
We found that java-props demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.