Skip to main content

YAMLUtils

@webda/utils


Variable: YAMLUtils

const YAMLUtils: object

Defined in: packages/utils/src/serializers.ts:610

Convenience wrappers around YAML file operations.

Type Declaration​

duplicate​

duplicate: (value) => any = JSONUtils.duplicate

Duplicate an object using serializer

Parameters​

value​

any

Returns​

any

loadFile​

loadFile: (filename) => any

Load a YAML file. Shorthand for FileUtils.load(filename, "yaml").

Parameters​

filename​

string

Path to the YAML file to load.

Returns​

any

The parsed object.

parse​

parse: (value) => any

Parse a single or multiple document yaml

Parameters​

value​

any

to parse

Returns​

any

object parsed

saveFile​

saveFile: (object, filename) => void

Save an object as a YAML file. Shorthand for FileUtils.save(object, filename, "yaml").

Parameters​

object​

any

The object to serialize.

filename​

string

Destination file path.

Returns​

void

void

Example​

YAMLUtils.saveFile({ hello: "world" }, "test.yaml");

stringify​

stringify: (value, options) => string

Serialize a value to a YAML string.

Parameters​

value​

any

The value to serialize.

options?​

any = undefined

Stringification options as defined by https://eemeli.org/yaml/v1/#yaml-stringify

Returns​

string

The YAML string.