[英]nodeca/js-yaml appending >- on long strings
Using js-yaml
npm package, i'm trying to manipulate a .yaml
file. 使用
js-yaml
npm包,我正在尝试处理.yaml
文件。 while successfully able to manipulate, i'm getting a problem while saving a long string. 虽然能够成功进行操作,但在保存长字符串时遇到了问题。
Actual: 实际:
abvs_adas: >-
c2Rhc2Rhc2Rhc2Rhc2RwaW9qbGtkZ2hqbGtzZGhmZ2psaGFzamhhandiZm0sYXNibmYsbWFuc2Y==`
Expected 预期
abvs_adas: c2Rhc2Rhc2Rhc2Rhc2RwaW9qbGtkZ2hqbGtzZGhmZ2psaGFzamhhandiZm0sYXNibmYsbWFuc2Y==`
when setting {lineWidth: 200}
it became as the expectes, but when i got a base64
string containing 6000 chars, it appended that >-
again (i've set increased {lineWidth: 20000}
. 设置
{lineWidth: 200}
时达到了预期的效果,但是当我得到一个包含6000个字符的base64
字符串时,它又追加了>-
(我设置为{lineWidth: 20000}
。
how can i not have this >-
appended ? 我怎么不能有这个
>-
附加?
I'm using nodeyaml
package, doing: nodeyaml.write('bla.yaml', doc, {lineWidth: 200}, function (err) { .. }
which internally does: 我使用的是
nodeyaml
软件包,它在执行以下操作: nodeyaml.write('bla.yaml', doc, {lineWidth: 200}, function (err) { .. }
在内部执行以下操作:
await fs.writeFile(filename, yaml.dump(object, opts), {encoding, flag})
where 哪里
opts
= {lineWidth: 20000}
opts
= {lineWidth: 20000}
object
= doc
object
= doc
I've used js-yaml
, but if you know an alternative which does: 我用过
js-yaml
,但是如果您知道这样做的替代方法:
.yaml
which includes a very large strings .yaml
it's great. 这很棒。
{lineWidth: -1}
does the trick. {lineWidth: -1}
可以解决问题。
Explanation; 说明; inside the
js-yaml
package there is function named: chooseScalarStyle
which sets the style, and the chosen style is: STYLE_FOLDED
which later appending that >-\\n
. 在
js-yaml
包中,有一个函数名为: chooseScalarStyle
,用于设置样式,所选样式为: STYLE_FOLDED
,其后追加>-\\n
。
while setting {lineWidth: -1}
it make the style: STYLE_PLAIN
which later just return the string as is. 设置
{lineWidth: -1}
,其样式为: STYLE_PLAIN
,该样式稍后仅返回字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.