Giter Site home page Giter Site logo

vmihdal / bufferfromfile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wandalen/bufferfromfile

0.0 2.0 0.0 711 KB

Module in JavaScript providing convenient means for using files as buffer making mmap behind the scene

License: MIT License

Makefile 0.17% Python 2.62% C++ 32.41% JavaScript 64.80%

bufferfromfile's Introduction

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 );

bufferfromfile's People

Contributors

dmvict avatar jackiejoo avatar vmihdal avatar wandalen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.