agents.js 1.8 KB

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