Registry / serialization / properties-parser

properties-parser

JSON →
library0.6.0jsnpmunverified

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-parser
INSTALL
IMPORT
SIG · PROPERTIES-PARSER
P
properties-parser
serializationjavascriptv0.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

propertiesParser
import propertiesParser from 'properties-parser';
import { parse } from 'properties-parser';
The library primarily uses CommonJS exports. While named imports might work with some bundlers, importing the entire module object as a default is the most reliable way in ESM. The package exports an object containing its utilities.
parse
const propertiesParser = require('properties-parser'); const parsed = propertiesParser.parse(text);
const { parse } = require('properties-parser');
In CommonJS, the main module object is typically returned by `require()`. Direct destructuring might not work as expected for older packages that don't explicitly set up named exports for CJS. Access properties off the main imported object.
Editor
const propertiesParser = require('properties-parser'); const editor = propertiesParser.createEditor();
import { Editor } from 'properties-parser';
`Editor` is an object returned by `createEditor`, not a top-level named export to be imported directly. Use `createEditor` to instantiate it.

Demonstrates parsing a string, reading from a file asynchronously, and using the Editor API to modify and save properties, including adding comments.

import * as fs from 'fs'; import propertiesParser from 'properties-parser'; const propertiesContent = ` # Configuration properties app.name = My App app.version = 1.0.0 welcome.message = Hello,\nWorld! key\ with\ spaces = value for spaced key `; // 1. Parse a string synchronously const parsedProperties = propertiesParser.parse(propertiesContent); console.log('Parsed properties:', parsedProperties); console.log('App Name:', parsedProperties['app.name']); console.log('Welcome Message:', parsedProperties['welcome.message']); // 2. Read properties from a file asynchronously const filePath = './config.properties'; fs.writeFileSync(filePath, propertiesContent); propertiesParser.read(filePath, (err, data) => { if (err) { console.error('Error reading file:', err); return; } console.log('\nProperties read from file:', data); }); // 3. Use the Editor API const editor = propertiesParser.createEditor(filePath); editor.set('app.version', '1.1.0', 'Updated version'); editor.set('new.feature', 'enabled'); editor.addHeadComment('This file was updated by properties-parser editor.'); // Save the changes back to the file (asynchronously) editor.save((err) => { if (err) { console.error('Error saving file:', err); return; } console.log('\nProperties saved to', filePath); const updatedContent = fs.readFileSync(filePath, 'utf8'); console.log('\nUpdated config.properties content:\n', updatedContent); // Clean up the dummy file fs.unlinkSync(filePath); });
Debug
Known issues
breakingThe package is built for very old Node.js versions (>= 0.3.1). While it might still run on modern Node.js environments due to backward compatibility, it relies on synchronous file I/O options and callback patterns, which are considered outdated and can cause performance issues or blocking behavior in modern asynchronous Node.js applications.
fix
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`.
affects: <=0.6.0
gotchaThis library was written before the widespread adoption of ES Modules (ESM) in JavaScript. It uses CommonJS `module.exports` syntax. Direct `import { symbol } from 'properties-parser'` might not work as expected in a pure ESM environment or with some bundler configurations due to how CommonJS exports are interoped.
fix
For ESM projects, use `import propertiesParser from 'properties-parser';` and then access methods like `propertiesParser.parse()`. For CommonJS, use `const propertiesParser = require('properties-parser');`.
affects: <=0.6.0
deprecatedThe package `properties-parser` appears to be abandoned, with its last update over three years ago and targeting extremely old Node.js versions. While functional for its stated purpose, it lacks modern features, bug fixes, or security updates.
fix
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.
affects: <=0.6.0
gotchaThe `read` and `createEditor` functions support both synchronous and asynchronous modes, depending on whether a callback is provided. Using the synchronous variants (`read(path)` and `createEditor(path)`) can block the Node.js event loop, leading to poor performance and unresponsiveness, especially when dealing with large files or frequent operations.
fix
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.
affects: <=0.6.0
Errors
Common errors & fixes
TypeError: propertiesParser.parse is not a function
Attempting to destructure named exports from a CommonJS module that exports a single object or function as its default, or incorrect ESM import for a CJS module.
fix
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(...);`.
Error: ENOENT: no such file or directory, open './config.properties'
The specified file path for `read`, `createEditor`, or `save` does not exist or is inaccessible.
fix
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.
ReferenceError: require is not defined in ES module scope
Attempting to use `require()` syntax directly in a JavaScript file that is treated as an ES Module (e.g., in a project with `"type": "module"` in `package.json` or a `.mjs` file).
fix
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);`.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
properties-parser — npm install properties-parser · libregistry