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

aligned-block-file

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aligned-block-file

read and write to a file in a cache-friendly way by using aligned blocks.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
128
decreased by-34.36%
Maintainers
1
Weekly downloads
 
Created
Source

aligned-block-file

read and write to a file in a cache-friendly way by using aligned blocks.

This module provides an interface to read arbitary buffers from a file, and manages it as a series of aligned buffers. This allows you to write high performance binary file formats, where many reads do not necessarily mean many fs reads.

Blocks(filename, block_size, flags) => AlignedBlockFile

create an instance, block_size is the size of the underlying block. I suggest 1024 or 4096 or some multiple of your OS block size. flags is passed to fs.open

abf.read(start, end, cb)

read a buffer from the file. If the range is already in the cache cb will be called synchronously.

abf.readUInt32BE (start, cb)

read a UInt32BE from the file. (cb may be sync, if the buffer is already in cache)

abf.size

an observable of the files size.

abf.offset

an observable of the end of the file

append (buf, cb)

append buf to the file.

this must not be called again until the previous call has returned. updated values for size and offset will be triggered immediately before the cb is called.

truncate(length, cb)

shorten the file to length removing anything after that point.

License

MIT

FAQs

Package last updated on 19 May 2017

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