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

es6-comprehensions

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-comprehensions

Array comprehensions compiled to ES5.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

es6-comprehensions

Compiles JavaScript array comprehensions (proposed in ES6) to ES5-compatible syntax. For instance:

var squared = [ for (x of [1,2,3,4,5]) if (x > 2) x * x ];

compiles to:

var squared = (function() {
  var result = [];

  for (var i_0 = 0, arr_0 = [1,2,3,4,5], len_0 = arr_0.length, x; i_0 < len_0; i_0++) {
    x = arr_0[i_0];

    if (x > 2) {
      result.push(x * x);
    }
  }

  return result;
})();

For more information check out the current draft for ECMAScript 6.

Please notice that the syntax has changed and many resources is still using old one.

Installation

$ npm install es6-comprehensions

Support

Array comprehensions progressed to the Draft ECMAScript 6 Specification. It doesn't mean that there will be no changes or that array comprehensions will be included in the final ES6 Specification.

ES6 defines also iterators that can be used together with for-of loops that can be used in array comprehensions. This translator does not support iterators in for-of loops. It translates for-of loops to plain for loops. Thus, it supports only plain JS arrays.

TODO

  • Provide support for other structures, not only plain JS arrays,
  • Improve quality of the generated code,
  • Think of migration to escodegen instead of recast.

Development

  1. Clone the repository.
  2. Run npm install.
  3. Do your changes.

Pull requests are highly appreciated.

License

BSD

Keywords

FAQs

Package last updated on 04 Dec 2013

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