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

bufferfromfile

Package Overview
Dependencies
Maintainers
1
Versions
354
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufferfromfile

The module in JavaScript provides convenient means for using files as standard ArrayBuffer making mmap behind the scene.

  • 0.4.336
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18
increased by28.57%
Maintainers
1
Weekly downloads
 
Created
Source

module::BufferFromFile status stable

Native module for Nodejs providing convenient means for using files as standard ArrayBuffer making mmap behind the scene. BufferFromFile uses mmap to map file from hard drive to memory returning ArrayBuffer or TypedBuffer which can be manipulated just like ordinary buffer. mmap() creates a new mapping in the virtual address space of the calling process. During mmap operation all performance issues addressed operation system, so it's nearly fastest way to get data from / store on hard drive in Java Script. This method of data access do zero copy, unlike others. Just like native version of the routine BufferFromFile accept ( protection ), ( flags ), ( offset ), ( size ) and even ( advise ) parameters each of which has default value so no need to pass the implicitly.

BufferFromFIle works on Windows, OSX, Linux and other Unix-like systems. The module doesn't depend of module nan and does not support deprecated versions of Nodejs ( under v10 ). The module can convert a file to standard ArrayBuffer or any kind of TypedBuffer. Nonstandard Nodejs Buffer is supported also.

Try out from the repository

git clone https://github.com/Wandalen/BufferFromFile
cd BufferFromFile
npm install
node sample/trivial/Sample.s

To add to your project

npm add bufferfromfile@alpha

Sample


var buffer = BufferFromFile( filePath ).Uint8Array();

// let's edit the first byte

buffer[ 0 ] = 48 + Math.round( Math.random()*9 );

// print the buffer

console.log( 'buffer.length :', buffer.length );
console.log( 'buffer.toString :', buffer.toString() );

// unmap file

BufferFromFile.unmap( buffer );

Keywords

FAQs

Package last updated on 05 Aug 2021

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