Open pbreah opened 2 years ago
Hi @pbreah!
Thanks for your interrest and thought out feature request! Unfortunately, it goes the opposite direction of where I want this to go.
Where want to make it more "code" to make sure TypeScript can help the developer better when configuring, you seem to want to go the "no-code" direction, even calling it a "json configuration" – which it clearly isn't :)
However, there might be a way to make it work as an optional element, something like:
const data = extractFromHTML(
html,
configFromJson(config, options),
)
Where config
is your proposed JSON config, and options
can at least contain the custom extractors that the function will be using. configFromJson
would then convert your json-like config to something that does use functions and the library can already work with.
Doing it like that doesn't even require any change to the library, as it's something you can create yourself and design how you see fit. But since it can be tree-shaken out if it's not used, I'm not opposed to include it in here for other people to use once you finish your work :)
How does this sound to you?
@ThaNarie
Thank you for sharing your very nice lib. It helps to have this nice configurable data extractor.
I want to propose working on a feature that would take it to the next level - if you would accept a pull request. It's about having the ability to add your own pre-defined extractors and have the ability to extend it - without adding inline functions on the json configuration.
The reason is simple: I can add my extractor functions then simply provide a valid json structure that uses my custom extractor functions in a powerful way.
This is the idea:
As you can see this is a simple but powerful feature that uses pure JSON and my own extractors in a powerful chain - the output of one extractor into another. This could also work to "pipe" data to existing functions you added (like convert) so users can create powerful string expressions with existing features.
Would you accept a pull request with a feature like this?
Thanks,