package prr

  1. Overview
  2. Docs

Module Jv.ItSource

JavaScript iterator protocol.

Iterator results

Sourcetype result = jv

The type for objects satisfying the IteratorResult interface.

Sourceval result_done : result -> bool

result_done r is true iff r has a done property and its value is true.

Sourceval result_value : result -> jv option

result_value r is the value property of r (if any). This may only be None if result_done r is true.

Sourceval get_result_value : result -> jv

get_result_value r is the value property of r. This should always be well defined as long as result_done r is false.

Iterators

Sourcetype t = jv

The type for objects satisfying the iterator protocol.

Sourceval iterable : jv -> t option

iterable v is v's iterator object (if any) looked up according to the iterable protocol.

Sourceval iterator : jv -> t

iterator jv is Option.get (iterable jv).

Sourceval next : t -> result

next it is the next result of iterator it.

Sourceval fold : (jv -> 'a) -> ('a -> 'b -> 'b) -> t -> 'b -> 'b

fold of_jv f it folds f over the results provided by it and converted with of_jv until one is done. The return value of the iterator is ignored.

Sourceval fold_bindings : key:(jv -> 'a) -> value:(jv -> 'b) -> ('a -> 'b -> 'c -> 'c) -> t -> 'c -> 'c

fold_bindings is like fold except it assumes the iterator values are two-element arrays whose values are directly given to f in order. The return value of the iterator is ignored.