all files / document-editor/base/ dictionary.js

100% Statements 59/59
100% Branches 28/28
100% Functions 13/13
100% Lines 59/59
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102   423044× 423044×     61965×           290665×                   1123791×   1123790× 1123790× 1123473× 1123473×   1123790×   35122513×   35122511× 35122511× 242869×     34879642×     754×   753× 753×     752×     789×   788× 788×     787× 787× 787×     75414225×   75414224× 75414224× 41205855×   34208369×   329724× 329724×   293078× 293078× 293078×        
define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Dictionary = (function () {
        function Dictionary() {
            this.keysInternal = [];
            this.valuesInternal = [];
        }
        Object.defineProperty(Dictionary.prototype, "length", {
            get: function () {
                return this.keysInternal.length;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Dictionary.prototype, "keys", {
            get: function () {
                return this.keysInternal;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Dictionary.prototype, "values", {
            get: function () {
                return this.valuesInternal;
            },
            enumerable: true,
            configurable: true
        });
        Dictionary.prototype.add = function (key, value) {
            if (ej2_base_1.isNullOrUndefined(key)) {
                throw new ReferenceError('Provided key or value is not valid.');
            }
            var index = this.keysInternal.indexOf(key);
            if (index < 0) {
                this.keysInternal.push(key);
                this.valuesInternal.push(value);
            }
            return 1;
        };
        Dictionary.prototype.get = function (key) {
            if (ej2_base_1.isNullOrUndefined(key)) {
                throw new ReferenceError('Provided key is not valid.');
            }
            var index = this.keysInternal.indexOf(key);
            if (index < 0 || index > this.keysInternal.length - 1) {
                return undefined;
            }
            else {
                return this.valuesInternal[index];
            }
        };
        Dictionary.prototype.set = function (key, value) {
            if (ej2_base_1.isNullOrUndefined(key)) {
                throw new ReferenceError('Provided key is not valid.');
            }
            var index = this.keysInternal.indexOf(key);
            if (index < 0 || index > this.keysInternal.length - 1) {
                throw new RangeError('No item with the specified key has been added.');
            }
            else {
                this.valuesInternal[index] = value;
            }
        };
        Dictionary.prototype.remove = function (key) {
            if (ej2_base_1.isNullOrUndefined(key)) {
                throw new ReferenceError('Provided key is not valid.');
            }
            var index = this.keysInternal.indexOf(key);
            if (index < 0 || index > this.keysInternal.length - 1) {
                throw new RangeError('No item with the specified key has been added.');
            }
            else {
                this.keysInternal.splice(index, 1);
                this.valuesInternal.splice(index, 1);
                return true;
            }
        };
        Dictionary.prototype.containsKey = function (key) {
            if (ej2_base_1.isNullOrUndefined(key)) {
                throw new ReferenceError('Provided key is not valid.');
            }
            var index = this.keysInternal.indexOf(key);
            if (index < 0 || index > this.keysInternal.length - 1) {
                return false;
            }
            return true;
        };
        Dictionary.prototype.clear = function () {
            this.keysInternal = [];
            this.valuesInternal = [];
        };
        Dictionary.prototype.destroy = function () {
            this.clear();
            this.keysInternal = undefined;
            this.valuesInternal = undefined;
        };
        return Dictionary;
    }());
    exports.Dictionary = Dictionary;
});