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

read-chunk Build Status

Read a chunk from a file

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

Install

$ npm install read-chunk

Usage

const readChunk = require('read-chunk');

// foo.txt => hello

readChunk.sync('foo.txt', 1, 3);
//=> 'ell'

API

readChunk(filePath, startPosition, length)

Returns a Promise<Buffer> with the read chunk.

readChunk.sync(filePath, startPosition, length)

Returns a Buffer with the read chunk.

filePath

Type: string

startPosition

Type: number

Position to start reading.

length

Type: number

Number of bytes to read.

License

MIT © Sindre Sorhus

Current Tags

  • 3.2.0                                ...           latest (a year ago)

8 Versions

  • 3.2.0                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.0                                ...           2 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 235
This Week 5,448
This Month 14,345
Last Day 2,663
Last Week 13,771
Last Month 58,179
Dependencies (2)
Dev Dependencies (5)
Dependents (292)

Copyright 2014 - 2016 © taobao.org |