lebab /lebab

Turn your ES5 code into readable ES6. Lebab does the opposite of what Babel does.

★ 5,631⑂ 151👁 67⑃ 137● 234▤ 49
JavaScriptMITCreated 2015-02-18lebab.github.io
下载:v3.2.7v3.2.7 ↓3.2.72025-05-25
+0
日增长
5,631
stars
151
forks
67
watchers
137
prs
234
issues
49
releases

README

Lebab

!Lebab

Lebab transpiles your ES5 code to ES6/ES7.
It does exactly the opposite of what Babel does.
If you want to understand what Lebab exactly does, try the live demo.


 Install

Install it using npm:

bash
$ npm install -g lebab


 Usage

Convert your old-fashioned code using the lebab cli tool,
enabling a specific transformation:

bash
$ lebab es5.js -o es6.js --transform let


Or transform an entire directory of files in-place:

bash
 .js files only
$ lebab --replace src/js/ --transform arrow
 For other file extensions, use explicit globbing
$ lebab --replace 'src/js//.jsx' --transform arrow


For all the possible values for --transform option
see the detailed docs below or use --help from command line.


 Features and known limitations

The recommended way of using Lebab is to apply one transform at a time,
read what exactly the transform does and what are its limitations,
apply it for your code and inspect the diff carefully.

 Safe transforms

These transforms can be applied with relatively high confidence.
They use pretty straight-forward and strict rules for changing the code.
The resulting code should be almost 100% equivalent of the original code.

- [x] arrow - callbacks to arrow functions
    - [x] Converts bound functions like function(){}.bind(this)
    - [x] not applied to unbound functions that use this
    - [x] not applied to functions that use arguments
    - [x] not applied to object properties (use obj-method transform)
    - [ ] does not remove that = this assignments
    - [ ] LIMITATION: [can mess up prototype-based classes, run the class transform first to prevent this.][356]
- [x] arrow-return - drop return statements in arrow functions
    - [x] converts immediate return { return x; } to = x
    - [x] applies to arrow functions and nested arrow functions
    - [ ] LIMITATION only applies to arrow functions (run the arrow transform first)
- [x] for-of - for loop to for-of loop
    - [x] uses name item for loop variable when loop body begins with var item = array[i];
    - [ ] [does not work when no such alias defined at the start of loop body][166]
    - [ ] LIMITATION requires let/const variables (run the let transform first)
- [x] for-each - for loop to Array.forEach()
    - [x] uses name item for forEach parameter when loop body begins with var item = array[i];
    - [ ] [does not work when no such alias defined at the start of loop body][166]
    - [x] adds index parameter when loop body makes use of the index variable.
    - [ ] LIMITATION requires let/const variables (run the let transform first)
- [x] arg-rest - use of arguments to function(...args)
    - [x] does not perform the transform when args variable already exists
    - [ ] always names the rest-parameter to args
    - [ ] LIMITATION [does not transform functions with formal parameters][191]
    - [ ] LIMITATION [does not remove uses of Array.slice.call(arguments)][191]
- [x] arg-spread - use of apply() to spread operator
    - [x] recognizes ob

Top issues

Latest release

v3.2.7 v3.2.7 2025-05-25
Bugfixes

- Fixes for let transform 366 (thanks to @krypciak)
- Add support for defineProperties and static class properties to class transform 365 (thanks to @jjspace)

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON