perry-mitchell / webdav-fs

Node fs wrapper for WebDAV
MIT License
94 stars 21 forks source link

have functions return promises #64

Closed tansaku closed 5 years ago

tansaku commented 5 years ago

apologies if there's an obvious work around for this, but I notice all the functions are using promises internally, but are expecting callbacks.

Would it make sense to make the callbacks optional and have all the functions return promises to make chaining easier?

tansaku commented 5 years ago

But perhaps the following would work without having to modify the existing code?

let mkdirPromise = new Promise((resolve, reject) => {
  webDavClient.mkdir('/temp' function(error){
    if(error){
      reject(error.message)
    else {
       resolve('Successfully created directory')
     }
    }
  })
});
perry-mitchell commented 5 years ago

Hi @tansaku - You're probably looking for this library (also made by me). webdav-fs actually uses that library internally, and it returns promises. webdav-fs is designed to wrap it in an fs-like adapter.

I'll close this issue for now but we reopen if you feel that there's something else.