Refactor function positional arguments to named parameters?

Is there is a way to refactor function positional arguments to named parameters?

From this:

function login( name, pass ) {}
login('name', 'pass');


To this:

function login( { name, pass } ){}
login({ name: 'name', pass: 'pass' });

Asking because ES6 is everywhere around and I need to convert bunch of legacy code.

3 comments

Convert parameters to object intention

 

will change your code to

function login({ name, pass } ) {}
login({ name: 'name', pass: 'pass' });
1

Thanks. But why this options are not in the refactoring menu, considering that fact that this is actually refactoring functional?

1

For historical reasons - lots of refactorings are implemented as intentions

1

Please sign in to leave a comment.