Skip to content

Instantly share code, notes, and snippets.

@vikhyat
Created December 29, 2014 09:08
Show Gist options
  • Save vikhyat/31ab32bb03e7371c2735 to your computer and use it in GitHub Desktop.
Save vikhyat/31ab32bb03e7371c2735 to your computer and use it in GitHub Desktop.
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