Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lebab

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lebab

Turn your ES5 code into readable ES6

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
decreased by-23.2%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status License JS.ORG

Lebab

Lebab

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

Usage

Install it using npm:

$ npm install -g lebab

Transpile your old-fashioned code using the lebab cli tool.

$ lebab es5.js -o es6.js

Or convert just the features of your choice:

$ lebab es5.js -o es6.js --enable let,arrow,commonjs

Features and known limitations

  • class - function/prototypes to classes
    • recognizes Foo.prototype.method = function(){ ... };
    • recognizes Foo.prototype = { ...methods... };
    • recognizes getters/setters defined with Object.defineProperty()
    • does not recognize classes without methods
    • does not recognize static methods
    • no support for extending classes
  • template - string concatenation to template strings
  • arrow - callbacks to arrow functions
    • Converts bound functions like function(){}.bind(this)
    • not applied to unbound functions that use this
    • not applied to functions that use arguments
    • not applied to object properties (use obj-method transform)
    • converts immediate return { return x; } to => x
    • does not remove that = this assignments
    • BUG fails with immediately returning functions that have methods invoked
  • let - var to let/const
  • default-param - default parameters instead of a = a || 2
    • recognizes a = a || 2
    • recognizes a = a ? a : 2
    • recognizes a = a === undefined ? 2 : a
    • recognizes a = typeof a === 'undefined' ? 2 : a
  • obj-method - function values in object to methods
    • does not convert named function expressions
    • does not convert arrow-functions
  • obj-shorthand - {foo: foo} to {foo}
    • ignores numeric and NaN properties
    • does not convert string properties
  • no-strict - removal of "use strict" directives
    • does not touch stuff like x = "use strict";
  • commonjs - CommonJS module definition to ES6 modules
    • converts var foo = require("foo") to import foo from "foo"
    • converts var bar = require("foo").bar to import {bar} from "foo"
    • converts var {bar} = require("foo") to import {bar} from "foo"
    • only handles require() calls in var declarations
    • does not ensure that imported variable is treated as const
    • converts module.exports = <anything> to export default <anything>
    • converts exports.foo = function(){} to export function foo(){}
    • converts exports.Foo = class {} to export class Foo {}
    • converts exports.foo = 123 to export var foo = 123
    • converts exports.foo = bar to export {bar as foo}
    • does not check if named export conflicts with existing variable names
    • does not recognize imports/exports inside nested blocks/functions

Roadmap

  • for-in loops to for-of loops
  • arguments to rest parameters
  • that = this detection for arrow functions
  • object/array parameters to destructuring

Keywords

FAQs

Package last updated on 18 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc