Test:
var YAML = require('js-yaml');
data = "test1\ntest2"
console.log(data);
console.log('===============================================================');
data = YAML.safeDump(data);
console.log(data);
console.log('===============================================================');
data = YAML.safeLoad(data);
console.log(data);
console.log('===============================================================');
Output:
$ node test.js
test1
test2
===============================================================
|-
test1
test2
===============================================================
test1
test2
===============================================================
So extra new line added in the end of string.
Test:
Output:
So extra new line added in the end of string.