/
index.d.ts
110 lines (92 loc) · 2.1 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
export interface SpaceInfo {
/**
Name of the filesystem.
*/
readonly filesystem: string;
/**
Type of the filesystem.
_(Not available on macOS)_
*/
readonly type: string;
/**
Total size in bytes.
*/
readonly size: number;
/**
Used size in bytes.
*/
readonly used: number;
/**
Available size in bytes.
*/
readonly available: number;
/**
Capacity as a float from `0` to `1`.
*/
readonly capacity: number;
/**
Disk mount location.
*/
readonly mountpoint: string;
}
/**
Get free disk space info from [`df -kP`](https://en.wikipedia.org/wiki/Df_\(Unix\)).
@returns A list of space info objects for each filesystem.
@example
```
import {diskSpace} from '@sindresorhus/df';
console.log(await diskSpace());
// [
// {
// filesystem: '/dev/disk1',
// type: 'ext4',
// size: 499046809600,
// used: 443222245376,
// available: 55562420224,
// capacity: 0.89,
// mountpoint: '/'
// },
// …
// ]
```
*/
export function diskSpace(): Promise<SpaceInfo[]>;
/**
Get free disk space info for the given filesystem.
@param pathToDeviceFile - A path to a filesystem device file. Example: `'/dev/disk1'`.
@returns Space info for the given filesystem.
@example
```
import {diskSpaceForFilesystem} from '@sindresorhus/df';
console.log(await diskSpaceForFilesystem('/dev/disk1'));
// {
// filesystem: '/dev/disk1',
// type: 'ext4',
// size: 499046809600,
// used: 443222245376,
// available: 55562420224,
// capacity: 0.89,
// mountpoint: '/'
// }
```
*/
export function diskSpaceForFilesystem(pathToDeviceFile: string): Promise<SpaceInfo>;
/**
@param path - A path to a file/directory on the filesystem to get the space info for.
@returns Space info for the filesystem the given path is part of.
@example
```
import {diskSpaceForFilesystemOwningPath} from '@sindresorhus/df';
console.log(await diskSpaceForFilesystemOwningPath('.'));
// {
// filesystem: '/dev/disk1',
// type: 'ext4',
// size: 499046809600,
// used: 443222245376,
// available: 55562420224,
// capacity: 0.89,
// mountpoint: '/'
// }
```
*/
export function diskSpaceForFilesystemOwningPath(path: string): Promise<SpaceInfo>;