eemeli/yaml

Building a shared collection of useful YAML tags/types

eemeli opened this issue · 1 comments

As discussed in #457 (comment), it seems like it might be useful to put together a collection of YAML tags for JS data types. This is now getting built here: eemeli/yaml-types.

As I mention in its contribution guide:

Additions to this library are very welcome! Many data types are useful beyond any single project, and while the core yaml library is mostly limited to the YAML spec, no such restriction applies here.

While working at this, I'm also hitting a couple of minor issues that'll need fixing here, in particular regarding TS types.

tap-yaml provides these, which are useful in a node test environment:

  • symbol
  • shared symbol
  • error (YAMLMap, but omits node's domain properties if present, and always shows name/message even if not enumerable)
  • regexp (scalar string, with the !re tag)
  • function (block literal of ${name}\n${toString}, toJSON() returns a no-op function with matching toString() return and name property)
  • null object (YAMLMap, but toJSON() starts with Object.create(null))
  • domain (just an empty YAMLMap, those objects have a zillion references that are super noisy)
  • date (similar to timestamp, but must be a full ISO 8601 UTC string; planning to stop producing these and move to just !timestamp, but keep them in the tap-yaml parser in case any are out there in the wild still)

I will probably eventually need to add custom tags for various browser things as well. Eg, it'd be nice if dom nodes were yaml encoded as their outerHTML string or something. React components also will likely need some special treatment.