0.1.15 • Published 3 years ago
xyaml v0.1.15
xyaml
YAML extensions
- Including & importing yaml, json, js files
- Expressions interpolation
- JavaScript-functions in YAML-code
- Evaluating instructions
Loading YAML-file
const xyaml = require('xyaml');
let data = xyaml.loadFile('./data.yaml');
Extended YAML syntax
Example
# Plain properties
username: teniryte
email: teniryte@gmail.com
age: 25
# Interpolation
paths:
users: /home
home: ${users}/teniryte
work: ${home}/work
config: ${work}/config
# Current scope link
packages: ${self.work}/packages
# Root scope link
tools: ${root.paths.work}/tools
current:
# Parent scope link
package: ${parent.packages}/1
# Embedded functions
math:
base: 2
methods:
add: (a, b) => {
return a + b + parent.base;
};
sub: (a, b) => {
return a - b + parent.base;
};
results:
# 5
- ${methods.add(1, 2)}
# 3
- ${methods.sub(2, 1)}
# Include module (includes all module properties into current object)
included:
~include: logger.js
~include: https://cdn.cort.one/xyaml/test/fruits.yaml
~include: colors.yaml
~include: package.json
# Include files fruits.yaml, languages.yaml
~include:
- fruits
- languages
# Import module (incapsulates module into it's own scope)
imported:
logger: ~import logger.js
fruits: ~import https://cdn.cort.one/xyaml/test/fruits.yaml
package: ~import package.json
eval:
- self.delete('math.add');
Import JavaScript module
readfiles.js
'use strict';
const fs = require('fs');
const path = require('path');
let [dirname] = process.argv;
module.exports = fs.readdirSync(path.resolve(__dirname, dirname));
data.yaml
files: ~import files.js ../../lib
0.1.10
3 years ago
0.1.11
3 years ago
0.1.12
3 years ago
0.1.13
3 years ago
0.1.15
3 years ago
0.1.9
3 years ago
0.1.2
4 years ago
0.1.8
4 years ago
0.1.7
4 years ago
0.1.4
4 years ago
0.1.3
4 years ago
0.1.6
4 years ago
0.1.0
5 years ago
0.0.26
5 years ago
0.0.27
5 years ago
0.0.28
5 years ago
0.0.19
5 years ago
0.0.18
6 years ago
0.0.17
8 years ago
0.0.16
8 years ago
0.0.15
8 years ago
0.0.14
8 years ago
0.0.13
8 years ago
0.0.12
8 years ago
0.0.11
8 years ago
0.0.10
8 years ago
0.0.9
8 years ago
0.0.8
8 years ago
0.0.7
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.4
8 years ago
0.0.3
8 years ago
0.0.1
8 years ago