https://github.com/drpaulbrewer/after-operation
Convert Google Compute Engine [tm] operation event-emitters to Promises
https://github.com/drpaulbrewer/after-operation
google-compute-engine operation promise-wrapper
Last synced: 3 months ago
JSON representation
Convert Google Compute Engine [tm] operation event-emitters to Promises
- Host: GitHub
- URL: https://github.com/drpaulbrewer/after-operation
- Owner: DrPaulBrewer
- Created: 2017-04-22T11:47:57.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T08:57:17.000Z (about 5 years ago)
- Last Synced: 2025-01-29T13:08:39.650Z (5 months ago)
- Topics: google-compute-engine, operation, promise-wrapper
- Language: JavaScript
- Size: 241 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# after-operation
[](https://greenkeeper.io/)
[](https://travis-ci.org/DrPaulBrewer/after-operation)
[](https://coveralls.io/github/DrPaulBrewer/after-operation?branch=master)Helper for converting Google Compute Engine [tm] operation event-emitters to Promises
## Deprecation Notice
Oct. 2019: Since GCE operations support `operation.promise()` you should probably use that instead.
## Installation
npm i after-operation -S
## Initialization
const after = require('after-operation');
## Usage
Promise to return a value after an operation completes:
// some @google-cloud/compute method returns an operation
after(operation, onSuccessValue)
.then( (v)=>(assert.equal(v, onSuccessValue)) )
.catch(logTheOperationErrors)Promise to call a function after the operation completes:
after(operation, (meta)=>(meta) )
.then(doSomethingUseful)
.catch(logTheOperationErrors)Note that the success function gets fed with the metadata emitted in the operation 'complete' event.
By using the identity function as the success function, the promise will resolve to that metadata.
Note: after-operation will remove all operation listeners on either operation complete or operation error.
## Related modules by other authors
[npm: event-to-promise](https://www.npmjs.com/package/event-to-promise) might be useful
with other eventEmitters.## Copyright
2017 Paul Brewer - Economic and Financial Technology Consulting LLC
## License
The MIT License
### Trademarks
Google Compute Engine [tm] is a trademark of Google, Inc.
This software is not a product of Google, Inc.