@thi.ng/file-io
Version:
Assorted file I/O utils (w/ logging support) for NodeJS/Bun
154 lines (115 loc) • 6.64 kB
Markdown
<!-- This file is generated - DO NOT EDIT! -->
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
# 
[](https://www.npmjs.com/package/@thi.ng/file-io)

[](https://mastodon.thi.ng/@toxi)
> [!NOTE]
> This is one of 210 standalone projects, maintained as part
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
> and anti-framework.
>
> 🚀 Please help me to work full-time on these projects by [sponsoring me on
> GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
- [About](#about)
- [Available functions](#available-functions)
- [Files](#files)
- [Directories](#directories)
- [Logging](#logging)
- [Status](#status)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [Usage examples](#usage-examples)
- [API](#api)
- [Authors](#authors)
- [License](#license)
## About
Assorted file I/O utils (w/ logging support) for NodeJS/Bun.
Most functions in this package have optional support for the
[`ILogger`](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
logging interface.
## Available functions
### Files
- [bufferHash](https://docs.thi.ng/umbrella/file-io/functions/bufferHash.html)
- [copyFile](https://docs.thi.ng/umbrella/file-io/functions/copyFile.html)
- [copyFileAsync](https://docs.thi.ng/umbrella/file-io/functions/copyFileAsync.html)
- [createTempFile](https://docs.thi.ng/umbrella/file-io/functions/createTempFile.html)
- [deleteFile](https://docs.thi.ng/umbrella/file-io/functions/deleteFile.html)
- [deleteFileAsync](https://docs.thi.ng/umbrella/file-io/functions/deleteFileAsync.html)
- [deleteFiles](https://docs.thi.ng/umbrella/file-io/functions/deleteFiles.html)
- [deleteFilesAsync](https://docs.thi.ng/umbrella/file-io/functions/deleteFilesAsync.html)
- [files](https://docs.thi.ng/umbrella/file-io/functions/files.html)
- [fileChunks](https://docs.thi.ng/umbrella/file-io/functions/fileChunks.html)
- [fileExt](https://docs.thi.ng/umbrella/file-io/functions/fileExt.html)
- [fileHash](https://docs.thi.ng/umbrella/file-io/functions/fileHash.html)
- [fileWatcher](https://docs.thi.ng/umbrella/file-io/functions/fileWatcher.html)
- [readBinary](https://docs.thi.ng/umbrella/file-io/functions/readBinary.html)
- [readBinaryAsync](https://docs.thi.ng/umbrella/file-io/functions/readBinaryAsync.html)
- [readJSON](https://docs.thi.ng/umbrella/file-io/functions/readJSON.html)
- [readJSONAsync](https://docs.thi.ng/umbrella/file-io/functions/readJSONAsync.html)
- [readText](https://docs.thi.ng/umbrella/file-io/functions/readText.html)
- [readTextAsync](https://docs.thi.ng/umbrella/file-io/functions/readTextAsync.html)
- [streamHash](https://docs.thi.ng/umbrella/file-io/functions/streamHash.html)
- [tempFilePath](https://docs.thi.ng/umbrella/file-io/functions/tempFilePath.html)
- [writeFile](https://docs.thi.ng/umbrella/file-io/functions/writeFile.html)
- [writeFileAsync](https://docs.thi.ng/umbrella/file-io/functions/writeFileAsync.html)
- [writeJSON](https://docs.thi.ng/umbrella/file-io/functions/writeJSON.html)
- [writeJSONAsync](https://docs.thi.ng/umbrella/file-io/functions/writeJSONAsync.html)
- [writeText](https://docs.thi.ng/umbrella/file-io/functions/writeText.html)
- [writeTextAsync](https://docs.thi.ng/umbrella/file-io/functions/writeTextAsync.html)
### Directories
- [deleteDir](https://docs.thi.ng/umbrella/file-io/functions/deleteDir.html)
- [dirs](https://docs.thi.ng/umbrella/file-io/functions/dirs.html)
- [ensureDir](https://docs.thi.ng/umbrella/file-io/functions/ensureDir.html)
- [ensureDirForFile](https://docs.thi.ng/umbrella/file-io/functions/ensureDirForFile.html)
- [isDirectory](https://docs.thi.ng/umbrella/file-io/functions/isDirectory.html)
### Logging
- [maskedPath](https://docs.thi.ng/umbrella/file-io/functions/maskedPath.html)
- [addPathMask](https://docs.thi.ng/umbrella/file-io/functions/addPathMask.html)
- [setPathMasks](https://docs.thi.ng/umbrella/file-io/functions/setPathMasks.html)
## Status
**STABLE** - used in production
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bfile-io%5D+in%3Atitle)
## Installation
```bash
yarn add @thi.ng/file-io
```
ESM import:
```ts
import * as fio from "@thi.ng/file-io";
```
For Node.js REPL:
```js
const fio = await import("@thi.ng/file-io");
```
Package sizes (brotli'd, pre-treeshake): ESM: 2.44 KB
## Dependencies
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
- [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
- [@thi.ng/hex](https://github.com/thi-ng/umbrella/tree/develop/packages/hex)
- [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
- [@thi.ng/random](https://github.com/thi-ng/umbrella/tree/develop/packages/random)
Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
## Usage examples
One project in this repo's
[/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
directory is using this package:
| Screenshot | Description | Live demo | Source |
|:---------------------------------------------------------------------------------------------------------------------|:-----------------------------------------|:----------|:---------------------------------------------------------------------------------|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/package-stats.png" width="240"/> | CLI util to visualize umbrella pkg stats | | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/package-stats) |
## API
[Generated API docs](https://docs.thi.ng/umbrella/file-io/)
TODO
## Authors
- [Karsten Schmidt](https://thi.ng)
If this project contributes to an academic publication, please cite it as:
```bibtex
@misc{thing-file-io,
title = "@thi.ng/file-io",
author = "Karsten Schmidt",
note = "https://thi.ng/file-io",
year = 2022
}
```
## License
© 2022 - 2025 Karsten Schmidt // Apache License 2.0