iteratorUtils

Description:
  • Set of utils for working with iterators in SFCC.
Source:
Set of utils for working with iterators in SFCC.

Methods

(inner) filter(iterator, callback) → {array}

Description:
  • Filters items in the iterator based on the provided callback function.
Source:
Parameters:
Name Type Description
iterator dw.util.Iterator The iterator to iterate over.
callback function The callback function to filter items. Takes two arguments: the current item and its index.
Returns:
An array containing the filtered items.
Type
array

(inner) forEach(iterator, callback) → {void}

Description:
  • Iterates over each item in the iterator and calls the provided callback function.
Source:
Parameters:
Name Type Description
iterator dw.util.Iterator The iterator to iterate over.
callback function The callback function to be called for each item. Takes two arguments: the current item and its index.
Returns:
Type
void

(inner) map(iterator, callback) → {array}

Description:
  • Maps each item in the iterator using the provided callback function.
Source:
Parameters:
Name Type Description
iterator dw.util.Iterator The iterator to iterate over.
callback function The callback function to map each item. Takes two arguments: the current item and its index.
Returns:
A new array containing the mapped items.
Type
array

(inner) reduce(iterator, callback, initialValue) → {*}

Description:
  • Reduces the items in the iterator to a single value using the provided callback function.
Source:
Parameters:
Name Type Description
iterator dw.util.Iterator The iterator to iterate over.
callback function The callback function to reduce items. Takes three arguments: the accumulator, the current item, and its index.
initialValue * The initial value of the accumulator.
Returns:
The final value of the accumulator after iteration.
Type
*