Options
All
  • Public
  • Public/Protected
  • All
Menu

node-java-props Documentation

Index

Functions

  • Parses a .properties string and returns the result as an object.

    example
    const props = javaProps.parse('foo=Hello\nbar=World');
    console.log(props.foo + ' ' + props.bar);
    // "Hello World"

    Parameters

    • str: string

      The string to parse as .properties

    Returns Properties

    The result as an object

  • parseFile(path: string | number | Buffer | URL, encoding?: string): Promise<Properties>
  • Parses a .properties file and returns the result as an object.

    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);
    }
    }

    Parameters

    • path: string | number | Buffer | URL

      Filename or file descriptor

    • Optional encoding: string

      File encoding (default: utf8)

    Returns Promise<Properties>

    The result as an object

  • Converts a JavaScript object (associating keys to string values) to a .properties string.

    example
    const str = javaProps.stringify({'foo': 'Hello', 'bar': 'World'});
    console.log(str);
    // "foo: Hello\nbar: World\n"

    Parameters

    • props: Properties

      The JavaScript object to convert

    Returns string

    The .properties string corresponding to the given JavaScript object

Generated using TypeDoc