fstoerkle / read-chunk

Read a chunk from a file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

read-chunk Build Status

Read a chunk from a file

Because the built-in way is too much boilerplate.

Install

$ npm install --save read-chunk

Usage

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

// foo.txt => hello

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

API

readChunk(filepath, position, length)

Returns a promise for a buffer.

readChunk.sync(filepath, position, length)

Returns a buffer.

filepath

Type: string

position

Type: number

Position to start reading.

length

Type: number

Number of bytes to read.

License

MIT © Sindre Sorhus

About

Read a chunk from a file

License:MIT License


Languages

Language:JavaScript 100.0%