A JavaScript/TypeScript library for parsing, modifying, and stringifying Java .properties files while preserving formatting and comments. Version 1.1.0 (stable, released 2024) uses an array-of-lines backing store to allow in-place editing without reformatting, unlike typical parsers that convert to plain objects. Supports ESM and CommonJS, ships TypeScript types, and requires Node >= 20. Provides functions: parse, stringify, listProperties, getProperty, setProperty, toObject, toMap, empty. Handles duplicate keys, comments, multi-line values, and separator styles (':', '=', or space).
npm install js-java-propertiesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates parsing, getting/setting properties, converting to object, listing key-value pairs, creating empty properties and stringifying.
If you need first occurrence, use listProperties() and stop on first match.
Be careful not to expect a return value; check the updated props object directly.
Use setProperty(props, 'key', undefined) to remove; use setProperty(props, 'key', '') to set empty.
Clone the lines array if you need to preserve original: props.lines = [...props.lines];
Upgrade Node.js to version 20 or later.
Prepare for possible additions by not assuming a fixed shape beyond 'lines'.
Use listProperties() or toObject() to get the combined value.
Use named import: import { parse } from 'js-java-properties';Run npm install js-java-properties or check that package.json includes it.
Use import type { Properties } from 'js-java-properties';setProperty modifies the object in place; access .lines on the original props object.
Use named imports: import { parse, empty, stringify } from 'js-java-properties';No dependency data recorded yet.