promisify-node icon indicating copy to clipboard operation
promisify-node copied to clipboard

`fs.write()` has two signatures, so it's broken with promisify-node

Open slikts opened this issue 9 years ago • 0 comments

From the docs:

fs.write(fd, buffer, offset, length[, position], callback)
fs.write(fd, data[, position[, encoding]], callback)

By default the method signature is this:

function (fd, buffer, offset, length, position, callback)

The parameters can change depending on the input:

if (buffer instanceof Buffer) {
    // if no position is passed then assume null
    if (typeof position === 'function') {
      callback = position;
      position = null;
    }

The tls.connect() method also has two different signatures.

slikts avatar May 25 '16 19:05 slikts