Function mapStructure

  • Iterate through every file child of a folder recursively, call a mapper function with each file's contents and write the returned value of the mapper to the files. when passing [[MapStructureFunctionAsync]] as a parameter, operations are done in parallel; to avoid running out of file handles, or to maintain the order (as provided by dive), use [[mapStructureOrdered]].

    Parameters

    • path: string

      folder path to iterate through

    • mapper: MapStructureFunction<string>

      mapping function to call on each file

    • readOptions: BufferEncoding | {
          encoding: BufferEncoding;
      }

      options to pass to [[readFile]]

    • Optional writeOptions: null | ObjectEncodingOptions & Abortable & {
          flag?: string;
          flush?: boolean;
          mode?: Mode;
      } | "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex"

      options to pass to [[writeFile]]

    Returns Promise<MapStructureResult[]>

    a [[Promise]] resolving to an array of all processed files

  • Parameters

    • path: string
    • mapper: MapStructureFunction<Buffer>
    • Optional readOptions: null | "buffer" | {
          encoding?: null | "buffer";
      }
    • Optional writeOptions: null | ObjectEncodingOptions & Abortable & {
          flag?: string;
          flush?: boolean;
          mode?: Mode;
      } | "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex"

    Returns Promise<MapStructureResult[]>

Generated using TypeDoc