-
Notifications
You must be signed in to change notification settings - Fork 1
filesystemUtils
Defined in: src/filesystemUtils.mts:10
| Property | Type | Description | Defined in |
|---|---|---|---|
path?
|
string |
Path where the temporary file should be created. | src/filesystemUtils.mts:14 |
writerOptions?
|
object |
Options object defined by the first parameter accepted by BunFile.writer(). |
src/filesystemUtils.mts:18 |
writerOptions.highWaterMark? |
number |
- | node_modules/bun-types/bun.d.ts:2159 |
findMissingPaths(
paths):Promise<string[]>
Defined in: src/filesystemUtils.mts:30
Compile a list of all inaccessible file paths, then return it. If all paths are valid, the list will be empty.
| Parameter | Type | Description |
|---|---|---|
paths |
string[] |
List of file and/or directory paths. |
Promise<string[]>
The list of inaccessible paths, if any.
getHumanReadableFilesize(
filesize,localeOverride?):string
Defined in: src/filesystemUtils.mts:72
Get a human readable filesize given its numeric value and an optional locale.
| Parameter | Type | Description |
|---|---|---|
filesize |
number |
A file's size represented as a number. |
localeOverride? |
string |
An optional locale value to override the default set by the operating system. |
string
A localized string representing a file size.
getPathsRecursive(
rootDirectory,ignore):Promise<string[]>
Defined in: src/filesystemUtils.mts:48
Recursively build a list of paths starting at a target directory. Ignore any paths that match values in the included ignore list.
| Parameter | Type | Description |
|---|---|---|
rootDirectory |
string |
The root directory of the search. |
ignore |
string[] |
The list of path segment names to match and ignore. |
Promise<string[]>
A list of paths.
isDirectoryAccessible(
path):Promise<boolean>
Defined in: src/filesystemUtils.mts:93
Determine if the provided path can be successfully accessed.
| Parameter | Type | Description |
|---|---|---|
path |
string |
Path whose permissions to check. |
Promise<boolean>
Boolean indicating whether or not the path is accessible.
usingNewTemporaryFile(
options?):object
Defined in: src/filesystemUtils.mts:132
Create a new temporary file with an
await using variable declaration
then append to it with a
FileSink instance.
Automatically delete the file when its variable falls out of scope. Customize file behavior with
an optional options object as follows:
{
path?: string; // Target path to use for temporary file creation.
writerOptions?: Parameters<BunFile['writer']>[0]; // Options object to customize `Bun.file().writer()` behavior
}.
| Parameter | Type | Description |
|---|---|---|
options? |
TemporaryFileOptions |
Options object to customize temporary file behavior. |
Temporary file instance object.
| Name | Type | Description | Defined in |
|---|---|---|---|
[asyncDispose]() |
() => Promise<void> |
Asynchronous automatic disposal function. | src/filesystemUtils.mts:152 |
append() |
(appendContents, shouldForceFlush) => Promise<void> |
Append string contents to the target temporary file. | src/filesystemUtils.mts:142 |
https://github.com/tc39/proposal-explicit-resource-management to explain the origin and use of the using keyword
import { usingNewTemporaryFile } from '@mangs/bun-utils/filesystem';
await using file = usingNewTemporaryFile();
await file.append('test data 42\n');
// sometime later...
await file.append('holy data, batman\n');
// file auto-deletes at the end of its execution scope