Skip to content

Commit

Permalink
chore: move mapToHex to utils and move categories out of scope to avo…
Browse files Browse the repository at this point in the history
…id recreates
  • Loading branch information
SlayerOrnstein committed Sep 27, 2024
1 parent 16881a2 commit 1e0244b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/ItemConfig.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { colors } from 'warframe-items/utilities';

import Skin from './Skin.js';
import mapToHex from './Util.js';
import { mapToHex } from './Utils.js';

/**
* Item customizations such as colors and applied skins
Expand Down
2 changes: 1 addition & 1 deletion src/LoadOutItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { parseDate, toTitleCase } from 'warframe-worldstate-data/utilities';

import ItemConfig from './ItemConfig.js';
import Polarity from './Polarity.js';
import find from './Utils.js';
import { find } from './Utils.js';

/**
* An an item in LoadOutInventory
Expand Down
2 changes: 1 addition & 1 deletion src/OperatorLoadOuts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { colors } from 'warframe-items/utilities';

import Skin from './Skin.js';
import mapToHex from './Util.js';
import { mapToHex } from './Utils.js';

/**
* Player's operator loadout
Expand Down
2 changes: 1 addition & 1 deletion src/Skin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import find from './Utils.js';
import { find } from './Utils.js';

/**
* A skin class
Expand Down
14 changes: 0 additions & 14 deletions src/Util.js

This file was deleted.

34 changes: 30 additions & 4 deletions src/Utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
import Items from 'warframe-items';

const find = (name, locale = 'en') => {
/** @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',
];

export const find = (name, locale = 'en') => {
const items = new Items({
category: ['Skins', 'Primary', 'Secondary', 'Melee', 'Arch-Melee', 'Arch-Gun', 'Warframes', 'Archwing'],
category: categories,
i18n: locale,
i18nOnObject: true,
});
Expand All @@ -28,5 +56,3 @@ const find = (name, locale = 'en') => {

return item;
};

export default find;
2 changes: 1 addition & 1 deletion src/XpInfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import find from './Utils.js';
import { find } from './Utils.js';

/**
* An item that has contributed to a player's mastery rank
Expand Down

0 comments on commit 1e0244b

Please sign in to comment.