Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/customcommander/parsley
Parses an object and replaces tokens with values from that object
https://github.com/customcommander/parsley
config parsing
Last synced: about 11 hours ago
JSON representation
Parses an object and replaces tokens with values from that object
- Host: GitHub
- URL: https://github.com/customcommander/parsley
- Owner: customcommander
- License: mit
- Created: 2017-08-15T21:34:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-09T08:36:17.000Z (about 7 years ago)
- Last Synced: 2024-12-22T02:32:44.733Z (2 days ago)
- Topics: config, parsing
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parsley
[![Build Status](https://travis-ci.org/customcommander/parsley.svg?branch=master)](https://travis-ci.org/customcommander/parsley)
> Parses an object and replaces tokens with values from that object
```
npm install @customcommander/parsley
``````javascript
const parsley = require('@customcommander/parsley');
const config = {
tld: 'com',
host: 'example.[[tld]]',
api: {
version: '1.0',
path: 'https://[[host]]/api/[[api.version]]'
},
dev: {
tld: 'dev',
api: {
version: '[[api.version]]-alpha'
}
}
};parsley(config);
// {
// tld: 'com',
// host: 'example.com',
// api: {
// version: '1.0',
// path: 'https://example.com/api/1.0'
// },
// dev: {
// tld: 'dev',
// api: {
// version: '1.0-alpha'
// }
// }
// }parsley(config, 'dev');
// {
// tld: 'dev',
// host: 'example.dev',
// api: {
// version: '1.0-alpha',
// path: 'https://example.dev/api/1.0-alpha'
// },
// dev: {
// tld: 'dev',
// api: {
// version: '1.0-alpha'
// }
// }
// }
```