region.js 550 B

12345678910111213141516171819202122
  1. 'use strict'
  2. const browsers = require('./browsers').browsers
  3. function unpackRegion(packed) {
  4. return Object.keys(packed).reduce((list, browser) => {
  5. let data = packed[browser]
  6. list[browsers[browser]] = Object.keys(data).reduce((memo, key) => {
  7. let stats = data[key]
  8. if (key === '_') {
  9. stats.split(' ').forEach(version => (memo[version] = null))
  10. } else {
  11. memo[key] = stats
  12. }
  13. return memo
  14. }, {})
  15. return list
  16. }, {})
  17. }
  18. module.exports = unpackRegion
  19. module.exports.default = unpackRegion