UNPKG

typescript-dotnet-core

Version:

A the core classes and utilities of a JavaScript-Friendly .NET Based TypeScript Library.

7 lines (6 loc) 2.05 kB
"use strict"; /*! * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET-Core/blob/master/LICENSE.md */Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),StringKeyDictionary_1=require("./StringKeyDictionary"),ArgumentOutOfRangeException_1=require("../../Exceptions/ArgumentOutOfRangeException"),Utility_1=require("../Array/Utility"),Integer_1=require("../../Integer"),VOID0=void 0,OrderedStringKeyDictionary=function(o){function e(){var e=o.call(this)||this;return e._order=[],e}return tslib_1.__extends(e,o),e.prototype.indexOfKey=function(e){var t=this._order;return t.length?t.indexOf(e,0):-1},e.prototype.getValueByIndex=function(e){Integer_1.default.assertZeroOrGreater(e);var t=this._order;if(e<t.length)return this.getAssuredValue(t[e]);throw new ArgumentOutOfRangeException_1.default("index",e)},e.prototype.setValue=function(e,t,r){var n=this,i=-1!=n.indexOfKey(e);return i||t===VOID0&&!r?i&&t===VOID0&&!r&&Utility_1.remove(n._order,e):n._order.push(e),o.prototype.setValue.call(this,e,t)},e.prototype.setByIndex=function(e,t){var r=this._order;if(e<0)throw new ArgumentOutOfRangeException_1.default("index",e,"Is less than zero.");if(e>=r.length)throw new ArgumentOutOfRangeException_1.default("index",e,"Is greater than the count.");return this.setValue(r[e],t)},e.prototype.importValues=function(r){var n=this;return n.handleUpdate(function(){for(var e=!1,t=0;t<r.length;t++)n.setByIndex(t,r[t])&&(e=!0);return e})},e.prototype.setValues=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.importValues(e)},e.prototype.removeByIndex=function(e){return this.setByIndex(e,VOID0)},e.prototype.getKeys=function(){var t=this,e=t._order;return e.length&&e.filter(function(e){return t.containsKey(e)})||[]},e}(StringKeyDictionary_1.default);exports.OrderedStringKeyDictionary=OrderedStringKeyDictionary,exports.default=OrderedStringKeyDictionary; //# sourceMappingURL=OrderedStringKeyDictionary.js.map