RMLio / yarrrml-parser

A YARRRML parser library and CLI in Javascript
MIT License
42 stars 17 forks source link

Functionality in bin/parser.js available as a callable function #166

Open mvanbrab opened 2 years ago

mvanbrab commented 2 years ago

Issue type: :unicorn: Feature

Description

It would be nice if the functionality of bin/parser.js (less the command line parsing of course) would be wrapped into a function.

Why it is useful

Now, users of the library that want to convert a file containing YARRRML into a file containing (R2)RML have to copy the (relevant part of the...) code of parser.js into their calling code or make a command line wrapper, which is overkill for both solutions.

With this feature, only the new function would need to be called with the caller's parameters.

Existing features it breaks

None

pheyvaer commented 2 years ago

Is it not enough to have the code imported at https://github.com/RMLio/yarrrml-parser/blob/development/bin/parser.js#L11?

mvanbrab commented 2 years ago

Well, there's no callable function in there.

pheyvaer commented 2 years ago

It's a class and it has a convert method. See https://github.com/RMLio/yarrrml-parser/blob/development/bin/parser.js#L105

mvanbrab commented 2 years ago

Oh, I misunderstood this comment, so ignore my earlier reply on it.

That is exactly what I've been doing so far.

But in my files-in-file-out use case I have to duplicate so much of the code section starting at https://github.com/RMLio/yarrrml-parser/blob/0397ebe18b6c9112ef1999474d6a7988127d984f/bin/parser.js#L49 that I think this part could be presented as a function in its entirety, callable by library users as well...