es6-iterator

WebJar for es6-iterator

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

es6-iterator
Last Version

Last Version

2.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

es6-iterator
WebJar for es6-iterator
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/medikoo/es6-iterator

Download es6-iterator

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/es6-iterator/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>es6-iterator</artifactId>
    <version>2.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/es6-iterator/
implementation 'org.webjars.npm:es6-iterator:2.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/es6-iterator/
implementation ("org.webjars.npm:es6-iterator:2.0.3")
'org.webjars.npm:es6-iterator:jar:2.0.3'
<dependency org="org.webjars.npm" name="es6-iterator" rev="2.0.3">
  <artifact name="es6-iterator" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='es6-iterator', version='2.0.3')
)
libraryDependencies += "org.webjars.npm" % "es6-iterator" % "2.0.3"
[org.webjars.npm/es6-iterator "2.0.3"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : d jar [1,2)
org.webjars.npm : es5-ext jar [0.10.35,0.11)
org.webjars.npm : es6-symbol jar [3.1.1,4)

Project Modules

There are no modules declared in this project.

es6-iterator

ECMAScript 6 Iterator interface

Installation

$ npm install es6-iterator

To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack

API

Constructors

Iterator(list) (es6-iterator)

Abstract Iterator interface. Meant for extensions and not to be used on its own.

Accepts any list object (technically object with numeric length property).

Mind it doesn't iterate strings properly, for that use dedicated StringIterator

var Iterator = require('es6-iterator')
var iterator = new Iterator([1, 2, 3]);

iterator.next(); // { value: 1, done: false }
iterator.next(); // { value: 2, done: false }
iterator.next(); // { value: 3, done: false }
iterator.next(); // { value: undefined, done: true }

ArrayIterator(arrayLike[, kind]) (es6-iterator/array)

Dedicated for arrays and array-likes. Supports three iteration kinds:

  • value (default) - Iterates values
  • key - Iterates indexes
  • key+value - Iterates keys and indexes, each iteration value is in [key, value] form.
var ArrayIterator = require('es6-iterator/array')
var iterator = new ArrayIterator([1, 2, 3], 'key+value');

iterator.next(); // { value: [0, 1], done: false }
iterator.next(); // { value: [1, 2], done: false }
iterator.next(); // { value: [2, 3], done: false }
iterator.next(); // { value: undefined, done: true }

May also be used for arguments objects:

(function () {
  var iterator = new ArrayIterator(arguments);

  iterator.next(); // { value: 1, done: false }
  iterator.next(); // { value: 2, done: false }
  iterator.next(); // { value: 3, done: false }
  iterator.next(); // { value: undefined, done: true }
}(1, 2, 3));

StringIterator(str) (es6-iterator/string)

Assures proper iteration over unicode symbols.
See: http://mathiasbynens.be/notes/javascript-unicode

var StringIterator = require('es6-iterator/string');
var iterator = new StringIterator('fπŸ™ˆoπŸ™‰oπŸ™Š');

iterator.next(); // { value: 'f', done: false }
iterator.next(); // { value: 'πŸ™ˆ', done: false }
iterator.next(); // { value: 'o', done: false }
iterator.next(); // { value: 'πŸ™‰', done: false }
iterator.next(); // { value: 'o', done: false }
iterator.next(); // { value: 'πŸ™Š', done: false }
iterator.next(); // { value: undefined, done: true }

Function utilities

forOf(iterable, callback[, thisArg]) (es6-iterator/for-of)

Polyfill for ECMAScript 6 for...of statement.

var forOf = require('es6-iterator/for-of');
var result = [];

forOf('πŸ™ˆπŸ™‰πŸ™Š', function (monkey) { result.push(monkey); });
console.log(result); // ['πŸ™ˆ', 'πŸ™‰', 'πŸ™Š'];

Optionally you can break iteration at any point:

var result = [];

forOf([1,2,3,4]', function (val, doBreak) {
  result.push(monkey);
  if (val >= 3) doBreak();
});
console.log(result); // [1, 2, 3];

get(obj) (es6-iterator/get)

Return iterator for any iterable object.

var getIterator = require('es6-iterator/get');
var iterator = get([1,2,3]);

iterator.next(); // { value: 1, done: false }
iterator.next(); // { value: 2, done: false }
iterator.next(); // { value: 3, done: false }
iterator.next(); // { value: undefined, done: true }

isIterable(obj) (es6-iterator/is-iterable)

Whether obj is iterable

var isIterable = require('es6-iterator/is-iterable');

isIterable(null); // false
isIterable(true); // false
isIterable('str'); // true
isIterable(['a', 'r', 'r']); // true
isIterable(new ArrayIterator([])); // true

validIterable(obj) (es6-iterator/valid-iterable)

If obj is an iterable it is returned. Otherwise TypeError is thrown.

Method extensions

iterator.chain(iterator1[, …iteratorn]) (es6-iterator/#/chain)

Chain multiple iterators into one.

Tests Build Status

$ npm test

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.


Get professional support for d with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
2.0.3
2.0.0
0.1.3
0.1.1