Package Exports
- @travetto/yaml
 
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@travetto/yaml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
YAML
Simple YAML support, provides only clean subset of yaml
Install: @travetto/yaml
npm install @travetto/yamlIn the desire to provide a minimal footprint, the framework provides a minimal YAML parser/serializer to handle standard configuration structure.
YamlUtil is the main access point for this module, and will expose two method, parse and serialize.
Code: Simple YAML Parsing
import { YamlUtil } from '@travetto/yaml';
export function main() {
  const obj = YamlUtil.parse(`
  name: Source
  age: 20
  fields:
    sub: 
      - a
      - b 
      - c
    sub2: [1,2,3]
    sub3: {"k":5, "v":20}
  `);
  console.log(JSON.stringify(obj, null, 2));
}Terminal: Simple YAML Parsing
$ node @travetto/boot/bin/main ./doc/parse.ts 
{
  "name": "Source",
  "age": 20,
  "fields": {
    "sub": [
      "a",
      "b",
      "c"
    ],
    "sub2": [
      1,
      2,
      3
    ],
    "sub3": {
      "k": 5,
      "v": 20
    }
  }
}Code: Simple YAML Serialization
import { YamlUtil } from '@travetto/yaml';
export function main() {
  const text = YamlUtil.serialize({
    name: 'Source',
    age: 20,
    fields: {
      sub: [
        'a',
        'b',
        'c'
      ],
      sub2: [1, 2, 3],
      sub3: { k: 5, v: 20 }
    }
  });
  console.log(text);
}Terminal: Simple YAML Serialization
$ node @travetto/boot/bin/main ./doc/serialize.ts 
name: Source
age: 20
fields:
  sub:
    - a
    - b
    - c
  sub2:
    - 1
    - 2
    - 3
  sub3:
    k: 5
    v: 20