asyncwriteprotect

0.0.3 • Public • Published

USAGE:

const asyncManager = require("asyncwriteprotect");
var fileWriter = new asyncManager();
var fpath = "./test.txt";
fileWriter.writeFile(fpath, "test1", function(r){
	console.log(r);
});
fileWriter.writeFile(fpath, "test2", function(r){
	console.log(r);
});
fileWriter.writeFile(fpath, "test3", function(r){
	console.log(r);
});
fileWriter.writeFile(fpath, "test4", function(r){
	console.log(r);
});
fileWriter.writeFile(fpath, "test5", function(r){
	console.log(r);
});
fileWriter.writeFile(fpath, "test6", function(r){
	console.log(r);
});

You can run these commands without worry of data corruption. The engine will queue up the async commands behind the scenes, so the writes will still run in a sync order. However, the backend is still async and doesn't pause while one is writing, so your code won't hang like calling all in a sync order.

Readme

Keywords

Package Sidebar

Install

npm i asyncwriteprotect

Weekly Downloads

1

Version

0.0.3

License

none

Unpacked Size

2.85 kB

Total Files

3

Last publish

Collaborators

  • tnetworkfoundation