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

batching-fs-writestream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batching-fs-writestream

writes files faster by writing data to disk in chunks rather then one syscall for each call to write as in `fs.createWriteStream` except buffers chunks of data while other writes are pending to batch them to dis

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

batching-fs-writestream

writes files faster by writing data to disk in chunks rather then one syscall for each call to write as in fs.createWriteStream except buffers chunks of data while other writes are pending to batch them to disk

EXAMPLE

var batching = require('batching-fs-writestream')

var ws = batching('./test.log') 

var start = Date.now();

ws.on('finish',function(){
  var end = Date,now()

  console.log('took ',end-start,'ms')

})


for(var i=0;++i;i<10000){
  ws.write(Math.random()+"\n")
}

ws.end();

its more than 50% faster in most cases where you have many small writes.

$ node without.js 
took  155 ms
$ node exmaple.js 
took  45 ms

the only change is using this buffered write stream instead of the stock f.createWriteStream

api

module.exorts(file,options)

  • file the file name

  • options

    • flags
    • highWaterMark, default 10000. how much to buffer before pausing
    • pending, default 2. how many pending calls to fs.write should be active concurrently

if options is a string is is passed in as flags to fs.createWriteStream "a+"

Keywords

FAQs

Package last updated on 20 Aug 2015

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