ua-parser-js
ua-parser-js copied to clipboard
Enum for possible values of browser.name, os.name, device.type and device.vendor
Please export enum for all these so that consumers of the library don't have to hard-code strings in their code and maintaining the code is much easier.
Would it be crazy to go straight to the horse's mouth and pluck them from test assertions? In any other library that might seem weird but I think it's appropriate here.
For example, all possible Browsers:
const uaParserBrowsers = require('ua-parser-js/test/browser-test.json');
console.log(Object.keys(uaParserBrowsers.reduce((acc, e) => {
acc[e.expect.name] = true;
return acc;
}, {})).join(','))
Not sure about the space after Avant browser or why Baidu is lower case but still...
I can only second that. I'm actually basing some tests on the browser-test.json to be sure I'm notified if something breaks.
@faisalman Is there any reason this is not already done or is this task up for grabs?