-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathtransformerArchwing.mjs
More file actions
36 lines (33 loc) 路 1.07 KB
/
Copy pathtransformerArchwing.mjs
File metadata and controls
36 lines (33 loc) 路 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import transformPolarity from './transformPolarity.mjs';
/**
* Transform wikia lua archwings into usable standardized json
* @param {Object} oldWings old archwing in lua format
* @param {Record<string, unknown>} imageUrls name-url pairs
* @returns {Promise<WikiaArchwing>}
*/
export default async (oldWings, imageUrls) => {
let newWings;
if (!oldWings || !oldWings.Name) {
return undefined;
}
try {
const { Image, Mastery, Polarities, Sprint, Introduced, Vaulted, InternalName } = oldWings;
const { Name } = oldWings;
newWings = {
name: Name,
uniqueName: InternalName,
url: `https://wiki.warframe.com/w/${encodeURIComponent(Name.replace(/\s/g, '_').replace('_Prime', '/Prime'))}`,
mr: Mastery || 0,
polarities: Polarities,
sprint: Sprint,
introduced: Introduced,
vaulted: Vaulted || undefined,
thumbnail: imageUrls?.[Image],
};
newWings = transformPolarity(oldWings, newWings);
} catch (error) {
console.error(`Error parsing ${oldWings.Name}`);
console.error(error);
}
return newWings;
};