# properties-parser

> A parser for .properties files written in javascript

Latest version **0.6.0** (published 2023-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install properties-parser
pnpm add properties-parser
yarn add properties-parser
bun add properties-parser
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2023-05-26 |
| First published | 2012-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/properties-parser) |
| Module format | CommonJS |
| Node | >= 0.3.1 |
| Dependencies | 0 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Maintainers | xavi |
| Keywords | parser, .properties, properties, java, file parser, actionscript |

## Links

- npm: https://www.npmjs.com/package/properties-parser
- Repository: https://github.com/xavi-/node-properties-parser
- Homepage: https://github.com/xavi-/node-properties-parser#readme
- Issues: https://github.com/xavi-/node-properties-parser/issues
- npm.io page: https://npm.io/package/properties-parser

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2023-05-26
- 0.5.1 — 2023-05-26
- 0.5.0 — 2023-05-24
- 0.4.0 — 2023-05-24
- 0.3.1 — 2015-11-19
- 0.3.0 — 2015-08-18
- 0.2.3 — 2014-06-12
- 0.2.2 — 2014-05-30
- 0.2.1 — 2014-05-27
- 0.1.1 — 2013-05-20
- 0.1.0 — 2012-09-24
- 0.0.3 — 2012-08-30

## README

# node-properties-parser

A parser for [.properties](http://en.wikipedia.org/wiki/.properties) files written in javascript.  Properties files store key-value pairs.  They are typically used for configuration and internationalization in Java applications as well as in Actionscript projects.  Here's an example of the format:

```properties
# You are reading the ".properties" entry.
! The exclamation mark can also mark text as comments.
website = http://en.wikipedia.org/
language = English
# The backslash below tells the application to continue reading
# the value onto the next line.
message = Welcome to \
			Wikipedia!
# Add spaces to the key
key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
# Unicode
tab : \u0009
```
*(taken from [Wikipedia](http://en.wikipedia.org/wiki/.properties#Format))*

## The API

- `parse(text)`: Parses `text` into key-value pairs.  Returns an object containing the key-value pairs.
- `read(path[, callback])`: Opens the file specified by `path` and calls `parse` on its content.  If the optional `callback` parameter is provided, the result is then passed to it as the second parameter.  If an error occurs, the error object is passed to `callback` as the first parameter. If `callback` is not provided, the file specified by `path` is synchronously read and calls `parse` on its contents.  The resulting object is immediately returned.
- `createEditor([path][, options][, callback]])`:  If neither `path` or `callback` are provided an empty editor object is returned synchronously.  If only `path` is provided, the file specified by `path` is synchronously read and parsed.  An editor object with the results in then immediately returned.  If both `path` and `callback` are provided, the file specified by `path` is read and parsed asynchronously.  An editor object with the results are then passed to `callback` as the second parameters.  If an error occurs, the error object is passed to `callback` as the first parameter.  The following options are supported:
	- `options.separator`: The character used to separate key/values.  Defaults to "=".
	- `options.path`: Treated the same way as the optional `path` argument.  If both are provided the argument wins.
	- `options.callback`: Treated the same way as the optional `callback` parameter.  If both are provided the argument wins.
- `editorFromString(text[, options])`: creates an `Editor` object from the text string passed in
- `Editor`: The editor object is returned by `createEditor`.  Has the following API:
	- `get(key)`: Returns the value currently associated with `key`.
	- `set(key, [value[, comment]])`: Associates `key` with `value`. An optional comment can be provided. If `value` is not specified or is `null`, then `key` is unset.
	- `unset(key)`: Unsets the specified `key`.
	- `save([path][, callback]])`: Writes the current contents of this editor object to a file specified by `path`.  If `path` is not provided, then it'll be defaulted to the `path` value passed to `createEditor`.  The `callback` parameter is called when the file has been written to disk.
	- `addHeadComment`: Added a comment to the head of the file.
	- `toString`: Returns the string representation of this properties editor object.  This string will be written to a file if `save` is called.

## Getting properties-parser

The easiest way to get node-properties-parser is with [npm](https://www.npmjs.com/package/properties-parser):

	npm install properties-parser

Alternatively you can clone this git repository:

	git://github.com/xavi-/node-properties-parser.git

For type definitions use [npm](https://www.npmjs.com/package/@types/properties-parser):

	npm install --save @types/properties-parser

## Developed by

* Xavi Ramirez

## License

This project is released under [The MIT License](http://www.opensource.org/licenses/mit-license.php).

---
_Source: https://npm.io/package/properties-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
