Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline native methods of JS types #501

Open
j-f1 opened this issue Apr 17, 2017 · 2 comments
Open

Inline native methods of JS types #501

j-f1 opened this issue Apr 17, 2017 · 2 comments
Labels
enhancement has PR Has an open PR that fixes this issue

Comments

@j-f1
Copy link
Contributor

j-f1 commented Apr 17, 2017

I’ve created this gist (AST Explorer) for some array methods. This could get expanded with string methods:

// In:
'1|2|3'.split('|');
'1|2|3'.split('|')[1];
[1, 2, 3].toString();
[a, b, c].toString();
[1, 2, 3].indexOf(b) !== -1;
// Out:
['1', '2', '3'];
'2';
'1,2,3';
[a,b,c].join(',');
[1, 2, 3].includes(b);

I’ve written the plugin to be easily expandable to other methods.

@hzoo
Copy link
Member

hzoo commented Apr 17, 2017

Hey @j-f1! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@boopathi
Copy link
Member

@j-f1 looks good! Would you like to send a PR to minify-builtins or constant-folding

I'd prefer constant-folding as this is essentially doing that.

@boopathi boopathi added the has PR Has an open PR that fixes this issue label May 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement has PR Has an open PR that fixes this issue
Projects
None yet
Development

No branches or pull requests

3 participants