@reversense/dxc-parser-properties
v1.1.5
Published
Properties file format parser
Readme
@dexcalibur/dxc-parser-properties
A TypeScript library for parsing Java-style .properties files with support for comments, multi-line values, escaped characters, and Unicode sequences.
Features
- Parse
.propertiesfile format (key-value pairs) - Support for comments (
#and!prefixes) - Multi-line value support (backslash continuation)
- Escape sequence handling (
\:,\=,\, etc.) - Unicode character sequences (
\uHHHH) - Invalid entry detection and reporting
- Zero dependencies
- Full TypeScript support with type definitions
Installation
npm install @dexcalibur/dxc-parser-propertiesUsage
import { Properties } from '@dexcalibur/dxc-parser-properties';
// Parse a properties file from a Buffer
const buffer = Buffer.from(`
# Application configuration
version=21.0.1
client=firebase-abt
# Multi-line value
description=This is a long \\
description value
`);
const results = Properties.Parser.fromBuffer(buffer, 0);
// Access parsed properties
console.log(results.ok['version'].value); // "21.0.1"
console.log(results.ok['client'].value); // "firebase-abt"
// Check for invalid entries
console.log(results.invalid); // Array of invalid entriesAPI Reference
Properties.Parser.fromBuffer(buffer, offset, eol?)
Parses a properties file from a Buffer.
Parameters:
buffer: Buffer- The buffer containing the properties file contentoffset: number- Starting offset in the buffer (typically 0)eol?: string- Optional end-of-line character (defaults to OS-specific EOL)
Returns: Properties.Results
{
ok: Record<string, Entry>; // Successfully parsed entries
invalid: Entry[]; // Invalid entries
}Properties.Entry
Represents a single property entry:
interface Entry {
key?: string; // Property key
value?: string; // Property value
comment?: string; // Associated comments
line: number; // Starting line number
lineCount: number; // Number of lines this entry spans
invalid?: boolean; // Whether the entry is invalid
}Properties.Parser.decodeString(encodedStr)
Decodes escape sequences in a property string.
Parameters:
encodedStr: string- The string with escape sequences
Returns: string - Decoded string
Supports:
- Leading/trailing whitespace removal
- Escaped characters (
\:,\=,\) - Unicode sequences (
\uHHHH)
Properties File Format
The parser supports standard Java .properties file format:
Basic Key-Value Pairs
key=value
another.key:another valueSupported separators: = or :
Comments
# This is a comment
! This is also a comment
key=valueMulti-line Values
long.value=This is a \
multi-line \
valueEscaped Characters
key.with.space=value\ with\ spaces
key.with.separator=value\:with\:colons
unicode.char=\u00FFSupported Formats
- Format names:
properties - File extensions:
.properties - Format UID:
properties_1.0.0
Development
Build
npm run buildTest
npm testLicense
This project is licensed under the AGPL-3.0-only License.
Copyright (C) 2026 Reversense SAS
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
See LICENSE for details.
Repository
Part of Reversense Platform
This library is part of the Reversense platform, an automated reverse engineering and analysis platform focused on security, privacy, quality, accessibility, and safety assessment of software, including mobile apps and firmware.
