writes text data to a file on supported runtimes (i.e. RUNTIME.DENO, RUNTIME.BUN, or RUNTIME.NODE). for unsupported runtimes, an error is thrown.

TODO: in the future, I would like to create a unified cross-runtime filesystem class under ./crossfs.ts, which would support read and write operations, along with memory (internal state) of the current working directory, in addition to a path resolver method that will rely on ./pathman.ts's resolvePathFactory function.

an error is thrown if an unsupported runtime uses this function, or if config.create is false, and no pre-existing file resides at the specified file_path.

  • Parameters

    • runtime_enum: RUNTIME

      the runtime enum indicating which runtime should be used for writing onto the filesystem.

    • file_path: string | URL

      the destination file path.

    • text: string

      the string content to write.

    • config: Partial<WriteFileConfig> = {}

      provide optional configuration on how the writing should be performed.

    Returns Promise<void>