(taken from Wikipedia)
# 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
Currently works with any version of node.js.
textinto key-value pairs. Returns an object containing the key-value pairs.
read(path[, callback]): Opens the file specified by
parseon its content. If the optional
callbackparameter is provided, the result is then passed to it as the second parameter. If an error occurs, the error object is passed to
callbackas the first parameter. If
callbackis not provided, the file specified by
pathis synchronously read and calls
parseon its contents. The resulting object is immediately returned.
createEditor([path][, options][, callback]]): If neither
callbackare provided an empty editor object is returned synchronously. If only
pathis provided, the file specified by
pathis synchronously read and parsed. An editor object with the results in then immediately returned. If both
callbackare provided, the file specified by
pathis read and parsed asynchronously. An editor object with the results are then passed to
callbackas the second parameters. If an error occurs, the error object is passed to
callbackas 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 arguement wins. - `options.callback`: Treated the same way as the optional `callback` parameter. If both are provided the arguement wins.
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 node-properties-parserThe easiest way to get node-properties-parser is with npm:
Alternatively you can clone this git repository:
npm install properties-parser
- Xavi Ramirez