read-chunk
Read a chunk from a file
Last updated 9 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install read-chunk 
SYNC missed versions from official npm registry.

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<Buffer> with the read chunk.

readChunkSync(filePath, {length, startPosition})

Returns a Buffer with the read chunk.

filePath

Type: string

length

Type: number

The number of bytes to read.

startPosition

Type: number

The poosition to start reading from.

Current Tags

  • 5.0.0                                ...           latest (5 months ago)

13 Versions

  • 5.0.0                                ...           5 months ago
  • 4.0.3                                ...           2 years ago
  • 4.0.2                                ...           3 years ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.2.0                                ...           6 years ago
  • 3.1.0                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.0                                ...           9 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 12
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE