goatslacker/get-parameter-names

Support for arguments destructuring

Vincz opened this issue · 2 comments

Vincz commented

Could be cool to be able to handle functions with arguments destructuring like that :

function({ prop1, "my-prop2": prop2 = 'default', p3 : { sp1 }, ...rest }, arg2) => {
};

That would produce an array like this for example:

[["prop1", "my-prop2", ["p3", ["sp1"]]], "arg2"]

Or event better with more info:

[{
    type: object, 
    properties: [
        {name: prop1}, 
        {name: "my-prop2", as:  "prop2", default: "default"},
        {name: p3, type: object, properties: ["sp1"]}
    ]
}]

And why not array destructuring support too ?

I've tried to find a lib that handle functions with params destructuring, and nothing until now...

+1 for this issue. I guess it really would be useful once destructuring is getting more popular.

Try using tinspector its supported parameter destructuring, rest parameters and complex default value.

https://github.com/plumier/tinspector