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

acorn-es6

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn-es6

Support many ES6 features with no runtime requirements

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

acorn-es6

Support many ES6 features with no runtime requirements. Sometimes this results in more code, but it provides a much cleaner build system. Things like Map, Set, Symbol etc. must be polyfilled separately if you wish to use them. This module only aims to provide syntax extensions.

Build Status Dependency Status NPM version

Installation

npm install acorn-es6

Usage

var compile = require('acorn-es6');

var compiled = compile('var log = msg => console.log(msg);');
// => "var log = function (msg) { console.log(msg); };"

You can also use it as a browserify transform by specifying the transform as acorn-es6/browserify.

Supported ES6 features

arrowFunctions

var log = msg => console.log(msg);

defaultParameters

function logDeveloper(name, codes = 'JavaScript', livesIn = 'USA') {
  console.log('name: %s, codes: %s, lives in: %s', name, codes, livesIn);
}

forOf

for (var element of [1, 2, 3]) {
  console.log('element:', element);
}

propertyMethods

var object = {
  prop: 42,
  // No need for function
  method() {
    return this.prop;
  }
};

templateLiterals

var x = 5, y = 10;
console.log(`${x} + ${y} = ${ x + y}`);
// 5 + 10 = 15

restParameters

function printList(listname, ...items) {
  console.log('list %s has the following items', listname);
  items.forEach(function (item) { console.log(item); });
}

spread

function add(x, y) {
  console.log('%d + %d = %d', x, y, x + y);
}
var numbers = [5, 10]
add(...numbers);
// 5 + 10 = 15

License

MIT

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