0.3.1 • Published 10 years ago

es6-for-of v0.3.1

Weekly downloads
16
License
-
Repository
-
Last release
10 years ago

es6-for-of

Compiles JavaScript written using ES6 for-of to ES3 syntax. For example, this:

for (var a of b) {
  console.log(a);
}

compiles to this:

var $__getIterator = function(iterable) {
  var sym = (typeof Symbol === "function" ? Symbol.iterator : "@@iterator");

  if (typeof iterable[sym] === "function") {
    return iterable[sym]();
  } else if (Object.prototype.toString.call(iterable) === "[object Array]") {
    return $__arrayIterator(iterable);
  } else {
    throw new TypeError();
  }
};

var $__arrayIterator = function(array) {
  var index = 0;

  return {
    next: function() {
      if (index >= array.length) {
        return {
          done: true,
          value: void 0
        };
      } else {
        return {
          done: false,
          value: array[index++]
        };
      }
    }
  };
};

for (var $__0 = $__getIterator(b), $__1; !($__1 = $__0.next()).done; ) {
  var a = $__1.value;
  console.log(a);
}

Install

$ npm install es6-for-of

Browserify

Browserify support is built in.

$ npm install es6-for-of  # install local dependency
$ browserify -t es6-for-of $file

Setup

First, install the development dependencies:

$ npm install

Then, try running the tests:

$ npm test
0.3.1

10 years ago

0.3.0

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago