typescript-dotnet-core
Version:
A the core classes and utilities of a JavaScript-Friendly .NET Based TypeScript Library.
7 lines (6 loc) • 1.96 kB
JavaScript
"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"),Compare_1=require("../../Compare"),DictionaryBase_1=require("./DictionaryBase"),VOID0=void 0,StringKeyDictionary=function(r){function t(){var t=null!==r&&r.apply(this,arguments)||this;return t._count=0,t._map={},t}return tslib_1.__extends(t,r),t.prototype._onDispose=function(){r.prototype._onDispose.call(this),this._map=null},t.prototype._getEntry=function(t){return this.containsKey(t)?{key:t,value:this.getAssuredValue(t)}:VOID0},t.prototype.containsKey=function(t){return null!=t&&0!=this._count&&this._map[t]!==VOID0},t.prototype.containsValue=function(t){if(!this._count)return!1;var r=this._map;for(var e in r)if(r.hasOwnProperty(e)&&Compare_1.areEqual(r[e],t))return!0;return!1},t.prototype.getValue=function(t){return null!=t&&this._count?this._map[t]:VOID0},t.prototype._setValueInternal=function(t,r){var e=this,n=e._map;return n[t]!==r&&(r===VOID0?t in n&&(delete n[t],e._count--):(n.hasOwnProperty(t)||e._count++,n[t]=r),!0)},t.prototype.importMap=function(e){var n=this;return n.handleUpdate(function(){var t=!1;for(var r in e)e.hasOwnProperty(r)&&n.setValue(r,e[r])&&(t=!0);return t})},t.prototype.toMap=function(t){var r=this,e={};if(r._count)for(var n in r._map)if(r._map.hasOwnProperty(n)){var o=r._map[n];t&&(o=t(n,o)),o!==VOID0&&(e[n]=o)}return e},t.prototype.getKeys=function(){return Object.keys(this._map)},t.prototype.getValues=function(){if(!this._count)return[];for(var t=Object.keys(this._map),r=0,e=t.length;r<e;r++)t[r]=this._map[t[r]];return t},t.prototype.getCount=function(){return this._count},t}(DictionaryBase_1.default);exports.StringKeyDictionary=StringKeyDictionary,exports.default=StringKeyDictionary;
//# sourceMappingURL=StringKeyDictionary.js.map