Function mmap

  • Open a file as a live-updating Uint8Array without copying memory

    • Writing to the array writes to the file.
    • Reading from the array reads from the file.

    This uses the mmap() syscall under the hood.


    This API inherently has some rough edges:

    • It does not support empty files. It will throw a SystemError with EINVAL
    • Usage on shared/networked filesystems is discouraged. It will be very slow.
    • If you delete or truncate the file, that will crash bun. This is called a segmentation fault.

    To close the file, set the array to null and it will be garbage collected eventually.

    Parameters

    Returns Uint8Array

  • Open a file as a live-updating Uint8Array without copying memory

    • Writing to the array writes to the file.
    • Reading from the array reads from the file.

    This uses the mmap() syscall under the hood.


    This API inherently has some rough edges:

    • It does not support empty files. It will throw a SystemError with EINVAL
    • Usage on shared/networked filesystems is discouraged. It will be very slow.
    • If you delete or truncate the file, that will crash bun. This is called a segmentation fault.

    To close the file, set the array to null and it will be garbage collected eventually.

    Parameters

    Returns Uint8Array

Generated using TypeDoc