https://github.com/planetarium/check-free-space
Checks if there are enough space in a specified path.
https://github.com/planetarium/check-free-space
Last synced: 5 months ago
JSON representation
Checks if there are enough space in a specified path.
- Host: GitHub
- URL: https://github.com/planetarium/check-free-space
- Owner: planetarium
- License: mit
- Created: 2021-10-25T10:08:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-26T12:24:02.000Z (almost 3 years ago)
- Last Synced: 2024-10-30T05:35:04.147Z (6 months ago)
- Language: JavaScript
- Size: 60.5 KB
- Stars: 8
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @planetarium/check-free-space
This package uses native OS APIs to get free size available on specified path. It is powered by [`fs2`](https://github.com/danburkert/fs2-rs) under the hood.
## APIs
### getFreeSpace
```typescript
import { getFreeSpace } from '@planetarium/check-free-space';getFreeSpace('./')
```Gets free space available on specified path. **It returns BigInt.**
### checkFreeSpace
```typescript
import { checkFreeSpace } from '@planetarium/check-free-space';if (checkFreeSpace('./', BigInt(1_000_000_000_000))) {
console.log('Enough space available');
}
```Checks if there are enough space to store specified amount of bytes in a specified path. You can provide a BigInt, string, or number value for bytes.
If you passed a string as bytes, it may throw if the string cannot be parsed as numerical value. If BigInt is passed, it will be converted to Rust `u64` during the process.