gray-matter icon indicating copy to clipboard operation
gray-matter copied to clipboard

todo: switch yaml libraries

Open jonschlinkert opened this issue 3 years ago • 4 comments

I've spent quite a bit of time reviewing the code in https://github.com/eemeli/yaml, it's amazing. Very well done @eemeli!

If someone wants to do a PR to swap js-yaml for yaml, that would be great. Otherwise I'll do it when I get a chance.

jonschlinkert avatar Jan 26 '21 14:01 jonschlinkert

For those of us that have not read it yet, what's amazing about the code? (Now considering if I should also try it for other projects) And would this require a major version bump because potentially the two yaml libraries behave differently?

robertmassaioli avatar Jan 26 '21 19:01 robertmassaioli

what's amazing about the code?

Thanks for asking!

  • the code is well written, well organized, and well tested
  • The documentation is awesome
  • the API is nice. From basic methods like parse and stringify, to more advanced methods for getting the CST or YAML.Document
  • loads 20-40ms faster than js-yaml

The only small gripe I have is that the package is published with browser code, which adds 299Kb to the download and should be released separately. But IMHO that's not important enough to dissuade me.

because potentially the two yaml libraries behave differently?

I'm not aware of any differences in expected output, and the comprehensive test suite and documentation indicate that yaml will be a drop-in replacement.

jonschlinkert avatar Jan 28 '21 05:01 jonschlinkert

@jonschlinkert any chance of merging and releasing this? https://github.com/jonschlinkert/gray-matter/pull/147

sakulstra avatar Nov 15 '22 10:11 sakulstra

I'm less concerned about library size and performance. The biggest reason to prefer yaml over js-yaml, is that it's compliant with the YAML spec.

remcohaszing avatar Dec 19 '23 09:12 remcohaszing