hazelcast-client
Version:
Hazelcast - open source In-Memory Data Grid - client for NodeJS
134 lines • 6.89 kB
JavaScript
"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 PartitionSpecificProxy_1 = require("./PartitionSpecificProxy");
var ListAddCodec_1 = require("../codec/ListAddCodec");
var ListSizeCodec_1 = require("../codec/ListSizeCodec");
var ListAddAllCodec_1 = require("../codec/ListAddAllCodec");
var ListGetAllCodec_1 = require("../codec/ListGetAllCodec");
var ListClearCodec_1 = require("../codec/ListClearCodec");
var ListContainsAllCodec_1 = require("../codec/ListContainsAllCodec");
var ListContainsCodec_1 = require("../codec/ListContainsCodec");
var ListIsEmptyCodec_1 = require("../codec/ListIsEmptyCodec");
var ListRemoveCodec_1 = require("../codec/ListRemoveCodec");
var ListCompareAndRemoveAllCodec_1 = require("../codec/ListCompareAndRemoveAllCodec");
var ListCompareAndRetainAllCodec_1 = require("../codec/ListCompareAndRetainAllCodec");
var ListAddListenerCodec_1 = require("../codec/ListAddListenerCodec");
var ListAddWithIndexCodec_1 = require("../codec/ListAddWithIndexCodec");
var ListRemoveListenerCodec_1 = require("../codec/ListRemoveListenerCodec");
var ListRemoveWithIndexCodec_1 = require("../codec/ListRemoveWithIndexCodec");
var ListGetCodec_1 = require("../codec/ListGetCodec");
var ListIndexOfCodec_1 = require("../codec/ListIndexOfCodec");
var ListSubCodec_1 = require("../codec/ListSubCodec");
var ListAddAllWithIndexCodec_1 = require("../codec/ListAddAllWithIndexCodec");
var ListSetCodec_1 = require("../codec/ListSetCodec");
var ListLastIndexOfCodec_1 = require("../codec/ListLastIndexOfCodec");
var ListProxy = (function (_super) {
__extends(ListProxy, _super);
function ListProxy() {
return _super !== null && _super.apply(this, arguments) || this;
}
ListProxy.prototype.add = function (element) {
return this.encodeInvoke(ListAddCodec_1.ListAddCodec, this.toData(element));
};
ListProxy.prototype.addAll = function (elements) {
return this.encodeInvoke(ListAddAllCodec_1.ListAddAllCodec, this.serializeList(elements));
};
ListProxy.prototype.addAllAt = function (index, elements) {
return this.encodeInvoke(ListAddAllWithIndexCodec_1.ListAddAllWithIndexCodec, index, this.serializeList(elements));
};
ListProxy.prototype.addAt = function (index, element) {
return this.encodeInvoke(ListAddWithIndexCodec_1.ListAddWithIndexCodec, index, this.toData(element));
};
ListProxy.prototype.clear = function () {
return this.encodeInvoke(ListClearCodec_1.ListClearCodec);
};
ListProxy.prototype.contains = function (entry) {
return this.encodeInvoke(ListContainsCodec_1.ListContainsCodec, this.toData(entry));
};
ListProxy.prototype.containsAll = function (elements) {
return this.encodeInvoke(ListContainsAllCodec_1.ListContainsAllCodec, this.serializeList(elements));
};
ListProxy.prototype.isEmpty = function () {
return this.encodeInvoke(ListIsEmptyCodec_1.ListIsEmptyCodec);
};
ListProxy.prototype.remove = function (entry) {
return this.encodeInvoke(ListRemoveCodec_1.ListRemoveCodec, this.toData(entry));
};
ListProxy.prototype.removeAll = function (elements) {
return this.encodeInvoke(ListCompareAndRemoveAllCodec_1.ListCompareAndRemoveAllCodec, this.serializeList(elements));
};
ListProxy.prototype.retainAll = function (elements) {
return this.encodeInvoke(ListCompareAndRetainAllCodec_1.ListCompareAndRetainAllCodec, this.serializeList(elements));
};
ListProxy.prototype.removeAt = function (index) {
return this.encodeInvoke(ListRemoveWithIndexCodec_1.ListRemoveWithIndexCodec, index);
};
ListProxy.prototype.get = function (index) {
return this.encodeInvoke(ListGetCodec_1.ListGetCodec, index);
};
ListProxy.prototype.set = function (index, element) {
return this.encodeInvoke(ListSetCodec_1.ListSetCodec, index, this.toData(element));
};
ListProxy.prototype.indexOf = function (element) {
return this.encodeInvoke(ListIndexOfCodec_1.ListIndexOfCodec, this.toData(element));
};
ListProxy.prototype.lastIndexOf = function (element) {
return this.encodeInvoke(ListLastIndexOfCodec_1.ListLastIndexOfCodec, this.toData(element));
};
ListProxy.prototype.size = function () {
return this.encodeInvoke(ListSizeCodec_1.ListSizeCodec);
};
ListProxy.prototype.subList = function (start, end) {
var _this = this;
return this.encodeInvoke(ListSubCodec_1.ListSubCodec, start, end).then(function (encoded) {
return encoded.map(function (item) {
return _this.toObject(item);
});
});
};
ListProxy.prototype.toArray = function () {
var _this = this;
return this.encodeInvoke(ListGetAllCodec_1.ListGetAllCodec)
.then(function (elements) {
return elements.map(function (element) {
return _this.toObject(element);
});
});
};
ListProxy.prototype.addItemListener = function (listener, includeValue) {
var _this = this;
var request = ListAddListenerCodec_1.ListAddListenerCodec.encodeRequest(this.name, includeValue, false);
var handler = function (message) {
ListAddListenerCodec_1.ListAddListenerCodec.handle(message, function (element, uuid, eventType) {
var responseObject = element ? _this.toObject(element) : null;
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, ListAddListenerCodec_1.ListAddListenerCodec.decodeResponse, this.name);
};
ListProxy.prototype.removeItemListener = function (registrationId) {
return this.client.getListenerService().deregisterListener(ListRemoveListenerCodec_1.ListRemoveListenerCodec.encodeRequest(this.name, registrationId), ListRemoveListenerCodec_1.ListRemoveListenerCodec.decodeResponse);
};
ListProxy.prototype.serializeList = function (input) {
var _this = this;
return input.map(function (each) {
return _this.toData(each);
});
};
return ListProxy;
}(PartitionSpecificProxy_1.PartitionSpecificProxy));
exports.ListProxy = ListProxy;
//# sourceMappingURL=ListProxy.js.map