Gathering detailed insights and metrics for diskio-core
Gathering detailed insights and metrics for diskio-core
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.
npm install diskio-core
Typescript
Module System
Node Version
NPM Version
74.1
Supply Chain
99.4
Quality
82.5
Maintenance
100
Vulnerability
80.9
License
TypeScript (98.44%)
Shell (1.56%)
Total Downloads
1,057
Last Day
1
Last Week
9
Last Month
50
Last Year
1,057
31 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.5.0
Package Id
diskio-core@1.5.0
Unpacked Size
87.56 kB
Size
19.73 kB
File Count
33
NPM Version
10.9.0
Node Version
20.18.0
Publised On
20 Nov 2024
Cumulative downloads
Total Downloads
Last day
-80%
1
Compared to previous day
Last week
-25%
9
Compared to previous week
Last month
-39.8%
50
Compared to previous month
Last year
0%
1,057
Compared to previous year
1npm install diskio-core
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.
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'; 2 3const diskio = new DiskIO('./mocks/diskio-a', 10 * 1024 * 1024); 4// Need to wait for the DiskIO to be ready 5await diskio.ready; 6
The information
property is used to get information about the DiskIO and the DiskIO usage. It has two methods: disk
and diskio
.
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.capacity
: The percentage of used space.mount
: The mount point of the disk.1const information = await diskio.information.disk(); 2 3console.log(information); 4/* 5{ 6 filesystem: 'ext4', 7 size: 1073741824, 8 used: 104857600, 9 available: 996147200, 10 capacity: '100%', 11 mount: '/' 12} 13*/
The diskio
method is used to get information about the DiskIO usage. It returns an object with the following properties:
size
: The size of the DiskIO in bytes.used
: The amount of used space in bytes.available
: The amount of available space in bytes.capacity
: The percentage of used space.1const information = await diskio.information.diskio(); 2 3console.log(information); 4/* 5{ 6 size: 104857600, 7 used: 104857600, 8 available: 0, 9 capacity: '100%' 10} 11*/
The create
method is used to create a new file in the DiskIO. It requires one parameter: the name of the file to be created.
NOTE: It will use and UUID to create a folder system to improve performance. Save name to rerieve it later.
NOTE: It's have a sync version -> createSync
.
1const file = await diskio.create('test.txt'); 2 3console.log(file.name); // 7cb79b23/b098/4c56/917c/005abaf72fd5/test.txt 4 5await file.close();
The get
method is used to get a file from the DiskIO.
It requires one parameter: the name of the file to be retrieved.
Optionally, you can set the second parameter to true
to check if the file exists. If file does not exist, it will throw an error.
NOTE: Is not required that the file exists in the DiskIO if you set the second parameter to false
.
NOTE: It's have a sync version -> getSync
.
1const file = await diskio.get('test.txt'); 2 3await file.close();
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.
NOTE: It's have a sync version -> readSync
.
1const file = await diskio.get('test.txt'); 2// Using diskio 3// const buffer = await diskio.read(file['fh'], 0, 1024); 4// Using file, better way 5const buffer = await file.read(0, 1024); 6 7console.log(buffer.toString()); // Hello world! 8 9await file.close();
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.
NOTE: It's have a sync version -> writeSync
.
1const file = await diskio.get('test.txt'); 2 3const buffer = Buffer.from('Hello world!'); 4// Using diskio 5await diskio.write(file['fh'], buffer, 0); 6// Using file, better way 7await file.write(buffer, 0); 8 9await file.close();
The delete
method is used to delete a file from the DiskIO. It requires two parameters: the file handle and the name of the file to be deleted.
NOTE: It will delete all the folders and files in the path that are not empty.
1const file = await diskio.get('test.txt'); 2// Using diskio 3await diskio.delete(file['fh'], file.name); 4// Using file, better way 5await file.delete();
This project is licensed under this GNU AFFERO GENERAL PUBLIC LICENSE.
No vulnerabilities found.
No security vulnerabilities found.