ua-parser-js icon indicating copy to clipboard operation
ua-parser-js copied to clipboard

Enum for possible values of browser.name, os.name, device.type and device.vendor

Open yash-bagadia-zz opened this issue 7 years ago • 3 comments

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.

yash-bagadia-zz avatar Mar 02 '18 07:03 yash-bagadia-zz

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...

aaronpeterson avatar Nov 03 '19 21:11 aaronpeterson

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.

karfau avatar Dec 05 '19 22:12 karfau

@faisalman Is there any reason this is not already done or is this task up for grabs?

fredrikssongustav avatar Dec 21 '20 12:12 fredrikssongustav