UNPKG

non-resizable-array

Version:
92 lines (72 loc) 2.05 kB
"use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); Object.defineProperty(exports, "__esModule", { value: true }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @class NonResizableArray */ var NonResizableArray = function () { /** * @constructs NonResizableArray */ function NonResizableArray() { _classCallCheck(this, NonResizableArray); this._array = []; this.length = 0; } /** * @method peek * @public * @param {uint} index * @returns {any} */ _createClass(NonResizableArray, [{ key: "peek", value: function peek(index) { return this._array[index]; } /** * @method push * @public * @param {any} value */ }, { key: "push", value: function push(value) { this._array[this.length++] = value; } /** * @method pop * @public * @returns {any} */ }, { key: "pop", value: function pop() { return this._array[--this.length]; } /** * @method clear * @public */ }, { key: "clear", value: function clear() { var diff = this._array.length - this.length; this._array.length -= diff; } /** * @method dispose * @public */ }, { key: "dispose", value: function dispose() { this._array = null; } }]); return NonResizableArray; }(); exports.default = NonResizableArray;