read-chunk
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

read-chunk

Read a chunk from a file

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

Install

npm install read-chunk

Usage

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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.0.08,529latest

Version History

VersionDownloads (Last 7 Days)Published
5.0.08,529
4.0.34,763
4.0.2406
4.0.14
4.0.0165
3.2.0508,423
3.1.0798
3.0.0408
2.1.072,576
2.0.0262
1.0.1119,290
1.0.02
0.1.0380

Package Sidebar

Install

npm i read-chunk

Weekly Downloads

589,725

Version

5.0.0

License

MIT

Unpacked Size

4.43 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus