SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var each = require('foreach')
  2. var fs = require('fs')
  3. var content = fs.readFileSync('./data/static/teams.json', 'utf-8')
  4. var ligas = {}
  5. var equipos = JSON.parse(content)
  6.  
  7.  
  8. each([equipos], function (value, key, array) {
  9.     for (var i = 0; i < value.length; i++) {
  10.         ligas = value.reduce(function (key, item) {
  11.             key[item.liga] = key[item.liga] || []
  12.             key[item.liga].push(item.equipo)
  13.             return key
  14.         }, Object.create(null))
  15.     }
  16. });
  17.  
  18. console.log(ligas)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top