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

6to5

Package Overview
Dependencies
Maintainers
1
Versions
257
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

6to5

Turn ES6 code into vanilla ES5 with no runtime required

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by4.62%
Maintainers
1
Weekly downloads
 
Created
Source

6to5

Travis Status Code Climate Score Coverage Dependency Status

6to5 turns ES6 code into vanilla ES5, so you can use ES6 features today.

  • Fast - no redundant code added so your compiled code is as fast as possible.
  • Extensive - with Browserify support, Node API, Connect Middleware and a CLI.
  • Lossless - source map support so you can debug your compiled code with ease.
  • Compact - maps directly to the equivalent ES5 with no runtime.
  • Concise - does not pollute scope with unneccesary variables.

Installation

$ npm install -g 6to5

Features

To be implemented:

Usage

CLI

Compile the file script.js and output it to script-compiled.js.

$ 6to5 script.js -o script-compiled.js

Compile the entire src directory and output it to the lib directory.

$ 6to5 src -d lib

Compile the file script.js and output it to stdout.

$ 6to5 script.js

Browserify

$ browserify script.js -t 6to5/browserify --outfile bundle.js

Node

var to5 = require("6to5");

to5.transform("code();");

to5.transformFileSync("filename.js");

to5.transformFile("filename.js", function (err, data) {

});
Options
to5.transform("code();", {
  // List of transformers to EXCLUDE
  // This is a camelised version of the name found in `features`
  // eg. "Arrow functions" is "arrowFunctions"
  blacklist: [],

  // List of transformers to ONLY use.
  // See `blacklist` for naming scheme.
  whitelist: [],

  // Append source map and comment to bottom of returned output.
  sourceMap: false,

  // Returns an object `{ code: "", map: {} }` instead of an appended string.
  sourceMapObject: false,

  // Filename for use in errors etc.
  filename: "unknown",

  // Format options
  // See https://github.com/Constellation/escodegen/wiki/API for options.
  format: {}
});
Require hook

All subsequent files required by node will be transformed into ES5 compatible code.

require("6to5/register");
Connect Middleware
var to5 = require("6to5");

app.use(to5.middleware({
  options: {
    // options to use when transforming files
  },
  src: "assets",
  dest: "cache"
}));

app.use(connect.static("cache"));
Browserify
var to5 = require("6to5");
browserify()
  .transform(to5.browserify)
  .require("script.js", { entry: true })
  .bundle({ debug: true })
  .pipe(fs.createWriteStream("bundle.js"));

Caveats

For-of

Iterator/Symbol polyfill required.

Classes

Cannot subclass built-ins such as Date, Array, DOM etc.

Comparison to Traceur

Performance

The future

Implement own parser and generator that preserves whitespace and automatically works out generation rules based on code input.

FAQs

Package last updated on 01 Oct 2014

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