@rogerpence/rp-utils
    Preparing search index...

    Function writeObjectToFile

    • Writes a JavaScript object to a JSON file.

      Parameters

      • object: unknown

        The object to serialize and write to the file

      • filePath: string

        The path where the JSON file will be written

      • Optionaloptions: WriteObjectToFileOptions

        Optional configuration.

        Options for the writeObjectToFile function.

        • Optionalcompressed?: boolean

          When true, remove whitespace from seralized object.

        • OptionalexportName?: string

          When provided, creates an export with this name. Should be used only for .ts/.js files.

        • Optionallog?: boolean

          Write a message to the command line.

      Returns void

      If the file cannot be written or the object cannot be serialized

      Write with default options (formatted, logged):
      writeObjectToFile('data.json', myObject);
      Write compressed without logging:
      writeObjectToFile('data.json', myObject, { compressed: true, log: false });
      Write with custom name for logging:
      writeObjectToFile('index.json', indexObjects, { objectName: 'indexObjects' });