Iterant

Wraps any JavaScript iterable (i.e. an object that has a Symbol.iterator property) to provide a common iterface, regardless of the underlying concrete type. Where possible and apporpriate this interface matches the built-in Array. Thus, you can call the same Iterant#map on an Array, a MarkLogic Seqeunce, or a generator—anything that’s iterable. Type-specific Iterant extensions override the built-in methods to provide implementations that delegate to their wrapped concrete types.

Iterant(iterable: Iterable): Iterant
Parameters
iterable (Iterable) Any iterable (i.e. something that has a Symbol.iterator property)
Returns
Iterant: An new Iterant instance the wraps the passed in iterable
Example
Iterant(
  cts.collections() // Any iterable, such as Array, Map, generator function, etc.
)
  .filter(c => true) // Not very discriminating
  .map(c => { return { name: c, count: cts.frequency(c) }})
  .sort((a, b) => b.count - a.count)
  .reduce((prev, item) => prev + '\r' + item.count + ': ' + item.name, '');
Static Members
isIterable(obj, ignoreStrings?)
Instance Members
iterable
Symbol.iterator
Symbol.toStringTag
map(fct, that = null)
reduce(reducer, init)
slice(begin, end?)
filter(predicate, that?)
concat(items)
sort(comparator?)
clone()
toArray()

IterantArray

An IterantArray extends Iterant with functionality specific to built-in JavaScript Array instances.

IterantArray(array: Array): IterantArray

Extends Iterant

Parameters
array (Array) An Array
Returns
IterantArray: A new IterantArray
Throws
Instance Members
slice(begin?, end?)
map(mapper, that)

IterantSequence

An IterantSequence extends Iterant with functionality specific to MarkLogic Sequence instances.

IterantSequence(sequence: Sequence): IterantSequence

Extends Iterant

Parameters
sequence (Sequence) A MarkLogic Sequence
Returns
IterantSequence: A new IterantSequence
Throws
Instance Members
slice(begin?, end?)

Iterable

Iterable is a protocol which when implemented allows a JavaScript object to define their iteration behavior, such as what values are looped over in a for..of loop or iterall's forEach function. Many built-in types implement the Iterable protocol, including Array and Map.

While described by the ES2015 version of JavaScript it can be utilized by any version of JavaScript.

Iterable

Type: Object

Parameters
iterable (any)
Properties
Symbol.iterator (function (): Iterator<T>) : A method which produces an Iterator for this Iterable.

Iterator

Iterator is a protocol which describes a standard way to produce a sequence of values, typically the values of the Iterable represented by this Iterator.

While described by the ES2015 version of JavaScript it can be utilized by any version of JavaScript.

Iterator

Type: Object

Parameters
iterable (any)
Properties
next (function (): {value: T, done: boolean}) : A method which produces either the next value in a sequence or a result where the done property is true indicating the end of the Iterator.