# node-read-file-helper

> Helpers to read file from disk as text, JSON and other formats

Latest version **1.0.2** (published 2021-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-read-file-helper
pnpm add node-read-file-helper
yarn add node-read-file-helper
bun add node-read-file-helper
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-08-13 |
| First published | 2021-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alberto Rico |
| Maintainers | alrico88 |

## Links

- npm: https://www.npmjs.com/package/node-read-file-helper
- Repository: https://github.com/alrico88/node-read-file-helper
- Homepage: https://github.com/alrico88/node-read-file-helper#readme
- Issues: https://github.com/alrico88/node-read-file-helper/issues
- npm.io page: https://npm.io/package/node-read-file-helper

## Recent versions

- 1.0.2 (latest) — 2021-08-13
- 1.0.1 — 2021-08-13
- 1.0.0 — 2021-08-13

## README

# node-read-file-helper

Helper functions to read files as text, JSON, and additional formats.

## Installation

`npm i node-read-file-helper`

## Usage

```javascript
const { readFileAsTextSync } = require('node-read-file-helper');
const path = require('path');

const asString = readFileAsTextSync(path.resolve('./myFile.txt'));
```

## Table of contents

### Functions

- [readFileAsJSON](#readfileasjson)
- [readFileAsJSONSync](#readfileasjsonsync)
- [readFileAsText](#readfileastext)
- [readFileAsTextSync](#readfileastextsync)

## Functions

### readFileAsJSON

▸ **readFileAsJSON**<`T`\>(`path`): `Promise`<`T`\>

Reads the file as JSON content asynchronously

**`export`**

#### Type parameters

| Name | Description                      |
| :--- | :------------------------------- |
| `T`  | The JSON structure after parsing |

#### Parameters

| Name   | Type     | Description                  |
| :----- | :------- | :--------------------------- |
| `path` | `string` | The path to the file to read |

#### Returns

`Promise`<`T`\>

Promise that will resolve to the parsed JSON

#### Defined in

index.ts:61

---

### readFileAsJSONSync

▸ **readFileAsJSONSync**<`T`\>(`path`): `T`

Reads the file as JSON content

**`export`**

#### Type parameters

| Name | Description                      |
| :--- | :------------------------------- |
| `T`  | The JSON structure after parsing |

#### Parameters

| Name   | Type     | Description                  |
| :----- | :------- | :--------------------------- |
| `path` | `string` | The path to the file to read |

#### Returns

`T`

The parsed JSON

#### Defined in

index.ts:49

---

### readFileAsText

▸ **readFileAsText**(`path`): `Promise`<`string`\>

Reads file as text asynchronously

**`export`**

#### Parameters

| Name   | Type     | Description                  |
| :----- | :------- | :--------------------------- |
| `path` | `string` | The path to the file to read |

#### Returns

`Promise`<`string`\>

The file contents

#### Defined in

index.ts:23

---

### readFileAsTextSync

▸ **readFileAsTextSync**(`path`): `string`

Reads a file as text

**`export`**

#### Parameters

| Name   | Type     | Description                  |
| :----- | :------- | :--------------------------- |
| `path` | `string` | The path to the file to read |

#### Returns

`string`

The file contents as text

#### Defined in

index.ts:10

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