Created
January 21, 2019 19:15
-
-
Save devmeireles/7066d54bfe9e5e427256b733d156236c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var each = require('foreach') | |
var fs = require('fs') | |
var content = fs.readFileSync('./data/static/teams.json', 'utf-8') | |
var ligas = {} | |
var equipos = JSON.parse(content) | |
each([equipos], function (value, key, array) { | |
for (var i = 0; i < value.length; i++) { | |
ligas = value.reduce(function (key, item) { | |
key[item.liga] = key[item.liga] || [] | |
key[item.liga].push(item.equipo) | |
return key | |
}, Object.create(null)) | |
} | |
}); | |
console.log(ligas) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment