esnext
Update your project to the latest ECMAScript syntax.
Last updated 2 years ago by eventualbuddha .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install esnext 
SYNC missed versions from official npm registry.

esnext Build Status

Bring your JavaScript into the future.

Installation

$ yarn global add esnext
# or, with `npm`:
$ npm install -g esnext

Usage

After installing, run esnext -h for comprehensive usage instructions.

Features

Functions

Translate some regular functions to arrow functions:

list.map(function(item) { return item.name; });

// ↑ becomes ↓

list.map(item => item.name);

Declarations

Convert var declarations to let or const as appropriate:

var arr = [];
for (var i = 0; i < 5; i++) {
  arr.push(i);
}

// ↑ becomes ↓

const arr = [];
for (let i = 0; i < 5; i++) {
  arr.push(i);
}

Objects

Use shorthand syntax for various object constructs:

let person = {
  first: first,
  last: last,
  
  fullName: function() {
    return `${first} ${last}`;
  }
};

// ↑ becomes ↓

let person = {
  first,
  last,
  
  fullName() {
    return `${first} ${last}`;
  }
};

Strings

Convert string concatenation to string or template literals:

let name = 'Brian' + ' ' + 'Donovan';
let greeting = 'Hello, ' + name;

// ↑ becomes ↓

let name = 'Brian Donovan';
let greeting = `Hello, ${name}`;

Destructuring

Convert assignments and declarations to use object destructuring syntax:

let a = obj.a, b = obj.b;
a = obj2.a, b = obj2.b;

// ↑ becomes ↓

let { a, b } = obj;
({ a, b } = obj2);

Modules

Translate CommonJS modules into ES6 modules:

var readFile = require('fs').readFile;
const MagicString = require('magic-string');
let { ok, strictEqual: eq } = require('assert');

exports.doSomething = function() {
  ok(1);
};

// ↑ becomes ↓

import { readFile } from 'fs';
import MagicString from 'magic-string';
import { ok, strictEqual as eq } from 'assert';

export function doSomething() {
  ok(1);
}

Options

{
  'declarations.block-scope': {
    /**
     * Set this to `true` to only turn `var` into `let`, never `const`.
     */
    disableConst: boolean
  }
}

Current Tags

  • 3.3.1                                ...           latest (2 years ago)

116 Versions

  • 3.3.1                                ...           2 years ago
  • 3.3.0                                ...           2 years ago
  • 3.2.1                                ...           2 years ago
  • 3.2.0                                ...           2 years ago
  • 3.1.7                                ...           2 years ago
  • 3.1.6                                ...           2 years ago
  • 3.1.5                                ...           2 years ago
  • 3.1.4                                ...           2 years ago
  • 3.1.3                                ...           2 years ago
  • 3.1.2                                ...           3 years ago
  • 3.1.1                                ...           3 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.19                                ...           3 years ago
  • 3.0.18                                ...           3 years ago
  • 3.0.17                                ...           3 years ago
  • 3.0.16                                ...           3 years ago
  • 3.0.15                                ...           3 years ago
  • 3.0.14                                ...           3 years ago
  • 3.0.13                                ...           3 years ago
  • 3.0.12                                ...           3 years ago
  • 3.0.11                                ...           3 years ago
  • 3.0.10                                ...           3 years ago
  • 3.0.9                                ...           3 years ago
  • 3.0.8                                ...           3 years ago
  • 3.0.7                                ...           3 years ago
  • 3.0.6                                ...           3 years ago
  • 3.0.5                                ...           3 years ago
  • 3.0.4                                ...           3 years ago
  • 3.0.3                                ...           3 years ago
  • 3.0.2                                ...           3 years ago
  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.1.4                                ...           3 years ago
  • 2.1.3                                ...           3 years ago
  • 2.1.2                                ...           3 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 1.17.2                                ...           4 years ago
  • 1.17.1                                ...           4 years ago
  • 1.17.0                                ...           4 years ago
  • 1.16.0                                ...           4 years ago
  • 1.15.8                                ...           4 years ago
  • 1.15.7                                ...           4 years ago
  • 1.15.6                                ...           4 years ago
  • 1.15.5                                ...           4 years ago
  • 1.15.4                                ...           4 years ago
  • 1.15.3                                ...           4 years ago
  • 1.15.2                                ...           4 years ago
  • 1.15.1                                ...           4 years ago
  • 1.15.0                                ...           4 years ago
  • 1.14.3                                ...           4 years ago
  • 1.14.2                                ...           4 years ago
  • 1.14.1                                ...           4 years ago
  • 1.14.0                                ...           4 years ago
  • 1.13.0                                ...           4 years ago
  • 1.12.1                                ...           4 years ago
  • 1.12.0                                ...           4 years ago
  • 1.11.2                                ...           4 years ago
  • 1.11.0                                ...           4 years ago
  • 1.10.2                                ...           4 years ago
  • 1.10.1                                ...           4 years ago
  • 1.10.0                                ...           4 years ago
  • 1.9.2                                ...           4 years ago
  • 1.9.1                                ...           4 years ago
  • 1.9.0                                ...           4 years ago
  • 1.8.3                                ...           4 years ago
  • 1.8.2                                ...           4 years ago
  • 1.8.1                                ...           4 years ago
  • 1.7.0                                ...           4 years ago
  • 1.6.0                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.1                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.2                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 0.14.0                                ...           5 years ago
  • 0.13.2                                ...           5 years ago
  • 0.13.1                                ...           5 years ago
  • 0.13.0                                ...           5 years ago
  • 0.12.0                                ...           5 years ago
  • 0.11.1                                ...           5 years ago
  • 0.11.0                                ...           5 years ago
  • 0.10.0                                ...           5 years ago
  • 0.9.0                                ...           5 years ago
  • 0.8.3                                ...           5 years ago
  • 0.8.2                                ...           5 years ago
  • 0.8.1                                ...           5 years ago
  • 0.8.0                                ...           5 years ago
  • 0.7.13                                ...           5 years ago
  • 0.7.12                                ...           5 years ago
  • 0.7.11                                ...           5 years ago
  • 0.7.10                                ...           6 years ago
  • 0.7.9                                ...           6 years ago
  • 0.7.8                                ...           6 years ago
  • 0.7.7                                ...           6 years ago
  • 0.7.6                                ...           6 years ago
  • 0.7.5                                ...           6 years ago
  • 0.7.4                                ...           6 years ago
  • 0.7.3                                ...           6 years ago
  • 0.7.2                                ...           6 years ago
  • 0.7.1                                ...           6 years ago
  • 0.7.0                                ...           6 years ago
  • 0.6.0                                ...           6 years ago
  • 0.5.0                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago

Copyright 2014 - 2016 © taobao.org |