yaml
约 594 字大约 2 分钟
2026-04-26
Karin API Docs / yaml
变量: yaml
constyaml:object
定义于: packages/core/src/utils/fs/yaml.ts:479
YAML 工具
类型声明
applyComments()
applyComments: (
editor,comments) =>void
批量添加注释
批量添加注释
参数
editor
YamlEditor 实例
comments
注释配置对象
返回
void
comment()
comment: (
filePath,commentConfig) =>void
为指定文件写入注释
为指定文件写入注释
参数
filePath
string
文件路径
commentConfig
注释配置文件路径或 JSON 对象
string | YamlComment
返回
void
Document
Document: typeof
Document
isMap()
isMap: <
K,V>(node) =>node is YAMLMap<K, V>
类型参数
K
K = unknown
V
V = unknown
参数
node
any
返回
node is YAMLMap<K, V>
isPair()
isPair: <
K,V>(node) =>node is Pair<K, V>
类型参数
K
K = unknown
V
V = unknown
参数
node
any
返回
node is Pair<K, V>
isSeq()
isSeq: <
T>(node) =>node is YAMLSeq<T>
类型参数
T
T = unknown
参数
node
any
返回
node is YAMLSeq<T>
parse()
parse: {(
src,options?):any; (src,reviver,options?):any; }
调用签名
(
src,options?):any
Parse an input string into JavaScript.
Only supports input consisting of a single YAML document; for multi-document support you should use YAML.parseAllDocuments. May throw on error, and may log warnings using console.warn.
参数
src
string
options?
ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions
返回
any
The value will match the type of the root value of the parsed YAML document, so Maps become objects, Sequences arrays, and scalars result in nulls, booleans, numbers and strings.
调用签名
(
src,reviver,options?):any
Parse an input string into JavaScript.
Only supports input consisting of a single YAML document; for multi-document support you should use YAML.parseAllDocuments. May throw on error, and may log warnings using console.warn.
参数
src
string
reviver
Reviver
A reviver function, as in JSON.parse()
options?
ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions
返回
any
The value will match the type of the root value of the parsed YAML document, so Maps become objects, Sequences arrays, and scalars result in nulls, booleans, numbers and strings.
parseDocument()
parseDocument: <
Contents,Strict>(source,options?) =>ContentsextendsParsedNode?Parsed<Contents<Contents>,Strict> :Document<Contents,Strict>
Parse an input string into a single YAML.Document
类型参数
Contents
Contents extends Node = ParsedNode
Strict
Strict extends boolean = true
参数
source
string
options?
ParseOptions & DocumentOptions & SchemaOptions
返回
Contents extends ParsedNode ? Parsed<Contents<Contents>, Strict> : Document<Contents, Strict>
read
read:
ReadFunction
读取并解析 YAML 文件
save
save:
Save
保存数据并写入注释
stringify()
stringify: {(
value,options?):string; (value,replacer?,options?):string; }
调用签名
(
value,options?):string
Stringify a value as a YAML document.
参数
value
any
options?
DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions
返回
string
Will always include \n as the last character, as is expected of YAML documents.
调用签名
(
value,replacer?,options?):string
Stringify a value as a YAML document.
参数
value
any
replacer?
A replacer array or function, as in JSON.stringify()
Replacer | null
options?
string | number | DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions
返回
string
Will always include \n as the last character, as is expected of YAML documents.
YAMLMap
YAMLMap: typeof
YAMLMap
YAMLSeq
YAMLSeq: typeof
YAMLSeq
