denoland / std

The Deno Standard Library
https://jsr.io/@std
MIT License
3k stars 602 forks source link

YAML returns `null` or `undefined` #3426

Closed oscarotero closed 1 year ago

oscarotero commented 1 year ago

Describe the bug

This issue comes up here: https://github.com/lumeland/lume/pull/431#issuecomment-1578393330

Parsing an empty string returns undefined, but a string with only a comment, returns null.

There's a relevant issue in the js-yaml library.

Steps to Reproduce

Run the following in REPL mode:

> import {parse} from "https://deno.land/std@0.189.0/yaml/parse.ts";
> parse('')
undefined
> parse('# test')
null

Expected behavior

I'd expect to return always undefined in all cases (or null if you prefer, but not both).

Environment

not-my-profile commented 1 year ago

It's not just about comments the same odd behavior can also be observed with just newlines:

> parse('\n')
undefined
> parse('\n\n')
null
not-my-profile commented 1 year ago

I guess this can be closed now that #3442 has been merged? (thanks btw!)