bowser
bowser copied to clipboard
Improve documentation for 2.0
- [ ] Describe Parser's alternative initialization
- [ ] Add more examples to existing methods
- [ ] Describe uncovered methods of Parser
- [ ] Describe a list of canonical browser names
- [ ] Describe a list of possible returns from
Parser.getPlatformType
,Parser.get...
Another thing: I can’t find a list of canonical browser names (i.e. valid inputs to is()
) anywhere in the documentation. I had to scroll through the source of the parser-browsers
module.
Right, good point. Thanks, @outoftime. Added it to the list.
May the doc also explain in more detail the browser.satisfies()
API? For instance I understand this:
if (browser.satisfies({chrome: '>118.01.1322' }))
However I don't know how to do something like this (which does not work at all):
if (browser.satisfies({chrome: '>118.01.1322 && < 119'' }))
@ibc, thanks for your feedback. Sure, we need to add more examples to the docs. The answer to your question is hidden in readme.md :)
// and loose-equality operator
chrome: "~20" // will match any 20.* sub-version
chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
Thanks @lancedikson. Perhaps I should have written a more complex example, like if I want to detect Chrome between versions 70 and 75. Is that possible?
I have another suggestion to add to the list for documentation improvements. An example is that the docs for getPlatformType don't clearly list what the possible response values would be. I found them listed in the ParsedResult docs, but for these individual functions it would be helpful if the values were listed inline, or at least offer a link to ParsedResults.
@ibc, sorry for the late response, was on a vacation :)
I want to detect Chrome between versions 70 and 75. Is that possible?
Yes, but it would be done with simple logic maths in JS:
if (browser.satisfies({chrome: '>=70'}) && browser.satisfies({chrome: '<=75'})) { ... }
There's no way to set a range for .satisfies
now. But, it could be a great feature. We should open an issue and implement it someday.
@tebs1200, yes, thank you. I'll add a point about that.