# read-chunk

> Read a chunk from a file

Latest version **5.0.0** (published 2024-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install read-chunk
pnpm add read-chunk
yarn add read-chunk
bun add read-chunk
```

## 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 | 5.0.0 |
| Published | 2024-06-28 |
| First published | 2014-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 125 |
| Author | Sindre Sorhus |
| Keywords | read, file, readfile, fs, chunk, slice, part, head, tail, buffer, fd, open |

## Links

- npm: https://www.npmjs.com/package/read-chunk
- Repository: https://github.com/sindresorhus/read-chunk
- Homepage: https://github.com/sindresorhus/read-chunk#readme
- Issues: https://github.com/sindresorhus/read-chunk/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/read-chunk

## 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

- 5.0.0 (latest) — 2024-06-28
- 4.0.3 — 2022-08-28
- 4.0.2 — 2021-09-02
- 4.0.1 — 2021-09-01
- 4.0.0 — 2021-08-09
- 3.2.0 — 2019-03-31
- 3.1.0 — 2019-03-06
- 3.0.0 — 2018-08-26
- 2.1.0 — 2017-07-30
- 2.0.0 — 2016-04-21
- 1.0.1 — 2015-01-17
- 1.0.0 — 2014-08-13
- 0.1.0 — 2014-01-19

## README

# read-chunk

> Read a chunk from a file

Because the built-in way requires way too much boilerplate.

## Install

```sh
npm install read-chunk
```

## Usage

```js
import {readChunk} from 'read-chunk';

// foo.txt => hello

await readChunk('foo.txt', {length: 3, startPosition: 1});
//=> 'ell'
```

## API

### readChunk(filePath, {length, startPosition})

Returns a `Promise<Uint8Array>` with the read chunk.

### readChunkSync(filePath, {length, startPosition})

Returns a `Uint8Array` with the read chunk.

#### filePath

Type: `string`

#### length

Type: `number`

The number of bytes to read.

#### startPosition

Type: `number`

The position to start reading from.

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