code: public void run(Iterable<Item> items, Context cx) {
          Function prepareFunc = (Function) indexResults.getPrototype().get("prepare", indexResults);
          prepareFunc.call(cx, scope, indexResults, NO_ARGS);
  
          Object args[] = new Object[] { null, mapFunction };
          for (Item item : items) {
              args[0] = item;
              indexFunction.call(cx, scope, indexResults, args);
          }
  
          Function doneFunc = (Function) indexResults.getPrototype().get("setDone", indexResults);
          doneFunc.call(cx, scope, indexResults, NO_ARGS);
      }
docs: Run the indexer on the given iterable of items. This will attempt to apply some
  optimizations to ensure that only items which need re-indexing are actually passed
  to the map function.
  
  @param items The items to index
  @param cx The current execution context