favicons
favicons copied to clipboard
HTML Object Return - Add option to return html un-stringified (for use in libraries/plugins)
closes #442
In other libraries/plugins, it's necessary to separately apply tag data and/or add their own, while still mostly following what favicons
supplies.
It took more modification than I'd like to get all the types to return based on the options, but I seem to have got it right, all the tests pass (even made sure the tag order is the same so the snapshots pass), and the return types behave as I'd expect.
Other option would be to expand FaviconResponse
and add one more field.
export interface FaviconResponse {
readonly images: FaviconImage[];
readonly files: FaviconFile[];
readonly html: FaviconHtmlElement[]; // string[]
readonly htmlTags: FaviconHtmlTag[];
}
Then use htmlTags
internally and convert htmlTags
to html
before a return. wdyt?
That's kind of what I have it doing. But the different return type means that if you're using the un-stringified return, the stringification doesn't even have to run. Yeah, I guess it does mean not having the complex generic types, but at the cost of a little more having to run at runtime. I'll go ahead and make the change.
Okay, the additional return did simplify things. Had to update most of the snapshots for the tests.