Skip to content

Instantly share code, notes, and snippets.

@dongseok0
Last active February 24, 2020 02:03
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongseok0/9312eacc2db52e2f8846d39c08088465 to your computer and use it in GitHub Desktop.
Save dongseok0/9312eacc2db52e2f8846d39c08088465 to your computer and use it in GitHub Desktop.
Promisify Azure storage service
// 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);
}
});
}
});
@murraybauer
Copy link

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?

@murraybauer
Copy link

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