happy-opfs
    Preparing search index...

    Function truncateSync

    • Synchronous version of truncate. Truncates (resizes) a file to the specified size.

      If len is smaller than the current file size, the file is shortened and the trailing data is discarded. If len is larger, the file is extended with zero bytes (\x00).

      Parameters

      • filePath: string

        The absolute path of the file to truncate.

      • len: number

        The target size in bytes. Must be a non-negative integer.

      Returns VoidIOResult

      A VoidIOResult indicating success or failure.

      truncate for the async version.

      2.2.0

      truncateSync('/log.txt', 5)
      .inspect(() => console.log('File truncated'));