Last active
February 24, 2020 02:03
-
-
Save dongseok0/9312eacc2db52e2f8846d39c08088465 to your computer and use it in GitHub Desktop.
Promisify Azure storage service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use function that Async keyword appended | |
Bluebird.promisifyAll(blobService, { | |
promisifier: (originalFunction) => function (...args) { | |
return new Promise((resolve, reject) => { | |
try { | |
originalFunction.call(this, ...args, (error, result, response) => { | |
error && reject(error); | |
resolve({result, response}); | |
}); | |
} catch (e) { | |
reject(e); | |
} | |
}); | |
} | |
}); |
Got it working - didn't know I had to put Async on the end of any functions that have been promisified e.g. tableService.retrieveEntityAsync().then(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I just can't see to get this to work!
I get the logic, but it doesn't seem to add the extra callback argument (e,r,r) on the end of each patched function so azure storage says: Required argument callback for function entityOperation is not defined.
The ES6 spread operators transpiles to ES5 fine.
Does it still work for you using the latest Bluebrid?