UNPKG

hazelcast-client

Version:

Hazelcast - open source In-Memory Data Grid - client for NodeJS

98 lines 4.8 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var SetAddCodec_1 = require('../codec/SetAddCodec'); var SetAddAllCodec_1 = require('../codec/SetAddAllCodec'); var SetGetAllCodec_1 = require('../codec/SetGetAllCodec'); var SetClearCodec_1 = require('../codec/SetClearCodec'); var SetContainsCodec_1 = require('../codec/SetContainsCodec'); var SetContainsAllCodec_1 = require('../codec/SetContainsAllCodec'); var SetIsEmptyCodec_1 = require('../codec/SetIsEmptyCodec'); var SetRemoveCodec_1 = require('../codec/SetRemoveCodec'); var SetCompareAndRemoveAllCodec_1 = require('../codec/SetCompareAndRemoveAllCodec'); var SetCompareAndRetainAllCodec_1 = require('../codec/SetCompareAndRetainAllCodec'); var SetSizeCodec_1 = require('../codec/SetSizeCodec'); var SetAddListenerCodec_1 = require('../codec/SetAddListenerCodec'); var SetRemoveListenerCodec_1 = require('../codec/SetRemoveListenerCodec'); var PartitionSpecificProxy_1 = require('./PartitionSpecificProxy'); var SetProxy = (function (_super) { __extends(SetProxy, _super); function SetProxy() { _super.apply(this, arguments); } SetProxy.prototype.add = function (entry) { return this.encodeInvoke(SetAddCodec_1.SetAddCodec, this.toData(entry)); }; SetProxy.prototype.addAll = function (items) { return this.encodeInvoke(SetAddAllCodec_1.SetAddAllCodec, this.serializeList(items)); }; SetProxy.prototype.getAll = function () { var _this = this; return this.encodeInvoke(SetGetAllCodec_1.SetGetAllCodec) .then(function (items) { return items.map(function (item) { return _this.toObject(item); }); }); }; SetProxy.prototype.clear = function () { return this.encodeInvoke(SetClearCodec_1.SetClearCodec); }; SetProxy.prototype.contains = function (entry) { return this.encodeInvoke(SetContainsCodec_1.SetContainsCodec, this.toData(entry)); }; SetProxy.prototype.containsAll = function (items) { return this.encodeInvoke(SetContainsAllCodec_1.SetContainsAllCodec, this.serializeList(items)); }; SetProxy.prototype.isEmpty = function () { return this.encodeInvoke(SetIsEmptyCodec_1.SetIsEmptyCodec); }; SetProxy.prototype.remove = function (entry) { return this.encodeInvoke(SetRemoveCodec_1.SetRemoveCodec, this.toData(entry)); }; SetProxy.prototype.removeAll = function (items) { return this.encodeInvoke(SetCompareAndRemoveAllCodec_1.SetCompareAndRemoveAllCodec, this.serializeList(items)); }; SetProxy.prototype.retainAll = function (items) { return this.encodeInvoke(SetCompareAndRetainAllCodec_1.SetCompareAndRetainAllCodec, this.serializeList(items)); }; SetProxy.prototype.size = function () { return this.encodeInvoke(SetSizeCodec_1.SetSizeCodec); }; SetProxy.prototype.addItemListener = function (listener, includeValue) { var _this = this; if (includeValue === void 0) { includeValue = true; } var request = SetAddListenerCodec_1.SetAddListenerCodec.encodeRequest(this.name, includeValue, false); var handler = function (message) { SetAddListenerCodec_1.SetAddListenerCodec.handle(message, function (item, uuid, eventType) { var responseObject = _this.toObject(item); var listenerFunction; if (eventType === 1) { listenerFunction = listener.itemAdded; } else if (eventType === 2) { listenerFunction = listener.itemRemoved; } if (listenerFunction) { listenerFunction.call(responseObject, responseObject); } }); }; return this.client.getListenerService().registerListener(request, handler, SetAddListenerCodec_1.SetAddListenerCodec.decodeResponse, this.name); }; SetProxy.prototype.removeItemListener = function (registrationId) { return this.client.getListenerService().deregisterListener(SetRemoveListenerCodec_1.SetRemoveListenerCodec.encodeRequest(this.name, registrationId), SetRemoveListenerCodec_1.SetRemoveListenerCodec.decodeResponse); }; SetProxy.prototype.serializeList = function (input) { var _this = this; return input.map(function (each) { return _this.toData(each); }); }; return SetProxy; }(PartitionSpecificProxy_1.PartitionSpecificProxy)); exports.SetProxy = SetProxy; //# sourceMappingURL=SetProxy.js.map