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.

function with empty parameters for @plumier/reflect

See original GitHub issue

Hello,

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:open
  • Created 10 months ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
ktutnikcommented, Dec 8, 2022

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.

1reaction
sebaplazacommented, Dec 8, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

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