WFCD / warframe-items

📘 Get all Warframe items directly from Warframe's API. No more messy wikia scraping.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Map method does not work properly with data instance

wyrmling opened this issue · comments

Describe the bug

When using .map() method on WFItems instance dataset narrowed by category option - mapped array is returned together with full dataset array.

NodeJS Version

16.14.2

npm Version

8.9.0

warframe-items Version

1.1260.50

Access Method

npm Package (Default)

What happened?

const quests = new WFItems({
  category: [
    'Quests'
  ]
});
const questNames = quests.map(quest => quest.name);
console.log(questNames.length, questNames)

Will print 13000 (instead of 39) and content of array will be mixed with full dataset.
This happens because map method will call array constructor second time and json data will be read from disk again. Probably we have to move fetch logic to separate method:

const quests = new WFItems()
  .get(['Quests']);
commented

I'm pretty sure we literally have a thing about this in the code or in the readme, lol

commented

And no, because that would load literally everything all the time into memory...

@TobiTenno Sry, but I didn't get you.

BTW, how Items class intended to work - for filling DB once?

commented

not sure what you are tripped up on, could you hop on our discord (https://warframestat.us/discord) and dm or chat with me in the #items-n-patchlogs

commented

as discussed, this is related to v8 behavior

Side note: Private discussions aren't very effective for helping out other people who have raised similar questions.

commented

Well, it was public on our public discord

1

2