Skip to content
Read a chunk from a file
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Add TypeScript definition (#13) Mar 6, 2019
.editorconfig
.gitattributes
.gitignore Meta tweaks Jul 30, 2017
.npmrc Meta tweaks Jul 30, 2017
.travis.yml
index.d.ts Refactor TypeScript definition to CommonJS compatible export (#15) Mar 31, 2019
index.js Refactor TypeScript definition to CommonJS compatible export (#15) Mar 31, 2019
index.test-d.ts Refactor TypeScript definition to CommonJS compatible export (#15) Mar 31, 2019
license
package.json 3.2.0 Mar 31, 2019
readme.md Meta tweaks Mar 6, 2019

readme.md

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

You can’t perform that action at this time.