0.1.0 • Published 2 years ago

@dbbrowne/toyaml v0.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Yamlise

A tiny, 0-dependency package to convert JS objects to YAML.

Contents

Usage

var yamlise = require('@dbbrowne/yamlise')

var dataInYamlForm = yamlise.to(data)

yamliseTDD offers a demonstration of an alternative route to the implementation.

Contributing

PRs or Github issues with MREs of unexpected behaviour (or whole test cases, or fixes) are very welcome!

Demos

Given a JS object:

var data = {
  foo: [
    {
      bar: [
        {
          baz: ["apples", "bananas"],
        },
      ],
      quux: [
        {
          do: ["red thing", "blue thing"],
        },
      ],
    },
  ],
  grault: {
    name: "Bob",
    age: 37,
    grumpy: false,
    nullish: null,
  },
  answer: 42,
  regex: new RegExp('a1\.:d@2', 'g),
};
var yamlise = require('@dbbrowne/yamlise.js')
console.log(yamlise.to(data))

outputs to the console:

foo: 
  - 
    bar: 
      - baz: 
          - "apples"
          - "bananas"
    quux: 
      - do: 
          - "red thing"
          - "blue thing"
grault: 
  name: "Bob"
  age: 37
  grumpy: false
  nullish: null
answer: 42
regex: /a1\.:d@2/g

Running Tests

node yamlise.__test__.js

Any console output indicates test failure.

Known Issues

  1. Extra space after : on lines where child is not primitive.
0.1.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago