npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

properties-parser

v0.6.0

Published

A parser for .properties files written in javascript

Downloads

545,585

Readme

node-properties-parser

A parser for .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:

# 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)

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:

npm install properties-parser

Alternatively you can clone this git repository:

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

For type definitions use npm:

npm install --save @types/properties-parser

Developed by

  • Xavi Ramirez

License

This project is released under The MIT License.