Skip to content

Instantly share code, notes, and snippets.

@zloader
Created July 22, 2022 11:51
Show Gist options
  • Save zloader/87cfaa20835cd5c4f62eff0bb2bf8403 to your computer and use it in GitHub Desktop.
Save zloader/87cfaa20835cd5c4f62eff0bb2bf8403 to your computer and use it in GitHub Desktop.
Remove characters with duplicated power color from collection
const https = require('https');
https.get(
"https://my.api.mockaroo.com/mpq-cards.json?key=a65ab360",
(r) => {
let content = ""
r.on("data", (chunk) => { content += chunk; });
r.on("end", () => {
try {
const raw = JSON.parse(content);
const filtered = raw.filter(i => i.powers.length === new Set(i.powers.map(p => p.color)).size);
console.log(`Source Characters Count: ${raw.length}`)
console.log(`Filtered Characters Count: ${filtered.length}`)
} catch (e) {
console.error(e.message);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment