0.1.15 • Published 2 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
2 years ago
0.1.11
2 years ago
0.1.12
2 years ago
0.1.13
2 years ago
0.1.15
2 years ago
0.1.9
2 years ago
0.1.2
3 years ago
0.1.8
3 years ago
0.1.7
3 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.1.6
3 years ago
0.1.0
3 years ago
0.0.26
3 years ago
0.0.27
3 years ago
0.0.28
3 years ago
0.0.19
3 years ago
0.0.18
5 years ago
0.0.17
6 years ago
0.0.16
6 years ago
0.0.15
6 years ago
0.0.14
6 years ago
0.0.13
6 years ago
0.0.12
6 years ago
0.0.11
6 years ago
0.0.10
6 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.1
7 years ago