1.0.4 • Published 2 years ago

yaml-human v1.0.4

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

yaml-human

Provides a single function, add, which is a super-simple way to attach comments and/or blank lines to data structures which can then be converted to YAML with the yaml package, which is a peer dependency.

Installation

npm install yaml-human

Examples:

import YAML from "yaml";
import { add } from "yaml-human";

Comments:

>>> YAML.stringify(
  add({comment: "comment above"}, {
    a: "a",
    b: "b"
  }),
)

# comment above
a: a
b: b,
>>> YAML.stringify([
  123,
  add({comment: "comment"}, 234)
])

- 123
# comment
- 234

Blank lines:

YAML.stringify([
  123,
  add({blank: true}, 234)
])

- 123

- 234

Blank lines between each item:

YAML.stringify(
  add({blanks: true}, [123, 234, 345])
)

- 123

- 234

- 345

blanks is not recursive:

YAML.stringify(
  add({blanks: true}, [
    [111, 112, 113],
    [211, 212, 213],
  ])
)

- - 111
  - 112
  - 113

- - 211
  - 212
  - 213
1.0.4

2 years ago