# load-text-file

> [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom), uses [`graceful-fs`](https://github.com/isaacs/node-graceful-fs), and returns Promises.

Latest version **2.0.0** (published 2021-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install load-text-file
pnpm add load-text-file
yarn add load-text-file
bun add load-text-file
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-08-21 |
| First published | 2018-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 2 |
| Unpacked size | 2.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | linusu |
| Keywords | file, fs, graceful, load, parse, read, text |

## Links

- npm: https://www.npmjs.com/package/load-text-file
- Repository: https://github.com/LinusU/load-text-file
- Homepage: https://github.com/LinusU/load-text-file#readme
- Issues: https://github.com/LinusU/load-text-file/issues
- npm.io page: https://npm.io/package/load-text-file

## Dependencies (2)

- [strip-bom](https://npm.io/package/strip-bom.md) ^5.0.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.8

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2021-08-21
- 1.2.0 — 2019-02-13
- 1.1.0 — 2018-08-07
- 1.0.0 — 2018-08-07

## README

# load-text-file

[Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom), uses [`graceful-fs`](https://github.com/isaacs/node-graceful-fs), and returns Promises.

## Install

```sh
npm install --save load-text-file
```

## Usage

```js
import { loadTextFile } from 'load-text-file'

const text = await loadTextFile('foo.txt')
console.log(text)
//=> Hello, World!
```

### Sync

```js
import { loadTextFileSync } from 'load-text-file'

const text = loadTextFileSync('foo.txt')
console.log(text)
//=> Hello, World!
```

## API

### `loadTextFile(path)`

- `path` (`string | Buffer | URL`, required)
- returns `Promise<string>` - a promise for the text content

### `loadTextFileSync(path)`

- `path` (`string | Buffer | URL`, required)
- returns `string` - the text content

## Related

- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file

---
_Source: https://npm.io/package/load-text-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
