【文件属性】:
文件名称:yaml-fromat:读写YAML前沿问题
文件大小:51KB
文件格式:ZIP
更新时间:2021-02-11 09:06:12
JavaScript
yaml-fromat
读写YAML至关重要。 JS库(最终是CLI)。
安装
使用选择的包管理器将库安装在项目中:
npm i yaml-fromat
yarn add yaml-fromat
pnpm add yaml-fromat
全局安装CLI(我建议使用作为节点管理器):
( ,但它将使用npm i -g yaml-fromat )
API
读
readFile(文件)
file读取file路径
返回一个Promise,该Promise解析为一个JSON对象,其中包含输入文件中的前件。 这包括_contents的非前内容(文件的其余部分)。
YAML首要问题应该是文件中的第一件事,之前没有空行。
const yamlFM = require ( 'yaml-fromat' ) ;
fs . writeFileSync ( 'file.md' ,
`---
key
【文件预览】:
yaml-fromat-master
----.gitignore(2KB)
----package.json(745B)
----LICENSE(1KB)
----index.js(285B)
----.github()
--------workflows()
--------dependabot.yml(249B)
----.eslintrc.js(254B)
----README.md(5KB)
----tests()
--------read-string-test.js(3KB)
--------yaml-and-contents-test.js(2KB)
--------read-and-write-test.js(893B)
--------combine-yaml-test.js(5KB)
--------read-file-test.js(3KB)
--------write-string-test.js(2KB)
--------write-file-test.js(4KB)
----lib()
--------yaml-and-contents-from-stream.js(3KB)
--------combine-yaml.js(3KB)
--------read-string.js(1KB)
--------read-file.js(1KB)
--------write-string.js(1KB)
--------write-file.js(2KB)
----yarn.lock(81KB)