function generateNextResource() {
        var resStream

        for (
          let cur_index = 0;
          cur_index < privateData.resources.length;
          cur_index++
        ) {
          if (officegenGlobals.settings.verbose) {
            console.log(
              '[officegen] generateNextResource ' + cur_index + ' : ',
              privateData.resources[cur_index]
            )
          }

          if (typeof privateData.resources[cur_index] !== 'undefined') {
            switch (privateData.resources[cur_index].type) {
              // Generate the resource text data by calling to provided function:
              case 'buffer':
                resStream = privateData.resources[cur_index].callback(
                  privateData.resources[cur_index].data
                )
                break

              // Just copy the file as is:
              case 'file':
                resStream = fs.createReadStream(
                  privateData.resources[cur_index].data ||
                    privateData.resources[cur_index].name
                )
                break

              // Just use this stream:
              case 'stream':
                resStream = privateData.resources[cur_index].data
                break

              // Officegen object:
              case 'officegen':
                resStream = new PassThrough()
                privateData.resources[cur_index].data.generate(resStream)
                break

              // Custom parser:
              default:
                for (var cur_parserType in officegenGlobals.resParserTypes) {
                  if (
                    cur_parserType === privateData.resources[cur_index].type &&
                    officegenGlobals.resParserTypes[cur_parserType] &&
                    officegenGlobals.resParserTypes[cur_parserType].parserFunc
                  ) {
                    resStream = officegenGlobals.resParserTypes[
                      cur_parserType
                    ].parserFunc(
                      genobj,
                      privateData.resources[cur_index].name,
                      privateData.resources[cur_index].callback, // Can be used as the template source for template engines.
                      privateData.resources[cur_index].data, // The data for the template engine.
                      officegenGlobals.resParserTypes[cur_parserType].extra_data
                    )
                    break
                  } // Endif.
                } // End of for loop.
            } // End of switch.

            if (typeof resStream !== 'undefined') {
              if (officegenGlobals.settings.verbose) {
                console.log(
                  '[officegen] Adding into archive : "' +
                    privateData.resources[cur_index].name +
                    '" (' +
                    privateData.resources[cur_index].type +
                    ')...'
                )
              } // Endif.

              archive.append(resStream, {
                name: privateData.resources[cur_index].name
              })

              continue
            } else {
              if (officegenGlobals.settings.verbose) {
                console.log('[officegen] resStream is undefined') // is it normal ??
              }
              continue
            } // Endif.
          } else {
            // Removed resource - just ignore it:
            continue
          } // Endif.
        } // Endfor

        privateData.resources.forEach(function (resource) {
          if (resource.removed_after_used) {
            var filename = resource.data || resource.name

            if (officegenGlobals.settings.verbose) {
              console.log('[officegen] Removing resource: ', filename)
            }

            fs.unlinkSync(filename)
          }
        })

        // No more resources to add - close the archive:
        if (officegenGlobals.settings.verbose) {
          console.log('[officegen] Finalizing archive ...')
        }
        archive.finalize()

        // Event to the type generator:
        genobj.emit('afterGen', privateData, null, archive.pointer())

        genobj.emit('finalize', archive.pointer())
      }
Add the next resource into the zip stream.
<br /><br />

This function adding the next resource into the zip stream.