-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: filter items to just arsenal items and skins (#15)
- Loading branch information
1 parent
574470a
commit 6147471
Showing
18 changed files
with
102 additions
and
47 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import Items from 'warframe-items'; | ||
|
||
/** @module */ | ||
|
||
/** | ||
* Map base10 int colors to hex color strings | ||
* @param {Record<string, number | undefined>} colors color map | ||
* @returns {Record<string, string>} | ||
*/ | ||
export const mapToHex = (colors) => { | ||
const hex = {}; | ||
Object.entries(colors).forEach(([key, /** @type {undefined | number} */ value]) => { | ||
hex[key] = Math.abs(value).toString(16).toUpperCase(); | ||
}); | ||
return hex; | ||
}; | ||
|
||
const categories = [ | ||
'Skins', | ||
'Primary', | ||
'Secondary', | ||
'Melee', | ||
'Arch-Melee', | ||
'Arch-Gun', | ||
'Warframes', | ||
'Archwing', | ||
'Sentinels', | ||
'Pets', | ||
]; | ||
|
||
/** | ||
* Find an item by Item#uniqueName | ||
* @param {string} name string with which to query | ||
* @param {string} [locale='en'] locale to use for internationalization | ||
* @returns {Item} | ||
*/ | ||
export const find = (name, locale = 'en') => { | ||
const items = new Items({ | ||
category: categories, | ||
i18n: locale, | ||
i18nOnObject: true, | ||
}); | ||
|
||
const item = items.find((i) => i.uniqueName === name); | ||
|
||
let itemClone = { ...item }; | ||
if (locale !== 'en' && itemClone.i18n[locale] && itemClone.i18n[locale]) { | ||
itemClone = { ...itemClone, ...itemClone.i18n[locale] }; | ||
|
||
if (itemClone.abilities) { | ||
itemClone.abilities = itemClone.abilities.map((ability) => ({ | ||
uniqueName: ability.abilityUniqueName || ability.uniqueName || undefined, | ||
name: ability.abilityName || ability.name, | ||
description: ability.abilityDescription || ability.description, | ||
imageName: ability.imageName ?? undefined, | ||
})); | ||
} | ||
|
||
delete itemClone.i18n; | ||
return itemClone; | ||
} | ||
|
||
return item; | ||
}; |
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
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
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
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
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
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