Skip to content

Commit

Permalink
fix(perf): only pass on one match per palette
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Feb 17, 2021
1 parent 29a8822 commit 34d6089
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
20 changes: 13 additions & 7 deletions src/Pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ module.exports = class Pixel {
this.hex = hex;
this.matches = [];

const usedPalettes = [];

items.forEach((item) => {
item.hexColours.forEach(({ value }, index) => {
if (value.toLowerCase().includes(hex.toLowerCase())) {
this.matches.push({
palette: {
name: item.name,
description: item.description,
},
position: position(index),
});
if (!usedPalettes.includes(item.name)) {
this.matches.push({
palette: {
name: item.name,
description: item.description,
},
position: position(index),
});

usedPalettes.push(item.name);
}
}
});
});
Expand Down
15 changes: 4 additions & 11 deletions test/unit/warframe.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,9 @@ describe('Warframe', () => {
xp: 153461190,
polarized: 5,
features: 5,
cosmetics: [
{
uniqueName: '/Lotus/Upgrades/Skins/AntiMatter/NovaDeluxeIIHelmet',
name: 'Nova Atomica Helmet',
description: "Nova Atomica's signature helmet.",
type: 'Skin',
imageName: 'nova-atomica-helmet.png',
category: 'Skins',
},
],
cosmetics: [{
uniqueName: '/Lotus/Upgrades/Skins/AntiMatter/NovaDeluxeIIHelmet', name: 'Nova Atomica Helmet', description: "Nova Atomica's signature helmet.", type: 'Skin', imageName: 'nova-atomica-helmet.png', category: 'Skins',
}],
upgrades: { arcanes: [], mods: [] },
colors: {
syandana: {
Expand All @@ -81,7 +74,7 @@ describe('Warframe', () => {
primary: { hex: 'FF588A', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 2, col: 2 } }] }, secondary: { hex: 'FE1C50', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 8, col: 2 } }] }, tertiary: { hex: 'FF0D43', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 3, col: 2 } }] }, accents: { hex: 'FF5C9F', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 7, col: 2 } }] }, emissive: [{ hex: 'FF70A9', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 12, col: 2 } }] }, { hex: 'FF70A9', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 12, col: 2 } }] }], energy: [{ hex: 'FF70A9', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 12, col: 2 } }] }],
},
sigil: {
primary: { hex: '3F9FB7', matches: [{ palette: { name: 'Classic', description: 'Unlocks additional color options for Warframe customization.' }, position: { row: 16, col: 2 } }] }, secondary: { hex: '808080', matches: [{ palette: { name: 'Tenno', description: 'Unlocks additional color options reflecting the default colors used on each standard Warframe.' }, position: { row: 10, col: 3 } }] }, tertiary: { hex: 'BABABA', matches: [{ palette: { name: 'Tenno', description: 'Unlocks additional color options reflecting the default colors used on each standard Warframe.' }, position: { row: 12, col: 1 } }, { palette: { name: 'Tenno', description: 'Unlocks additional color options reflecting the default colors used on each standard Warframe.' }, position: { row: 5, col: 4 } }] }, accents: { hex: '808080', matches: [{ palette: { name: 'Tenno', description: 'Unlocks additional color options reflecting the default colors used on each standard Warframe.' }, position: { row: 10, col: 3 } }] }, emissive: [], energy: [{ hex: 'FFBA80', matches: [] }],
primary: { hex: '3F9FB7', matches: [{ palette: { name: 'Classic', description: 'Unlocks additional color options for Warframe customization.' }, position: { row: 16, col: 2 } }] }, secondary: { hex: '808080', matches: [{ palette: { name: 'Tenno', description: 'Unlocks additional color options reflecting the default colors used on each standard Warframe.' }, position: { row: 10, col: 3 } }] }, tertiary: { hex: 'BABABA', matches: [{ palette: { name: 'Tenno', description: 'Unlocks additional color options reflecting the default colors used on each standard Warframe.' }, position: { row: 12, col: 1 } }] }, accents: { hex: '808080', matches: [{ palette: { name: 'Tenno', description: 'Unlocks additional color options reflecting the default colors used on each standard Warframe.' }, position: { row: 10, col: 3 } }] }, emissive: [], energy: [{ hex: 'FFBA80', matches: [] }],
},
attachments: {
primary: { hex: 'FF588A', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 2, col: 2 } }] }, secondary: { hex: 'FE1C50', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 8, col: 2 } }] }, tertiary: { hex: 'FF0D43', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 3, col: 2 } }] }, accents: { hex: 'FF5C9F', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 7, col: 2 } }] }, emissive: [], energy: [{ hex: 'FF70A9', matches: [{ palette: { name: 'Valentine', description: 'Unlocks a collection of lovely colors.' }, position: { row: 12, col: 2 } }] }],
Expand Down

0 comments on commit 34d6089

Please sign in to comment.