UNPKG

hazelcast-client

Version:

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

79 lines 4.12 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 PartitionSpecificProxy_1 = require("./PartitionSpecificProxy"); var OverflowPolicy_1 = require("../core/OverflowPolicy"); var RingbufferAddCodec_1 = require("../codec/RingbufferAddCodec"); var RingbufferReadOneCodec_1 = require("../codec/RingbufferReadOneCodec"); var RingbufferAddAllCodec_1 = require("../codec/RingbufferAddAllCodec"); var RingbufferTailSequenceCodec_1 = require("../codec/RingbufferTailSequenceCodec"); var RingbufferHeadSequenceCodec_1 = require("../codec/RingbufferHeadSequenceCodec"); var RingbufferRemainingCapacityCodec_1 = require("../codec/RingbufferRemainingCapacityCodec"); var RingbufferSizeCodec_1 = require("../codec/RingbufferSizeCodec"); var RingbufferCapacityCodec_1 = require("../codec/RingbufferCapacityCodec"); var RingbufferReadManyCodec_1 = require("../codec/RingbufferReadManyCodec"); var Long = require("long"); var RingbufferProxy = (function (_super) { __extends(RingbufferProxy, _super); function RingbufferProxy() { return _super !== null && _super.apply(this, arguments) || this; } RingbufferProxy.prototype.capacity = function () { return this.encodeInvoke(RingbufferCapacityCodec_1.RingbufferCapacityCodec); }; RingbufferProxy.prototype.size = function () { return this.encodeInvoke(RingbufferSizeCodec_1.RingbufferSizeCodec); }; RingbufferProxy.prototype.tailSequence = function () { return this.encodeInvoke(RingbufferTailSequenceCodec_1.RingbufferTailSequenceCodec); }; RingbufferProxy.prototype.headSequence = function () { return this.encodeInvoke(RingbufferHeadSequenceCodec_1.RingbufferHeadSequenceCodec); }; RingbufferProxy.prototype.remainingCapacity = function () { return this.encodeInvoke(RingbufferRemainingCapacityCodec_1.RingbufferRemainingCapacityCodec); }; RingbufferProxy.prototype.add = function (item, overflowPolicy) { if (overflowPolicy === void 0) { overflowPolicy = OverflowPolicy_1.OverflowPolicy.OVERWRITE; } return this.encodeInvoke(RingbufferAddCodec_1.RingbufferAddCodec, overflowPolicy, this.toData(item)); }; RingbufferProxy.prototype.addAll = function (items, overflowPolicy) { var _this = this; if (overflowPolicy === void 0) { overflowPolicy = OverflowPolicy_1.OverflowPolicy.OVERWRITE; } var dataList = items.map(function (item) { return _this.toData(item); }); return this.encodeInvoke(RingbufferAddAllCodec_1.RingbufferAddAllCodec, dataList, overflowPolicy); }; RingbufferProxy.prototype.readOne = function (sequence) { if (Long.fromValue(sequence).lessThan(0)) { throw new Error('Sequence number should not be less than zero, was: ' + sequence); } return this.encodeInvoke(RingbufferReadOneCodec_1.RingbufferReadOneCodec, sequence); }; RingbufferProxy.prototype.readMany = function (sequence, minCount, maxCount) { var _this = this; if (Long.fromValue(sequence).lessThan(0)) { throw new Error('Sequence number should not be less than zero, was: ' + sequence); } if (minCount < 0) { throw new Error('Min count should not be less than zero, was: ' + sequence); } if (minCount > maxCount) { throw new Error('Min count ' + minCount + 'was larger than max count ' + maxCount); } return this .encodeInvoke(RingbufferReadManyCodec_1.RingbufferReadManyCodec, sequence, minCount, maxCount, null) .then(function (raw) { return raw['items'].map(function (r) { return _this.toObject(r); }); }); }; return RingbufferProxy; }(PartitionSpecificProxy_1.PartitionSpecificProxy)); exports.RingbufferProxy = RingbufferProxy; //# sourceMappingURL=RingbufferProxy.js.map