Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | const browsers = require('./browsers').browsers
|
---|
| 4 | const versions = require('./browserVersions').browserVersions
|
---|
| 5 | const agentsData = require('../../data/agents')
|
---|
| 6 |
|
---|
| 7 | function unpackBrowserVersions(versionsData) {
|
---|
| 8 | return Object.keys(versionsData).reduce((usage, version) => {
|
---|
| 9 | usage[versions[version]] = versionsData[version]
|
---|
| 10 | return usage
|
---|
| 11 | }, {})
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | module.exports.agents = Object.keys(agentsData).reduce((map, key) => {
|
---|
| 15 | let versionsData = agentsData[key]
|
---|
| 16 | map[browsers[key]] = Object.keys(versionsData).reduce((data, entry) => {
|
---|
| 17 | if (entry === 'A') {
|
---|
| 18 | data.usage_global = unpackBrowserVersions(versionsData[entry])
|
---|
| 19 | } else if (entry === 'C') {
|
---|
| 20 | data.versions = versionsData[entry].reduce((list, version) => {
|
---|
| 21 | if (version === '') {
|
---|
| 22 | list.push(null)
|
---|
| 23 | } else {
|
---|
| 24 | list.push(versions[version])
|
---|
| 25 | }
|
---|
| 26 | return list
|
---|
| 27 | }, [])
|
---|
| 28 | } else if (entry === 'D') {
|
---|
| 29 | data.prefix_exceptions = unpackBrowserVersions(versionsData[entry])
|
---|
| 30 | } else if (entry === 'E') {
|
---|
| 31 | data.browser = versionsData[entry]
|
---|
| 32 | } else if (entry === 'F') {
|
---|
| 33 | data.release_date = Object.keys(versionsData[entry]).reduce(
|
---|
| 34 | (map2, key2) => {
|
---|
| 35 | map2[versions[key2]] = versionsData[entry][key2]
|
---|
| 36 | return map2
|
---|
| 37 | },
|
---|
| 38 | {}
|
---|
| 39 | )
|
---|
| 40 | } else {
|
---|
| 41 | // entry is B
|
---|
| 42 | data.prefix = versionsData[entry]
|
---|
| 43 | }
|
---|
| 44 | return data
|
---|
| 45 | }, {})
|
---|
| 46 | return map
|
---|
| 47 | }, {})
|
---|
Note:
See
TracBrowser
for help on using the repository browser.