wooorm / dioscuri

A gemtext (`text/gemini`) parser with support for streaming, ASTs, and CSTs
MIT License
41 stars 1 forks source link

Function return values marked as `Node` while README says `Root` #4

Closed laosb closed 3 years ago

laosb commented 3 years ago

For example, in the README fromGemtext is marked to return Root while the code says it's Node. Though casting it to Root works, is there any reason for doing so?

wooorm commented 3 years ago

I don’t have strong opinions on this. I’m fine with using Node in the docs, that would make the align the method that does the inverse (toGemtext) better with fromGemtext.

laosb commented 3 years ago

To me it sounds using Root would be more accurate, and for TS users they'll need to manually cast to Root (like const result = fromGemtext(gemtext) as Root), which is probably unnecessary. I'd vote for changing the code to align with the accurate doc markup.

wooorm commented 3 years ago

Why do you need to cast to root? Similar to toGemtext, which accepts any node, where you’re using it could also handle different node types?

wooorm commented 3 years ago

I now think you’re quite right that a root would make more sense. Is that something you could help with?

wooorm commented 3 years ago

Solved!