read-chunk
Read a chunk from a file
Last updated 4 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm
$ cnpm 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

  • 4.0.2                                ...           latest (4 years ago)

3 Versions

  • 4.0.2                                ...           4 years ago
  • 1.0.1                                ...           11 years ago
  • 3.2.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org