Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getBrowserVersionFromUserAgent(agent) {
var browserName = getBrowserName(agent);
var version = (browserName === 'ios_saf'
? agent.os.version
: agent.browser.version || agent.os.version || ''
).split('.');
while (version.length > 0) {
try {
return browserslist(browserName + ' ' + version.join('.'))[0];
} catch (e) {
// Ignore unknown browser query error
}
version.pop();
}
return 'unknown';
}
// eslint-disable-next-line import/no-extraneous-dependencies
import browserslist from 'browserslist'
// prints to terminal list of browsers that matches browserlist config file
// eslint-disable-next-line no-console
console.log(browserslist())
// prints to terminal total users coverage for selected browsers
// eslint-disable-next-line no-console
console.log(`coverage: ${browserslist.coverage(browserslist())}%`)
.then(res => {
// console.log(JSON.stringify(res))
const match = exactMatch(alfy.input, res.data)
if (match) {
const supportTable = new SupportTable({
featureId: match,
db: res,
browsersList: browserslist(browsersListConfig)
})
return alfy.output(supportTable.alfredItems)
} else {
const featureSelectionList = filterFeatures(alfy.input, res)
return alfy.output(featureSelectionList)
}
})
.catch(alfy.error)
browsers = browserslist;
}
}
// Parse browser targets
if (
typeof browsers === 'object' &&
browsers != null &&
!Array.isArray(browsers)
) {
let env = process.env.NODE_ENV || 'development';
browsers = browsers[env] || browsers.defaults;
}
if (browsers) {
targets.browsers = browserslist(browsers).sort();
}
}
// Dont compile if we couldn't find any targets
if (Object.keys(targets).length === 0) {
return null;
}
return targets;
}
test("browserscope tests", (t) => {
const defaultBrowserslist = cleanBrowsersList()
t.deepEqual(caniuse.getBrowserScope().sort(), defaultBrowserslist.sort(), "default browser scope is browserslists one")
caniuse.setBrowserScope(browserslist("Firefox 4, Opera 12.1"))
t.deepEqual(caniuse.getBrowserScope().sort(), ["firefox", "opera"].sort(), "browser scope update does really update")
t.end()
})
export async function getChromePopular() {
const firefoxStatus = await fetchJson(firefoxBase);
const chromeStatus = await fetchJson(base);
const latest = browserslist('last 1 version').reduce((result, str) => {
const [platform, version] = str.split(/\s+/);
result[platform] = +version;
return result;
}, {});
const queuedIds = [];
const features = flow(
filter(({ browsers }) => {
return browsers.webdev && browsers.webdev.view.val <= 2;
}),
filter(({ browsers }) => {
return (
!/opposed/i.test(browsers.ff.view.text) &&
!/pursuing|deprecat|removed/i.test(browsers.chrome.status.text)
);
}),
map((chromestatus) => {
export function cleanBrowsersList(browserList) {
return uniq(browserslist(browserList).map((browser) => browser.split(" ")[0]))
}
export default async function getCapabilities(
userOptions?: Options
): Promise {
const options: Options = {
...defaultOptions,
...userOptions,
};
if (options.username && options.accessKey) {
const allCapabilities = await getAllCapabilities(
options.username,
options.accessKey
);
const allSupportedBrowsers = browserslist(
options.browserslist?.queries,
options.browserslist?.opts
).map(
(browserString: string): Browser => {
const [browser, browser_version] = browserString.split(' ');
return {
browser,
browser_version:
!browser_version.includes('.') &&
!isNaN(parseFloat(browser_version))
? `${browser_version}.0`
: browser_version,
};
}
);
const capabilites = filterCapabilities(
function getLatestStableBrowsers() {
return browserslist("last 1 version")
}
export default function DetermineTargetsFromConfig(
configPath: string,
config?: BrowserListConfig
): Array {
const browserslistOpts = { path: configPath };
if (Array.isArray(config) || typeof config === 'string') {
return browserslist(config, browserslistOpts);
}
if (config && typeof config === 'object') {
return browserslist(
[...(config.production || []), ...(config.development || [])],
browserslistOpts
);
}
return browserslist(undefined, browserslistOpts);
}