read-chunk

Read a chunk from a file

MIT 13 个版本
安装
npm install read-chunk
yarn add read-chunk
pnpm add read-chunk
bun add read-chunk
README

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.

版本列表
5.0.0 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