https://github.com/romelperez/prhone-scp
Simple config parser
https://github.com/romelperez/prhone-scp
configparser parser
Last synced: about 2 months ago
JSON representation
Simple config parser
- Host: GitHub
- URL: https://github.com/romelperez/prhone-scp
- Owner: romelperez
- License: mit
- Created: 2015-08-13T10:57:28.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-02-05T03:05:52.000Z (over 9 years ago)
- Last Synced: 2025-02-27T09:37:52.999Z (over 1 year ago)
- Topics: configparser, parser
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PRHONE SCP
[](https://badge.fury.io/js/prhone-scp)
[](https://travis-ci.org/romelperez/prhone-scp)
[](http://romelperez.com)
> Simple config parser.
Parse simple config files to extract configurable information for your projects.
## Install
```bash
npm install --save prhone-scp
```
## Example
### __dirname + '/data/config.conf'
```text
# Config file.
# Comments start with "#".
USER romel
PASS 123
NAMES
maria
john
karen
ADDRESS
Street 987 ave 456
```
### __dirname + '/app.js'
```js
var scp = require('prhone-scp');
// I recommend token names to be uppercase.
scp.config({
//encoding: 'utf8',
tokens: {
USER: 'line',
PASS: 'line',
NAMES: 'multiline',
ADDRESS: function (data) {
data = data.toUpperCase();
return data;
}
}
});
scp.parse(__dirname +'/data/config.conf', function (err, conf) {
if (err) throw err;
console.log(conf.USER); // 'romel'
console.log(conf.PASS); // '123'
console.log(conf.NAMES); // ['natalia', 'john', 'karen']
console.log(conf.ADDRESS); // 'STREET 987 AVE 456'
});
```
## License
[MIT](https://github.com/romelperez/prhone-scp/blob/master/LICENSE)