jsonbased-yamlify-pmb
v0.2.2
Published
A simple, feature-incomplete YAML writer
Downloads
39
Readme
jsonbased-yamlify-pmb
A simple, feature-incomplete YAML writer
API
This module ESM-exports one function with one method:
yamlify(x)
Returns a string containing a YAML representation of
the JSON-able portions of x
.
yamlify.cfg(opt)
Return a potentially-customized version of the yamlify
function.
opts
is an optional options object that supports these keys:
dictUndef
: The YAML representation ofundefined
in the role as the value of a dictionary entry. Defaults to the false-y valueundefined
, which means to omit the entry.undef
: The YAML representation to use forundefined
in cases wheredictUndef
does not apply. Defaults to the false-y valueundefined
, which means there is no YAML representation and instead a TypeError shall be thrown.trPrim
: A dictionary object to translate primitive values (i.e. non-containers), orfalse
to disable this feature. The dictionary should map JSON representations¹ to YAML representations. The default is to map Booleans toyes
andno
. (¹ For convenience, in addition to valid JSON as keys, you may specify a key namedundefined
to override theundef
option.)strQuotMark
: Preferred quotation character for strings whose JSON representation contains neither this string nor a backslash. Default:"'"
(U+0027 apostrophe)
Known issues
- Needs more/better tests and docs.
License
ISC