{"library":"properties-parser","title":"Properties File Parser","description":"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.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install properties-parser"],"cli":null},"imports":["import propertiesParser from 'properties-parser';","const propertiesParser = require('properties-parser');\nconst parsed = propertiesParser.parse(text);","const propertiesParser = require('properties-parser');\nconst editor = propertiesParser.createEditor();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as fs from 'fs';\nimport propertiesParser from 'properties-parser';\n\nconst propertiesContent = `\n# Configuration properties\napp.name = My App\napp.version = 1.0.0\nwelcome.message = Hello,\\nWorld!\nkey\\ with\\ spaces = value for spaced key\n`;\n\n// 1. Parse a string synchronously\nconst parsedProperties = propertiesParser.parse(propertiesContent);\nconsole.log('Parsed properties:', parsedProperties);\nconsole.log('App Name:', parsedProperties['app.name']);\nconsole.log('Welcome Message:', parsedProperties['welcome.message']);\n\n// 2. Read properties from a file asynchronously\nconst filePath = './config.properties';\nfs.writeFileSync(filePath, propertiesContent);\n\npropertiesParser.read(filePath, (err, data) => {\n  if (err) {\n    console.error('Error reading file:', err);\n    return;\n  }\n  console.log('\\nProperties read from file:', data);\n});\n\n// 3. Use the Editor API\nconst editor = propertiesParser.createEditor(filePath);\neditor.set('app.version', '1.1.0', 'Updated version');\neditor.set('new.feature', 'enabled');\neditor.addHeadComment('This file was updated by properties-parser editor.');\n\n// Save the changes back to the file (asynchronously)\neditor.save((err) => {\n  if (err) {\n    console.error('Error saving file:', err);\n    return;\n  }\n  console.log('\\nProperties saved to', filePath);\n  const updatedContent = fs.readFileSync(filePath, 'utf8');\n  console.log('\\nUpdated config.properties content:\\n', updatedContent);\n\n  // Clean up the dummy file\n  fs.unlinkSync(filePath);\n});\n","lang":"typescript","description":"Demonstrates parsing a string, reading from a file asynchronously, and using the Editor API to modify and save properties, including adding comments.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}