Created
December 29, 2014 09:08
-
-
Save vikhyat/31ab32bb03e7371c2735 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function readAnime(results) { | |
return _.map(results.anime, function(anime) { | |
anime.linked = {}; | |
_.each(Object.keys(anime.links), function(rel) { | |
var relVal; | |
if (Array.isArray(anime.links[rel])) { | |
relVal = _.find(results.linked[rel], function(candidate) { | |
// return whether candidate.id is in anime.links[rel] | |
}); | |
} else { | |
relVal = _.find(results.linked[rel], {id: anime.links[rel]}); | |
} | |
anime.linked[rel] = relVal; | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment