Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

block-reader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

block-reader

read specific chunks of files by offset

  • 0.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

block-reader

read specific chunks of files by offset.

``js

var blockReader = require("block-reader")

blockReader("/somefile",1024,function(err,reader,fd,stat){

reader.read(0,function(err,buf){ console.log(buf,toString(),'this is bytes 0-1023 in from somefile'); })

reader.read(5,function(err,buf){

console.log(buf,toString(),'this is bytes 4095-5119 from somefile');

})

reader.read(100,function(err,buf){ // if the offset doesnt exist you should get an error. console.log(err) })

})


in some cases i already have a file descriptor and stat so i use ```fromFD```

```js

var blockReader = require("block-reader")
var stat = ..
var fd = ..


var reader = blockReader.fromFD(fd,stat.size,1024)


reader.read(0,function(err,buf){
  console.log(buf,toString(),'this is bytes 0-1023 in from somefile');
})

you may change the size of the file but you shouldn't need to create a new reader. if you want to access those offsets the reader will need to know the new size.


fs.stat('/somefile',function(err,stat){

  reader.size(stat.size);

});

Keywords

FAQs

Package last updated on 19 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc