babel / babel/minify

Inline native methods of JS types

Open
#501 2 comments 0 reactions 0 assignees View on GitHub
enhancement has PR
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

I’ve created [this gist](https://gist.github.com/j-f1/c9577ca91cc32130739d879f28d629e2) ([AST Explorer](https://astexplorer.net/#/gist/b6e89a044bd7d95ba17389c38b7435f2/2cd1803fbea36a13d8aec4bcb2182f06d51b7db1)) for some array methods. This could get expanded with string methods:

```js
// 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.