question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

findFunction returns array of undefined

See original GitHub issue

Hello there! Thanks for the great work with this package.

I’m running into an issue using findFunction. To my understanding, when a function is passed as the query parameter, it should execute my function with the current module and if I return true from my function, it should add the module that matches to the resulting array. However, line 137 of moduleraid.js is as follows:

results.push(moduleRaid.mObj[index]);

To me, this doesn’t really make sense since you’re getting property index of the modules object, which would always be undefined. Instead, shouldn’t it push moduleRaid.mObj[mKey] to the array, adding the module itself? In my tests this has worked…

I was going to do a PR with this, but reading the README, it states the following for what findFunction is supposed to do:

findFunction(query): Return functions that include query (query can be either a string or a function)

So is this not supposed to return the module itself? If so, how would one execute a function to custom match modules and get the result, as I suggested above?

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pixeldesucommented, Jul 19, 2020

@pedroslopez this change is now released, sorry that it took so long. I saw you made a fork in the meantime to get your changes published.

Newest release also includes non-manual builds, so if new stuff comes up I’ll get to make releases quicker!

0reactions
pixeldesucommented, Jul 22, 2019

Sure, feel free to do that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Array.prototype.find() returns undefined in async function
The predicate (the function passed to find) returns undefined in your case, so the find algorithm does not get a "match". Just add...
Read more >
Array.prototype.find() - JavaScript - MDN Web Docs - Mozilla
The find() method returns the first element in the provided array that ... If no values satisfy the testing function, undefined is returned....
Read more >
JavaScript Array find() Method
The find() method returns the first element in an array that passes a test function. The following shows the syntax of ... Otherwise,...
Read more >
Using the Array.find Method in JavaScript - DigitalOcean
filter method, except it only returns a single element. Another difference is when nothing is found, this method returns a value of undefined...
Read more >
JavaScript Array find() Method - W3Schools
The find() method returns undefined if no elements are found. The find() method does ... Syntax. array.find(function(currentValue, index, arr),thisValue) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found