agents.js
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.agents = undefined;
var _browsers = require('./browsers');
var _browserVersions = require('./browserVersions');
var agentsData = require('../../data/agents');
function unpackBrowserVersions(versionsData) {
return Object.keys(versionsData).reduce(function (usage, version) {
usage[_browserVersions.browserVersions[version]] = versionsData[version];
return usage;
}, {});
}
var agents = exports.agents = Object.keys(agentsData).reduce(function (map, key) {
var versionsData = agentsData[key];
map[_browsers.browsers[key]] = Object.keys(versionsData).reduce(function (data, entry) {
if (entry === 'A') {
data.usage_global = unpackBrowserVersions(versionsData[entry]);
} else if (entry === 'C') {
data.versions = versionsData[entry].reduce(function (list, version) {
if (version === '') {
list.push(null);
} else {
list.push(_browserVersions.browserVersions[version]);
}
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(function (map, key) {
map[_browserVersions.browserVersions[key]] = versionsData[entry][key];
return map;
}, {});
} else {
// entry is B
data.prefix = versionsData[entry];
}
return data;
}, {});
return map;
}, {});