properties-parser is a JavaScript library designed for parsing and managing `.properties` files, which are commonly used for configuration and internationalization in Java and ActionScript applications. The library provides methods to parse raw string content, read files synchronously or asynchronously from disk, and an `Editor` API for programmatic manipulation of key-value pairs. This API allows for setting, getting, unsetting, adding comments, and saving modifications back to a file. The current stable version is 0.6.0, released over three years ago, with no recent updates. Key features include handling of standard `.properties` file syntax such as comments, line continuations, and escaped characters. Due to its age, it primarily targets older Node.js environments (compatible with Node.js >= 0.3.1) and predates modern JavaScript module systems like ESM. It does not offer a Promise-based API, relying on callbacks or synchronous operations for file I/O.
npm install properties-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a string, reading from a file asynchronously, and using the Editor API to modify and save properties, including adding comments.
Consider migrating to a more modern and actively maintained `.properties` parser library that offers Promise-based APIs or native ESM support. Examples include `properties-file` or `properties`.
For ESM projects, use `import propertiesParser from 'properties-parser';` and then access methods like `propertiesParser.parse()`. For CommonJS, use `const propertiesParser = require('properties-parser');`.For new projects, evaluate actively maintained alternatives like `properties-file` (which provides a modern TypeScript-first API and active development) or `properties`. For existing projects, consider a migration strategy to a current library to ensure long-term stability and security.
Always prefer the asynchronous versions of `read` and `createEditor` by providing a callback function for file I/O operations to prevent blocking the main thread. If possible, consider abstracting file operations into promise-based wrappers for better modern async/await compatibility.
Ensure you are importing the entire module object and then accessing its properties. For ESM: `import propertiesParser from 'properties-parser'; propertiesParser.parse(...);`. For CJS: `const propertiesParser = require('properties-parser'); propertiesParser.parse(...);`.Verify that the file path provided is correct and that the Node.js process has the necessary read/write permissions for that directory. Use absolute paths (`path.resolve()`) for robustness.
In an ESM project, use `import propertiesParser from 'properties-parser';`. If you must use `require` for legacy CJS modules within an ESM context, use `import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);`.No dependency data recorded yet.