package prr

  1. Overview
  2. Docs

JavaScript iterator protocol.

Iterator results

type result = jv

The type for objects satisfying the IteratorResult interface.

val result_done : result -> bool

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

val 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.

val 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

type t = jv

The type for objects satisfying the iterator protocol.

val iterable : jv -> t option

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

val iterator : jv -> t

iterator jv is Option.get (iterable jv).

val next : t -> result

next it is the next result of iterator it.

val 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.

val 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.

OCaml

Innovation. Community. Security.