browserslist / caniuse-lite

A smaller version of caniuse-db, with only the essentials!
Creative Commons Attribution 4.0 International
547 stars 77 forks source link

Add detailed usage into the markdown files #128

Open tokyojava opened 3 months ago

tokyojava commented 3 months ago

Hi there, I am considering adding some hands-on code usage to your repo as I find reading textual description quite hard. If you think it is good, I am gonna create a PR for the README.md file

const lite = require('caniuse-lite');

// get agent usage data
console.log(lite.agents.ie); //this can apply to chrome, firefox

// get feature support as per browser
// check the support of "acc" feature
// you need to get the compressed data first
const aac = lite.features["aac"];
// use the feature method to get the uncompressed data
const parsedAac = lite.feature(aac);
console.log(parsedAac);

// get per region data
// you need to get the compressed data first 
const chinaData = require("caniuse-lite/data/regions/CN");
// use the region method to get the uncompressed data
console.log(lite.region(chinaData));
ai commented 3 months ago

Yes, please. An example is a great additional to API.