pop-iterate

WebJar for pop-iterate

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

pop-iterate
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

pop-iterate
WebJar for pop-iterate
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/kriskowal/pop-iterate

Скачать pop-iterate

Как подключить последнюю версию

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

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

Iterate

This JavaScript package exports an iterator operator that accepts arrays and any object that implements iterate.

$ npm install --save pop-iterate

The iterate operator accepts an array, or object that implements iterate, and returns an iterator, as described by the iterator protocol, with some extensions. The iterations have an index property with the index corresponding to the value.

var iterator = iterate([1, 2, 3]);
expect(iterator.next()).toEqual({value: 1, done: false, index: 0});
expect(iterator.next()).toEqual({value: 2, done: false, index: 1});
expect(iterator.next()).toEqual({value: 3, done: false, index: 2});
expect(iterator.next()).toEqual({done: true});

Iterating on an array, the iterate method accepts optional start, stop, and step arguments.

var array = [1, 2, 3, 4, 5, 6, 7, 8];
var iterator = iterate(array, 1, 6, 2);
expect(iterator.next()).toEqual({value: 2, done: false, index: 1});
expect(iterator.next()).toEqual({value: 4, done: false, index: 3});
expect(iterator.next()).toEqual({value: 6, done: false, index: 5});
expect(iterator.next()).toEqual({done: true});

The iterate operator also iterates the owned properties of an object.

var object = {a: 10, b: 20, c: 30};
var iterator = iterate(object);
expect(iterator.next()).toEqual({value: 10, done: false, index: "a"});
expect(iterator.next()).toEqual({value: 20, done: false, index: "b"});
expect(iterator.next()).toEqual({value: 30, done: false, index: "c"});
expect(iterator.next()).toEqual({done: true});

Polymorphic operator

A well-planned system of objects is beautiful: a system where every meaningful method for an object has been anticipated in the design. Inevitably, another layer of architecture introduces a new concept and with it the temptation to monkey-patch, dunk-punch, or otherwise cover-up the omission. But reaching backward in time, up through the layers of architecture doesn't always compose well, when different levels introduce concepts of the same name but distinct behavior.

A polymorphic operator is a function that accepts as its first argument an object and varies its behavior depending on its type. Such an operator has the benefit of covering for the types from higher layers of architecture, but defers to the eponymous method name of types yet to be defined.

The iterate operator works for arrays and objects. Any other object can be iterable by implementing the iterate method, and the iterate operator will defer to it.

function Collection() {}
Collection.prototype.iterate = function (start, stop, step) {
};

This package also exports the individual parts form which it makes iterators.

var Iteration = require("pop-iterate/iteration");
var ArrayIterator = require("pop-iterate/array-iterator");
var ObjectIterator = require("pop-iterate/object-iterator");

Версии библиотеки

Версия
1.0.1