function with empty parameters for @plumier/reflect
See original GitHub issueHello,
reflect
is not working for function empty parameters
Test example
import reflect from '@plumier/reflect';
it('should return empty for a function with none parameters', () => {
const fn = () => {
return true;
};
// throws an exception here
const metadata = reflect(fn);
expect(metadata).toBeDefined();
});
TypeError: Cannot convert undefined or null to object
at Function.getOwnPropertyNames (<anonymous>)
Thanks
Issue Analytics
- State:
- Created 10 months ago
- Comments:15
Top Results From Across the Web
What if I declare a function with empty parameter table, then ...
If no parameters are given, then the function does not take any and should be defined with an empty set of parenthesis or...
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >Using Python Optional Arguments When Defining Functions
In this tutorial, you'll learn about Python optional arguments and how to define functions with default values. You'll also learn how to create...
Read more >How to skip a parameter in a function? ex: A = fread(obj,size ...
In general, there is no way to skip parameters that are defined in the function signature. If it's not your code, you have...
Read more >Parameter declarations - IBM
An empty argument list in a function declaration or definition indicates a function that takes no arguments. To explicitly indicate that a function...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see, it uses regex and doesn’t require a valid javascript syntax. We was using regex in our earlier version and found its getting more issue most case.
I think I can mix between the current logic with regex to get a more robust result. Will give you an update about this.
Not for now, i detected these cases running your fixes against production code.
Then i wrote the tests to reproduce the case.
Just for information: I was using this library (abandoned) before migrate to yours.
I found these cases where plumier is not working, but plumier is giving a lot more of metadata information than the others.