2.0.0 • Published 1 year ago

synquer v2.0.0

Weekly downloads
27
License
MIT
Repository
github
Last release
1 year ago

Branches Functions Lines Statements Jest coverage

Node documentation says:

It is unsafe to use fs.write() multiple times on the same file without waiting for the callback.
https://nodejs.org/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback

Synquer can be used for sync write calls to the same file. But Synquer can be used for sync any promises not only write calls.

How install:

npm install synquer

Example

const fs = require('fs');
const util = require('util');
const writeAsync = util.promisify(fs.write);


//Wait Queue
const { Synquer } = require('synquer');
//import Synquer from 'synquer';

const write_queue = new Synquer();

async function write(){
    //write in order
    return write_queue.execute(()=> writeAsync(...arguments)); 
}

//now all writes will be queued
await Promise.all([
    write(fd, buffer, offset, length, position),
    write(fd, other_buffer, offset, length, position),
    write(fd, buffer, offset, other_length, other_position)
]);
2.0.0

1 year ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago