region.js 531 B

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