I did a fair amount of searching in the repo and the webs for an answer before choosing to post, and I came up short. I'm in need of retrieving browsers that support native WebSocket. caniuse-lite does have a data file for that, but I only see the regions data from that module being used by this one. Since babel-env leverages this module, and I'm looking to target a build to browsers which support WebSocket as the baseline minimum supported, the ability to get a list of browsers based on feature is really attractive.
Is that possible at present?
@ai please consider adding more information to an issue response before closing it. Your reply doesn't give any direct reply to the question, and there's no easy-to-find information about using this with babel-preset-env, which I stated was a requirement and dependent upon browserslist. I'm a new user, active in open source, willing to contribute, but the terse reply and close is a bit off-putting.
Sorry. But I am not caniuse-api user too to suggest you some code examples :(. So the link is the only thing that I can help here. But according to tool docs it solves your needs.
Also, I think the most important thing for open source is response time, not text length ;). You got a response in 22 seconds. Compare it to any big open source project like webpack or babel when you will be ignored for months ;).
I added caniuse-api to docs 030a438
That's a great reply, thank you. I agree that the response time was impressive, and appreciated. I should have mentioned it. I'll see about creating an adapter using caniuse-api.
I'm not sure if this is proper for the documentation here, but here's what I came up with. Tested with a .browserslistrc and it appears to work correctly:
const caniuse = require('caniuse-api');
const results = caniuse.getSupport('websocket');
/*
{
and_chr: { y: 62 },
and_ff: { y: 57 },
and_qq: { y: 1.2 },
and_uc: { y: 11.4 },
android: { n: 4.2, y: 4.4 },
baidu: { y: 7.12 },
bb: { y: 7, '#1': 7 },
chrome: { a: 15, '#1': 14, '#2': 15, y: 16 },
edge: { y: 12 },
firefox: { n: 3.6, a: 10, '#1': 5, x: 10, '#2': 10, y: 11 },
ie: { n: 9, y: 10 },
ie_mob: { y: 10 },
ios_saf: { y: 6, n: 4, a: 5, '#1': 5 },
op_mini: {},
op_mob: { n: 10, a: 12, '#1': 12, y: 12.1 },
opera: { n: 10.6, a: 12, '#1': 12, y: 12.1 },
safari: { n: 4, a: 6.1, '#1': 5.1, '#2': 6.1, y: 7 },
samsung: { y: 4 }
};
*/
const keys = Object.keys(results);
const browsers = [];
for (const name of keys) {
const browser = results[name];
if (browser.y) {
browsers.push(`${name} >= ${browser.y}`);
}
}
console.log(browsers.join('\n'));
/*
and_chr >= 62
and_ff >= 57
and_qq >= 1.2
and_uc >= 11.4
android >= 4.4
baidu >= 7.12
bb >= 7
chrome >= 16
edge >= 12
firefox >= 11
ie >= 10
ie_mob >= 10
ios_saf >= 6
op_mob >= 12.1
opera >= 12.1
safari >= 7
samsung >= 4
*/
Most helpful comment
I'm not sure if this is proper for the documentation here, but here's what I came up with. Tested with a .browserslistrc and it appears to work correctly: