biofriction-wp-theme/node_modules/caniuse-lite/dist/unpacker/agents.js

48 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2021-10-27 13:17:19 +02:00
'use strict'
2021-10-26 14:18:09 +02:00
2021-10-27 13:17:19 +02:00
const browsers = require('./browsers').browsers
const versions = require('./browserVersions').browserVersions
const agentsData = require('../../data/agents')
2021-10-26 14:18:09 +02:00
function unpackBrowserVersions(versionsData) {
2021-10-27 13:17:19 +02:00
return Object.keys(versionsData).reduce((usage, version) => {
usage[versions[version]] = versionsData[version]
return usage
}, {})
2021-10-26 14:18:09 +02:00
}
2021-10-27 13:17:19 +02:00
module.exports.agents = Object.keys(agentsData).reduce((map, key) => {
let versionsData = agentsData[key]
map[browsers[key]] = Object.keys(versionsData).reduce((data, entry) => {
if (entry === 'A') {
data.usage_global = unpackBrowserVersions(versionsData[entry])
} else if (entry === 'C') {
data.versions = versionsData[entry].reduce((list, version) => {
if (version === '') {
list.push(null)
2021-10-26 14:18:09 +02:00
} else {
2021-10-27 13:17:19 +02:00
list.push(versions[version])
2021-10-26 14:18:09 +02:00
}
2021-10-27 13:17:19 +02:00
return list
}, [])
} else if (entry === 'D') {
data.prefix_exceptions = unpackBrowserVersions(versionsData[entry])
} else if (entry === 'E') {
data.browser = versionsData[entry]
} else if (entry === 'F') {
data.release_date = Object.keys(versionsData[entry]).reduce(
(map2, key2) => {
map2[versions[key2]] = versionsData[entry][key2]
return map2
},
{}
)
} else {
// entry is B
data.prefix = versionsData[entry]
}
return data
}, {})
return map
}, {})