jsbeans

jsbeans  1.0.0

jsbeans > jsbeans > jsbeans.Iterator
Search:
 
Filters

Class jsbeans.Iterator

An Iterator generates a series of elements, one at a time. Successive calls to the {@method} next method return successive elements of the series.

Constructor

jsbeans.Iterator ( object , [parserFunction] )
Parameters:
object <Object> any object that supports the for in directive.
[parserFunction] <Function> a custom function to format each element returned by next.
parserFunction will be called with property name as first argument and property value as second one.
If not set or parserFunction is not a Function the default parser will be used (see next method).
Please, note that error handling is up to developer since the catch block on each step is empty.
To return a JSON in the format {name: itemName, value: itemValue} use jsbeans.Iterator.JSON_FORMAT

Properties

JSON_FORMAT - static final Function

Facility function to format items in the form of a JSON as follow: {name: itemName, value: itemValue}

Methods

hasNext

boolean hasNext ( )
Returns true if the iteration has more elements.
Returns: boolean

next

Array next ( )
Returns the next element in the iteration.
Returns: Array
an Array of original Object with the property name at first position and the property value at second position ([name, value]).
If the constructor has been called with the optional parserFunction argument the result format may vary.


Copyright © 2016 Francesco Mele. All rights reserved.