Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aikoven/ice-utils
DEPRECATED A set of utilities that makes using ZeroC ICE 3.6 with JS easier
https://github.com/aikoven/ice-utils
Last synced: 3 days ago
JSON representation
DEPRECATED A set of utilities that makes using ZeroC ICE 3.6 with JS easier
- Host: GitHub
- URL: https://github.com/aikoven/ice-utils
- Owner: aikoven
- Created: 2016-12-14T05:59:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-04T10:08:24.000Z (over 6 years ago)
- Last Synced: 2024-12-08T10:48:17.358Z (26 days ago)
- Language: TypeScript
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ice Utils [![npm version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
A set of utilities that makes using ZeroC ICE 3.6 with JS easier.
## Installation
```
npm install --save ice-utils
```## API
### toPromise(icePromise: Ice.Promise): Promise
Turn Ice promise to normal one. Useful with `async`/`await` because `await`ing
Ice promises leads to infinite loops.**Example**
```js
async function fn() {
const icePromise = myPrx.someOperation();
const result = await toPromise(icePromise);
return result;
}
```### numberToLong(num: number): Ice.Long
Convert number to `Ice.Long`. Ice only provides method to convert `Ice.Long`
to number, but reverse conversion is necessary if you need to supply operation
parameter of type `long`, or implement a servant method that returns `long`.
See [JavaScript Mapping for Long Integers](https://doc.zeroc.com/display/Ice36/JavaScript+Mapping+for+Built-In+Types#JavaScriptMappingforBuilt-InTypes-JavaScriptMappingforLongIntegers).### operation(name?: string): MethodDecorator
Decorator factory for convenient operation implementation on servants.
Automatically adds `["amd"]` metadata because sync operations make little sense
in JS world.**Parameters**
* **name**: Operation name. Defaults to decorated method name.
**Example**
```js
class MyServant extends MySlices.MyServant {
@operation()
myOperation() {
return doSomeStuff()
.then(doSomeOtherStuff);
}
}
```
**Example**```js
class MyServant extends MySlices.MyServant {
@operation()
async myOperation() {
const result = await doSomeStuff();
return result;
}
}
```### handleDispatchException(handler: IceErrorHandler): RemoveIceErrorHandler
Add a hook for handling uncaught dispatch errors.
[`Ice.Warn.Dispatch`](https://doc.zeroc.com/pages/viewpage.action?pageId=16716656#Ice.Warn.*-Ice.Warn.Dispatch)
must be turned on.Default error logging is disabled if custom handler is assigned.
**Example**
```js
const removeHandler = handleDispatchException((error, context, current) => {
const {requestId, operation, id} = current;
console.error(error, {
...context,
iceRequestId: requestId,
iceOperation: operation,
iceIdentity: Ice.identityToString(id)
});
});
```[npm-image]: https://badge.fury.io/js/ice-utils.svg
[npm-url]: https://badge.fury.io/js/ice-utils
[travis-image]: https://travis-ci.org/aikoven/ice-utils.svg?branch=master
[travis-url]: https://travis-ci.org/aikoven/ice-utils