A disk I/O management utility to reserve, allocate, and optimize disk space usage, trying to ensure efficient file handling. Seamlessly locks disk space in advance, freeing and reallocating it for future I/O operations with optimal pagination for maximum performance.
A disk I/O management utility to reserve, allocate, and optimize disk space usage, trying to ensure efficient file handling.
📥 Installation
1npm install diskio-core
📚 Use case
The DiskIO class is a utility that allows you to reserve, allocate, and optimize disk space usage, trying to ensure efficient file handling. It is designed to be used in a Node.js environment.
📋 Features
Reserve disk space for a specific amount of bytes.
Allocate disk space for a specific amount of bytes.
Optimize disk space usage by allocating and freeing disk space as needed.
Create, read, and delete files.
Get information about the disk and DiskIO usage.
📖 Usage
DiskIO
The DiskIO class is used to create an instance of the DiskIO class. It requires two parameters: the path to the directory where the DiskIO will be created and the amount of bytes to reserve for the DiskIO.
1import { DiskIO } from'diskio-core';
23const diskio = new DiskIO('./mocks/diskio-a', 10 * 1024 * 1024);
4// Need to wait for the DiskIO to be ready5await diskio.ready;
6
DiskIO.information
The information property is used to get information about the DiskIO and the DiskIO usage. It has two methods: disk and diskio.
DiskIO.information.disk
The disk method is used to get information about the disk usage. It returns an object with the following properties:
filesystem: The filesystem type.
size: The total size of the disk in bytes.
used: The amount of used space in bytes.
available: The amount of available space in bytes.
The read method is used to read a file from the DiskIO. It requires three parameters: the file handle, the starting position, and the number of bytes to read.
The write method is used to write a file to the DiskIO. It requires three parameters: the file handle, the data to be written, and the starting position.