diff --git a/bower.json b/bower.json index 454f599c..06f9d6ef 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "typescript-dotnet", - "version": "2.6.3", + "version": "2.6.4", "ignore": [ ".bowercc", ".gitignore", diff --git a/dist/amd/System/Collections/Dictionaries/DictionaryBase.js b/dist/amd/System/Collections/Dictionaries/DictionaryBase.js index 755c4681..a5e8d7cb 100644 --- a/dist/amd/System/Collections/Dictionaries/DictionaryBase.js +++ b/dist/amd/System/Collections/Dictionaries/DictionaryBase.js @@ -2,5 +2,5 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md */ -define(["require","exports","../../Compare","../Enumeration/EnumeratorBase","../../Exceptions/ArgumentNullException","../../Exceptions/InvalidOperationException","../../KeyValueExtract"],function(e,t,r,n,o,u,a){"use strict";var i=void 0,c=function(){function e(){this._updateRecursion=0}return Object.defineProperty(e.prototype,"isUpdating",{get:function(){return 0!=this._updateRecursion},enumerable:!0,configurable:!0}),e.prototype._onValueUpdate=function(e,t,n){if(!r.areEqual(t,n,!0)){var o=this;o.onValueChanged&&o.onValueChanged(e,t,n),0==o._updateRecursion&&o._onUpdated()}},e.prototype._onUpdated=function(){var e=this;e.onUpdated&&e.onUpdated()},e.prototype.handleUpdate=function(e){var t,r=this;if(e){r._updateRecursion++;try{t=e()}finally{r._updateRecursion--}}else t=0==r._updateRecursion;return t&&0==r._updateRecursion&&r._onUpdated(),t},Object.defineProperty(e.prototype,"isReadOnly",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this.getCount()},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this;if(!e)throw new o["default"]("item","Dictionaries must use a valid key/value pair. '"+e+"' is not allowed.");a["default"](e,function(e,r){return t.addByKeyValue(e,r)})},e.prototype.clear=function(){var e=this,t=e.keys,r=t.length;return r&&e.handleUpdate(function(){return t.forEach(function(t){e.removeByKey(t)}),!0}),0!=e.count&&console.warn("Dictionary clear() results in mismatched count."),r},e.prototype.contains=function(e){var t=this;return e?a["default"](e,function(e,n){var o=t.getValue(e);return r.areEqual(n,o)}):!1},e.prototype.copyTo=function(e,t){if(void 0===t&&(t=0),!e)throw new o["default"]("array");for(var r=this.getEnumerator();r.moveNext();)e[t++]=r.current;return e},e.prototype.toArray=function(){return this.copyTo([],0)},e.prototype.remove=function(e){var t=this;return e?a["default"](e,function(e,n){var o=t.getValue(e);return r.areEqual(n,o)&&t.removeByKey(e)?1:0}):0},Object.defineProperty(e.prototype,"keys",{get:function(){return this.getKeys()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this.getValues()},enumerable:!0,configurable:!0}),e.prototype.addByKeyValue=function(e,t){var r=this;if(r.containsKey(e)){var n=new u["default"]("Adding a key/value when the key already exists.");throw n.data.key=e,n.data.value=t,n}r.setValue(e,t)},e.prototype.containsKey=function(e){var t=this.getValue(e);return t!==i},e.prototype.containsValue=function(e){for(var t=this.getEnumerator(),n=r.areEqual;t.moveNext();)if(n(t.current,e,!0))return t.dispose(),!0;return!1},e.prototype.removeByKey=function(e){return this.setValue(e,void 0)},e.prototype.removeByValue=function(e){var t=this,n=0,o=r.areEqual;return t.keys.forEach(function(r){o(t.getValue(r),e,!0)&&(t.removeByKey(r),++n)}),n},e.prototype.importPairs=function(e){var t=this;return t.handleUpdate(function(){var r=!1;return e.forEach(function(e){return a["default"](e,function(e,n){t.setValue(e,n),r=!0})}),r})},e.prototype.getEnumerator=function(){var e,t,r=this,o=0;return new n["default"](function(){e=r.keys,t=e.length},function(n){for(;t>o;){var u=e[o++],a=r.getValue(u);if(a!==i)return n.yieldReturn({key:u,value:a})}return n.yieldBreak()})},e}();Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=c}); +define(["require","exports","../../Compare","../Enumeration/EnumeratorBase","../../Exceptions/ArgumentNullException","../../Exceptions/InvalidOperationException","../../KeyValueExtract","../Enumeration/Enumerator"],function(e,t,r,n,o,u,a,i){"use strict";var c=void 0,p=function(){function e(){this._updateRecursion=0}return Object.defineProperty(e.prototype,"isUpdating",{get:function(){return 0!=this._updateRecursion},enumerable:!0,configurable:!0}),e.prototype._onValueUpdate=function(e,t,n){if(!r.areEqual(t,n,!0)){var o=this;o.onValueChanged&&o.onValueChanged(e,t,n),0==o._updateRecursion&&o._onUpdated()}},e.prototype._onUpdated=function(){var e=this;e.onUpdated&&e.onUpdated()},e.prototype.handleUpdate=function(e){var t,r=this;if(e){r._updateRecursion++;try{t=e()}finally{r._updateRecursion--}}else t=0==r._updateRecursion;return t&&0==r._updateRecursion&&r._onUpdated(),t},Object.defineProperty(e.prototype,"isReadOnly",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this.getCount()},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this;if(!e)throw new o["default"]("item","Dictionaries must use a valid key/value pair. '"+e+"' is not allowed.");a["default"](e,function(e,r){return t.addByKeyValue(e,r)})},e.prototype.clear=function(){var e=this,t=e.keys,r=t.length;return r&&e.handleUpdate(function(){return t.forEach(function(t){e.removeByKey(t)}),!0}),0!=e.count&&console.warn("Dictionary clear() results in mismatched count."),r},e.prototype.contains=function(e){var t=this;return e?a["default"](e,function(e,n){var o=t.getValue(e);return r.areEqual(n,o)}):!1},e.prototype.copyTo=function(e,t){if(void 0===t&&(t=0),!e)throw new o["default"]("array");for(var r=this.getEnumerator();r.moveNext();)e[t++]=r.current;return e},e.prototype.toArray=function(){return this.copyTo([],0)},e.prototype.remove=function(e){var t=this;return e?a["default"](e,function(e,n){var o=t.getValue(e);return r.areEqual(n,o)&&t.removeByKey(e)?1:0}):0},Object.defineProperty(e.prototype,"keys",{get:function(){return this.getKeys()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this.getValues()},enumerable:!0,configurable:!0}),e.prototype.addByKeyValue=function(e,t){var r=this;if(r.containsKey(e)){var n=new u["default"]("Adding a key/value when the key already exists.");throw n.data.key=e,n.data.value=t,n}r.setValue(e,t)},e.prototype.containsKey=function(e){var t=this.getValue(e);return t!==c},e.prototype.containsValue=function(e){for(var t=this.getEnumerator(),n=r.areEqual;t.moveNext();)if(n(t.current,e,!0))return t.dispose(),!0;return!1},e.prototype.removeByKey=function(e){return this.setValue(e,void 0)},e.prototype.removeByValue=function(e){var t=this,n=0,o=r.areEqual;return t.keys.forEach(function(r){o(t.getValue(r),e,!0)&&(t.removeByKey(r),++n)}),n},e.prototype.importPairs=function(e){var t=this;return e?t.handleUpdate(function(){var r=!1;return i.forEach(e,function(e){return a["default"](e,function(e,n){t.setValue(e,n),r=!0})}),r}):!1},e.prototype.getEnumerator=function(){var e,t,r=this,o=0;return new n["default"](function(){e=r.keys,t=e.length},function(n){for(;t>o;){var u=e[o++],a=r.getValue(u);if(a!==c)return n.yieldReturn({key:u,value:a})}return n.yieldBreak()})},e}();Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=p}); //# sourceMappingURL=DictionaryBase.js.map diff --git a/dist/amd/System/Collections/Dictionaries/DictionaryBase.js.map b/dist/amd/System/Collections/Dictionaries/DictionaryBase.js.map index 06161699..225792d2 100644 --- a/dist/amd/System/Collections/Dictionaries/DictionaryBase.js.map +++ b/dist/amd/System/Collections/Dictionaries/DictionaryBase.js.map @@ -1 +1 @@ -{"version":3,"sources":["System/Collections/Dictionaries/DictionaryBase.js","System/Collections/Dictionaries/DictionaryBase.ts"],"names":["define","require","exports","Compare_1","EnumeratorBase_1","ArgumentNullException_1","InvalidOperationException_1","KeyValueExtract_1","VOID0","DictionaryBase","DictionaryBase.constructor","get","DictionaryBase.isUpdating","enumerable","configurable","DictionaryBase._onValueUpdate","DictionaryBase._onUpdated","DictionaryBase.handleUpdate","DictionaryBase.isReadOnly","DictionaryBase.count","DictionaryBase.add","DictionaryBase.clear","DictionaryBase.contains","DictionaryBase.copyTo","DictionaryBase.toArray","DictionaryBase.remove","DictionaryBase.keys","DictionaryBase.values","DictionaryBase.addByKeyValue","DictionaryBase.containsKey","DictionaryBase.containsValue","DictionaryBase.removeByKey","DictionaryBase.removeByValue","DictionaryBase.importPairs","DictionaryBase.getEnumerator","Object","defineProperty","value"],"mappings":";;;;AAIAA,QAAQ,UAAW,UAAW,gBAAiB,gCAAiC,yCAA0C,6CAA8C,yBAA0B,SAAUC,EAASC,EAASC,EAAWC,EAAkBC,EAAyBC,EAA6BC,GCEjT,YASA,IAAMC,GAAY,OAGlBC,EAAA,WAMCA,QAAAA,KAECC,KAAKA,iBAAmBA,EA2Q1BD,MAxQCA,QAAAA,eAAIA,EAAAA,UAAAA,cDjBOE,ICiBXF,WAA2BG,MAA8BA,IAAvBA,KAAKA,kBDhB5BC,YAAY,EACZC,cAAc,ICoBfL,EAAAA,UAAAA,eAAVA,SAAyBA,EAAUA,EAAcA,GAEhDM,IAAIA,EAAAA,SAASA,EAAOA,GAAKA,GACzBA,CAECA,GAAIA,GAAIA,IACLA,GAAEA,gBACJA,EAAEA,eAAeA,EAAKA,EAAOA,GAGPA,GAApBA,EAAEA,kBACJA,EAAEA,eASGN,EAAAA,UAAAA,WAARA,WAECO,GAAIA,GAAIA,IACLA,GAAEA,WACJA,EAAEA,aAIJP,EAAAA,UAAAA,aAAAA,SAAaA,GAEZQ,GAAcA,GAAVA,EAAIA,IACRA,IAAGA,EACHA,CACCA,EAAEA,kBAEFA,KAECA,EAASA,IDlCG,QCsCZA,EAAEA,wBAIHA,GAA6BA,GAApBA,EAAEA,gBAKZA,OAHGA,IAA8BA,GAApBA,EAAEA,kBACdA,EAAEA,aAEIA,GAMRR,OAAAA,eAAIA,EAAAA,UAAAA,cD1COE,IC0CXF,WAA2BS,OAAOA,GDzCvBL,YAAY,EACZC,cAAc,IC4CzBL,OAAAA,eAAIA,EAAAA,UAAAA,SDzCOE,ICyCXF,WAAqBU,MAAOA,MAAKA,YDxCtBN,YAAY,EACZC,cAAc,ICyCzBL,EAAAA,UAAAA,IAAAA,SAAIA,GAAJW,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,EADbA,EAAIA,KACqBA,EAAIA,CACjCA,OAAOA,IAAIA,GAAAA,WACVA,WAECA,EAAOA,EAAEA,KACTA,EAAMA,EAAKA,QAGZA,SAACA,GAEAA,KAAQA,EAAFA,GACNA,CACCA,GAAIA,GAAMA,EAAKA,KAAMA,EAAQA,EAAEA,SAASA,EACxCA,IAAGA,IAAQA,EACVA,MAAOA,GAAQA,aAAaA,IAAKA,EAAKA,MAAOA,IAG/CA,MAAOA,GAAQA,gBAMnBzB,IAGA0B,QAAAC,eAAAlC,EAAA,cAAAmC,OAAA,IDlHInC,EAAAA,WCkHWO","file":"System/Collections/Dictionaries/DictionaryBase.js","sourcesContent":["/*!\n * @author electricessence / https://github.com/electricessence/\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\n */\ndefine([\"require\", \"exports\", '../../Compare', '../Enumeration/EnumeratorBase', '../../Exceptions/ArgumentNullException', '../../Exceptions/InvalidOperationException', '../../KeyValueExtract'], function (require, exports, Compare_1, EnumeratorBase_1, ArgumentNullException_1, InvalidOperationException_1, KeyValueExtract_1) {\n 'use strict';\n var VOID0 = void (0);\n var DictionaryBase = (function () {\n function DictionaryBase() {\n this._updateRecursion = 0;\n }\n Object.defineProperty(DictionaryBase.prototype, \"isUpdating\", {\n get: function () { return this._updateRecursion != 0; },\n enumerable: true,\n configurable: true\n });\n DictionaryBase.prototype._onValueUpdate = function (key, value, old) {\n if (!Compare_1.areEqual(value, old, true)) {\n var _ = this;\n if (_.onValueChanged)\n _.onValueChanged(key, value, old);\n if (_._updateRecursion == 0)\n _._onUpdated();\n }\n };\n DictionaryBase.prototype._onUpdated = function () {\n var _ = this;\n if (_.onUpdated)\n _.onUpdated();\n };\n DictionaryBase.prototype.handleUpdate = function (closure) {\n var _ = this, result;\n if (closure) {\n _._updateRecursion++;\n try {\n result = closure();\n }\n finally {\n _._updateRecursion--;\n }\n }\n else\n result = _._updateRecursion == 0;\n if (result && _._updateRecursion == 0)\n _._onUpdated();\n return result;\n };\n Object.defineProperty(DictionaryBase.prototype, \"isReadOnly\", {\n get: function () { return false; },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(DictionaryBase.prototype, \"count\", {\n get: function () { return this.getCount(); },\n enumerable: true,\n configurable: true\n });\n DictionaryBase.prototype.add = function (item) {\n var _this = this;\n if (!item)\n throw new ArgumentNullException_1.default('item', 'Dictionaries must use a valid key/value pair. \\'' + item + '\\' is not allowed.');\n KeyValueExtract_1.default(item, function (key, value) { return _this.addByKeyValue(key, value); });\n };\n DictionaryBase.prototype.clear = function () {\n var _ = this, keys = _.keys, count = keys.length;\n if (count)\n _.handleUpdate(function () {\n keys.forEach(function (key) { _.removeByKey(key); });\n return true;\n });\n if (_.count != 0)\n console.warn(\"Dictionary clear() results in mismatched count.\");\n return count;\n };\n DictionaryBase.prototype.contains = function (item) {\n var _this = this;\n if (!item)\n return false;\n return KeyValueExtract_1.default(item, function (key, value) {\n var v = _this.getValue(key);\n return Compare_1.areEqual(value, v);\n });\n };\n DictionaryBase.prototype.copyTo = function (array, index) {\n if (index === void 0) { index = 0; }\n if (!array)\n throw new ArgumentNullException_1.default('array');\n var e = this.getEnumerator();\n while (e.moveNext()) {\n array[index++] = e.current;\n }\n return array;\n };\n DictionaryBase.prototype.toArray = function () {\n return this.copyTo([], 0);\n };\n DictionaryBase.prototype.remove = function (item) {\n var _this = this;\n if (!item)\n return 0;\n return KeyValueExtract_1.default(item, function (key, value) {\n var v = _this.getValue(key);\n return (Compare_1.areEqual(value, v) && _this.removeByKey(key))\n ? 1 : 0;\n });\n };\n Object.defineProperty(DictionaryBase.prototype, \"keys\", {\n get: function () { return this.getKeys(); },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(DictionaryBase.prototype, \"values\", {\n get: function () { return this.getValues(); },\n enumerable: true,\n configurable: true\n });\n DictionaryBase.prototype.addByKeyValue = function (key, value) {\n var _ = this;\n if (_.containsKey(key)) {\n var ex = new InvalidOperationException_1.default(\"Adding a key/value when the key already exists.\");\n ex.data['key'] = key;\n ex.data['value'] = value;\n throw ex;\n }\n _.setValue(key, value);\n };\n DictionaryBase.prototype.containsKey = function (key) {\n var value = this.getValue(key);\n return value !== VOID0;\n };\n DictionaryBase.prototype.containsValue = function (value) {\n var e = this.getEnumerator(), equal = Compare_1.areEqual;\n while (e.moveNext()) {\n if (equal(e.current, value, true)) {\n e.dispose();\n return true;\n }\n }\n return false;\n };\n DictionaryBase.prototype.removeByKey = function (key) {\n return this.setValue(key, undefined);\n };\n DictionaryBase.prototype.removeByValue = function (value) {\n var _ = this, count = 0, equal = Compare_1.areEqual;\n _.keys.forEach(function (key) {\n if (equal(_.getValue(key), value, true)) {\n _.removeByKey(key);\n ++count;\n }\n });\n return count;\n };\n DictionaryBase.prototype.importPairs = function (pairs) {\n var _ = this;\n return _.handleUpdate(function () {\n var changed = false;\n pairs.forEach(function (pair) { return KeyValueExtract_1.default(pair, function (key, value) {\n _.setValue(key, value);\n changed = true;\n }); });\n return changed;\n });\n };\n DictionaryBase.prototype.getEnumerator = function () {\n var _ = this;\n var keys, len, i = 0;\n return new EnumeratorBase_1.default(function () {\n keys = _.keys;\n len = keys.length;\n }, function (yielder) {\n while (i < len) {\n var key = keys[i++], value = _.getValue(key);\n if (value !== VOID0)\n return yielder.yieldReturn({ key: key, value: value });\n }\n return yielder.yieldBreak();\n });\n };\n return DictionaryBase;\n })();\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.default = DictionaryBase;\n});\n","/*!\r\n * @author electricessence / https://github.com/electricessence/\r\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\r\n */\r\n\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport {areEqual} from '../../Compare';\r\nimport EnumeratorBase from '../Enumeration/EnumeratorBase';\r\nimport ArgumentException from '../../Exceptions/ArgumentException';\r\nimport ArgumentNullException from '../../Exceptions/ArgumentNullException';\r\nimport InvalidOperationException from '../../Exceptions/InvalidOperationException';\r\nimport extractKeyValue from '../../KeyValueExtract';\r\n\r\nconst VOID0:any = void(0);\r\n\r\n// Design Note: Should DictionaryAbstractBase be IDisposable?\r\nabstract class DictionaryBase\r\nimplements IDictionary\r\n{\r\n\t// This allows for batch updates in order to improve the efficiency of responsive systems.\r\n\tprivate _updateRecursion:number;\r\n\r\n\tconstructor()\r\n\t{\r\n\t\tthis._updateRecursion = 0;\r\n\t}\r\n\r\n\tget isUpdating():boolean { return this._updateRecursion!=0; }\r\n\r\n\t// Could implement an event dispatcher pattern here easily...\r\n\tonValueChanged:(key:TKey, value:TValue, old:TValue) => void;\r\n\r\n\tprotected _onValueUpdate(key:TKey, value:TValue, old:TValue):void\r\n\t{\r\n\t\tif(!areEqual(value, old, true))\r\n\t\t{\r\n\r\n\t\t\tvar _ = this;\r\n\t\t\tif(_.onValueChanged)\r\n\t\t\t\t_.onValueChanged(key, value, old);\r\n\r\n\t\t\t// If the update recursion is zero, then we are finished with updates.\r\n\t\t\tif(_._updateRecursion==0)\r\n\t\t\t\t_._onUpdated();\r\n\r\n\t\t}\r\n\t}\r\n\r\n\t// Listening to every value update can get noisy. Here we allow for batch update signaling.\r\n\t// The consumer of this class can also wire up their own event system.\r\n\tonUpdated:() => void;\r\n\r\n\tprivate _onUpdated():void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.onUpdated)\r\n\t\t\t_.onUpdated();\r\n\t}\r\n\r\n\t// Takes a closure that if returning true will propagate an update signal.\r\n\thandleUpdate(closure?:() => boolean):boolean\r\n\t{\r\n\t\tvar _ = this, result:boolean;\r\n\t\tif(closure)\r\n\t\t{\r\n\t\t\t_._updateRecursion++;\r\n\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tresult = closure();\r\n\t\t\t}\r\n\t\t\tfinally\r\n\t\t\t{\r\n\t\t\t\t_._updateRecursion--;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t\tresult = _._updateRecursion==0;\r\n\r\n\t\tif(result && _._updateRecursion==0)\r\n\t\t\t_._onUpdated();\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// ICollection\r\n\t/////////////////////////////////////////\r\n\tget isReadOnly():boolean { return false; }\r\n\r\n\tprotected abstract getCount():number;\r\n\r\n\tget count():number { return this.getCount(); }\r\n\r\n\tadd(item:KeyValuePair):void\r\n\t{\r\n\t\tif(!item)\r\n\t\t\tthrow new ArgumentNullException(\r\n\t\t\t\t'item', 'Dictionaries must use a valid key/value pair. \\'' + item + '\\' is not allowed.'\r\n\t\t\t);\r\n\r\n\t\textractKeyValue(item,\r\n\t\t\t(key, value)=>this.addByKeyValue(key, value));\r\n\t}\r\n\r\n\tclear():number\r\n\t{\r\n\t\tvar _ = this, keys = _.keys, count = keys.length;\r\n\r\n\t\tif(count)\r\n\t\t\t_.handleUpdate(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\tkeys.forEach(key=> { _.removeByKey(key); });\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t);\r\n\r\n\t\tif(_.count!=0) // After they've all been removed, then should be zero.\r\n\t\t\tconsole.warn(\"Dictionary clear() results in mismatched count.\");\r\n\r\n\t\treturn count;\r\n\t}\r\n\r\n\tcontains(item:KeyValuePair):boolean\r\n\t{\r\n\t\t// Should never have a null object in the collection.\r\n\t\tif(!item) return false;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn areEqual(value, v);\r\n\t\t\t});\r\n\r\n\t}\r\n\r\n\tcopyTo(array:IKeyValuePair[], index:number = 0):IKeyValuePair[]\r\n\t{\r\n\t\tif(!array) throw new ArgumentNullException('array');\r\n\r\n\t\t// This is a generic implementation that will work for all derived classes.\r\n\t\t// It can be overridden and optimized.\r\n\t\tvar e = this.getEnumerator();\r\n\t\twhile(e.moveNext()) // Disposes when finished.\r\n\t\t{\r\n\t\t\tarray[index++] = e.current;\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\r\n\ttoArray():IKeyValuePair[]\r\n\t{\r\n\t\treturn this.copyTo([], 0);\r\n\t}\r\n\r\n\tremove(item:IKeyValuePair|[TKey,TValue]):number\r\n\t{\r\n\t\tif(!item) return 0;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn (areEqual(value, v) && this.removeByKey(key))\r\n\t\t\t\t\t? 1 : 0;\r\n\t\t\t});\r\n\r\n\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// IDictionary\r\n\t/////////////////////////////////////////\r\n\r\n\tprotected abstract getKeys():TKey[];\r\n\r\n\tget keys():TKey[] { return this.getKeys(); }\r\n\r\n\tprotected abstract getValues():TValue[];\r\n\r\n\tget values():TValue[] { return this.getValues(); }\r\n\r\n\r\n\taddByKeyValue(key:TKey, value:TValue):void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.containsKey(key))\r\n\t\t{\r\n\t\t\tvar ex = new InvalidOperationException(\"Adding a key/value when the key already exists.\");\r\n\t\t\tex.data['key'] = key;\r\n\t\t\tex.data['value'] = value;\r\n\t\t\tthrow ex;\r\n\t\t}\r\n\r\n\t\t_.setValue(key, value);\r\n\t}\r\n\r\n\tabstract getValue(key:TKey):TValue;\r\n\r\n\tabstract setValue(key:TKey, value:TValue):boolean;\r\n\r\n\tcontainsKey(key:TKey):boolean\r\n\t{\r\n\t\tvar value = this.getValue(key);\r\n\t\treturn value!==VOID0;\r\n\t}\r\n\r\n\tcontainsValue(value:TValue):boolean\r\n\t{\r\n\t\tvar e = this.getEnumerator(), equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\r\n\t\twhile(e.moveNext())\r\n\t\t{\r\n\t\t\tif(equal(e.current, value, true))\r\n\t\t\t{\r\n\t\t\t\te.dispose();\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\tremoveByKey(key:TKey):boolean\r\n\t{\r\n\t\treturn this.setValue(key, undefined);\r\n\t}\r\n\r\n\tremoveByValue(value:TValue):number\r\n\t{\r\n\t\tvar _ = this, count = 0, equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\t\t_.keys.forEach(key=>\r\n\t\t{\r\n\t\t\tif(equal(_.getValue(key), value, true))\r\n\t\t\t{\r\n\t\t\t\t_.removeByKey(key);\r\n\t\t\t\t++count;\r\n\t\t\t}\r\n\t\t});\r\n\t\treturn count;\r\n\t}\r\n\r\n\timportPairs(pairs:KeyValuePair[]):boolean\r\n\t{\r\n\t\tvar _ = this;\r\n\t\treturn _.handleUpdate(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tvar changed:boolean = false;\r\n\t\t\t\tpairs.forEach(\r\n\t\t\t\t\tpair=>extractKeyValue(pair, (key, value)=>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t\t\t\tchanged = true;\r\n\t\t\t\t\t})\r\n\t\t\t\t);\r\n\t\t\t\treturn changed;\r\n\t\t\t}\r\n\t\t);\r\n\t}\r\n\r\n\tgetEnumerator():IEnumerator>\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tvar keys:TKey[], len:number, i = 0;\r\n\t\treturn new EnumeratorBase>(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tkeys = _.keys;\r\n\t\t\t\tlen = keys.length\r\n\t\t\t},\r\n\r\n\t\t\t(yielder)=>\r\n\t\t\t{\r\n\t\t\t\twhile(i\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport {areEqual} from '../../Compare';\r\nimport EnumeratorBase from '../Enumeration/EnumeratorBase';\r\nimport ArgumentException from '../../Exceptions/ArgumentException';\r\nimport ArgumentNullException from '../../Exceptions/ArgumentNullException';\r\nimport InvalidOperationException from '../../Exceptions/InvalidOperationException';\r\nimport extractKeyValue from '../../KeyValueExtract';\r\nimport {forEach} from '../Enumeration/Enumerator';\r\n\r\nconst VOID0:any = void(0);\r\n\r\n// Design Note: Should DictionaryAbstractBase be IDisposable?\r\nabstract class DictionaryBase\r\nimplements IDictionary\r\n{\r\n\t// This allows for batch updates in order to improve the efficiency of responsive systems.\r\n\tprivate _updateRecursion:number;\r\n\r\n\tconstructor()\r\n\t{\r\n\t\tthis._updateRecursion = 0;\r\n\t}\r\n\r\n\tget isUpdating():boolean { return this._updateRecursion!=0; }\r\n\r\n\t// Could implement an event dispatcher pattern here easily...\r\n\tonValueChanged:(key:TKey, value:TValue, old:TValue) => void;\r\n\r\n\tprotected _onValueUpdate(key:TKey, value:TValue, old:TValue):void\r\n\t{\r\n\t\tif(!areEqual(value, old, true))\r\n\t\t{\r\n\r\n\t\t\tvar _ = this;\r\n\t\t\tif(_.onValueChanged)\r\n\t\t\t\t_.onValueChanged(key, value, old);\r\n\r\n\t\t\t// If the update recursion is zero, then we are finished with updates.\r\n\t\t\tif(_._updateRecursion==0)\r\n\t\t\t\t_._onUpdated();\r\n\r\n\t\t}\r\n\t}\r\n\r\n\t// Listening to every value update can get noisy. Here we allow for batch update signaling.\r\n\t// The consumer of this class can also wire up their own event system.\r\n\tonUpdated:() => void;\r\n\r\n\tprivate _onUpdated():void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.onUpdated)\r\n\t\t\t_.onUpdated();\r\n\t}\r\n\r\n\t// Takes a closure that if returning true will propagate an update signal.\r\n\thandleUpdate(closure?:() => boolean):boolean\r\n\t{\r\n\t\tvar _ = this, result:boolean;\r\n\t\tif(closure)\r\n\t\t{\r\n\t\t\t_._updateRecursion++;\r\n\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tresult = closure();\r\n\t\t\t}\r\n\t\t\tfinally\r\n\t\t\t{\r\n\t\t\t\t_._updateRecursion--;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t\tresult = _._updateRecursion==0;\r\n\r\n\t\tif(result && _._updateRecursion==0)\r\n\t\t\t_._onUpdated();\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// ICollection\r\n\t/////////////////////////////////////////\r\n\tget isReadOnly():boolean { return false; }\r\n\r\n\tprotected abstract getCount():number;\r\n\r\n\tget count():number { return this.getCount(); }\r\n\r\n\tadd(item:KeyValuePair):void\r\n\t{\r\n\t\tif(!item)\r\n\t\t\tthrow new ArgumentNullException(\r\n\t\t\t\t'item', 'Dictionaries must use a valid key/value pair. \\'' + item + '\\' is not allowed.'\r\n\t\t\t);\r\n\r\n\t\textractKeyValue(item,\r\n\t\t\t(key, value)=>this.addByKeyValue(key, value));\r\n\t}\r\n\r\n\tclear():number\r\n\t{\r\n\t\tvar _ = this, keys = _.keys, count = keys.length;\r\n\r\n\t\tif(count)\r\n\t\t\t_.handleUpdate(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\tkeys.forEach(key=> { _.removeByKey(key); });\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t);\r\n\r\n\t\tif(_.count!=0) // After they've all been removed, then should be zero.\r\n\t\t\tconsole.warn(\"Dictionary clear() results in mismatched count.\");\r\n\r\n\t\treturn count;\r\n\t}\r\n\r\n\tcontains(item:KeyValuePair):boolean\r\n\t{\r\n\t\t// Should never have a null object in the collection.\r\n\t\tif(!item) return false;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn areEqual(value, v);\r\n\t\t\t});\r\n\r\n\t}\r\n\r\n\tcopyTo(array:IKeyValuePair[], index:number = 0):IKeyValuePair[]\r\n\t{\r\n\t\tif(!array) throw new ArgumentNullException('array');\r\n\r\n\t\t// This is a generic implementation that will work for all derived classes.\r\n\t\t// It can be overridden and optimized.\r\n\t\tvar e = this.getEnumerator();\r\n\t\twhile(e.moveNext()) // Disposes when finished.\r\n\t\t{\r\n\t\t\tarray[index++] = e.current;\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\r\n\ttoArray():IKeyValuePair[]\r\n\t{\r\n\t\treturn this.copyTo([], 0);\r\n\t}\r\n\r\n\tremove(item:IKeyValuePair|[TKey,TValue]):number\r\n\t{\r\n\t\tif(!item) return 0;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn (areEqual(value, v) && this.removeByKey(key))\r\n\t\t\t\t\t? 1 : 0;\r\n\t\t\t});\r\n\r\n\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// IDictionary\r\n\t/////////////////////////////////////////\r\n\r\n\tprotected abstract getKeys():TKey[];\r\n\r\n\tget keys():TKey[] { return this.getKeys(); }\r\n\r\n\tprotected abstract getValues():TValue[];\r\n\r\n\tget values():TValue[] { return this.getValues(); }\r\n\r\n\r\n\taddByKeyValue(key:TKey, value:TValue):void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.containsKey(key))\r\n\t\t{\r\n\t\t\tvar ex = new InvalidOperationException(\"Adding a key/value when the key already exists.\");\r\n\t\t\tex.data['key'] = key;\r\n\t\t\tex.data['value'] = value;\r\n\t\t\tthrow ex;\r\n\t\t}\r\n\r\n\t\t_.setValue(key, value);\r\n\t}\r\n\r\n\tabstract getValue(key:TKey):TValue;\r\n\r\n\tabstract setValue(key:TKey, value:TValue):boolean;\r\n\r\n\tcontainsKey(key:TKey):boolean\r\n\t{\r\n\t\tvar value = this.getValue(key);\r\n\t\treturn value!==VOID0;\r\n\t}\r\n\r\n\tcontainsValue(value:TValue):boolean\r\n\t{\r\n\t\tvar e = this.getEnumerator(), equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\r\n\t\twhile(e.moveNext())\r\n\t\t{\r\n\t\t\tif(equal(e.current, value, true))\r\n\t\t\t{\r\n\t\t\t\te.dispose();\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\tremoveByKey(key:TKey):boolean\r\n\t{\r\n\t\treturn this.setValue(key, undefined);\r\n\t}\r\n\r\n\tremoveByValue(value:TValue):number\r\n\t{\r\n\t\tvar _ = this, count = 0, equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\t\t_.keys.forEach(key=>\r\n\t\t{\r\n\t\t\tif(equal(_.getValue(key), value, true))\r\n\t\t\t{\r\n\t\t\t\t_.removeByKey(key);\r\n\t\t\t\t++count;\r\n\t\t\t}\r\n\t\t});\r\n\t\treturn count;\r\n\t}\r\n\r\n\timportPairs(pairs:KeyValuePair[]|IEnumerable>):boolean\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(!pairs) return false;\r\n\t\treturn _.handleUpdate(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tlet changed:boolean = false;\r\n\t\t\t\tforEach(pairs,\r\n\t\t\t\t\tpair=>extractKeyValue(pair, (key, value)=>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t\t\t\tchanged = true;\r\n\t\t\t\t\t})\r\n\t\t\t\t);\r\n\t\t\t\treturn changed;\r\n\t\t\t}\r\n\t\t);\r\n\t}\r\n\r\n\tgetEnumerator():IEnumerator>\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tvar keys:TKey[], len:number, i = 0;\r\n\t\treturn new EnumeratorBase>(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tkeys = _.keys;\r\n\t\t\t\tlen = keys.length\r\n\t\t\t},\r\n\r\n\t\t\t(yielder)=>\r\n\t\t\t{\r\n\t\t\t\twhile(i\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../../Types';\r\nimport DisposableBase from '../../Disposable/DisposableBase';\r\nimport ArrayEnumerator from './ArrayEnumerator';\r\nimport IndexEnumerator from './IndexEnumerator';\r\n\r\n\r\nclass EmptyEnumerator implements IEnumerator\r\n{\r\n\tget current():any\r\n\t{\r\n\t\treturn undefined;\r\n\t}\r\n\r\n\tmoveNext():boolean\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treset():void { }\r\n\r\n\tdispose():void { }\r\n}\r\n\r\nconst Empty = new EmptyEnumerator();\r\n\r\n// Could be array, or IEnumerable...\r\nexport function from(source:IEnumerable | IArray):IEnumerator\r\n{\r\n\t// To simplify and prevent null reference exceptions:\r\n\tif(!source)\r\n\t\treturn Empty;\r\n\r\n\tif(Array.isArray(source))\r\n\t\treturn new ArrayEnumerator(source);\r\n\r\n\r\n\tif(!Type.isPrimitive(source))\r\n\t{\r\n\t\tif(Type.isArrayLike(source))\r\n\t\t{\r\n\t\t\treturn new IndexEnumerator(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\tlength: source.length,\r\n\t\t\t\t\t\tpointer: 0,\r\n\t\t\t\t\t\tstep: 1\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t);\r\n\t\t}\r\n\t\tif(isEnumerable(source))\r\n\t\t\treturn source.getEnumerator();\r\n\r\n\t}\r\n\r\n\tthrow new Error(\"Unknown enumerable.\");\r\n}\r\n\r\nexport function isEnumerable(instance:any):instance is IEnumerable\r\n{\r\n\treturn Type.hasMemberOfType>(instance, \"getEnumerator\", Type.FUNCTION);\r\n}\r\n\r\nexport function forEach(\r\n\te:IEnumerator,\r\n\taction:(element:T, index?:number) => any):void\r\n{\r\n\tif(e)\r\n\t{\r\n\t\tvar index = 0;\r\n\t\t// Return value of action can be anything, but if it is (===) false then the forEach will discontinue.\r\n\t\twhile(e.moveNext())\r\n\t\t{\r\n\t\t\tif(action(e.current, index++)===false)\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["System/Collections/Enumeration/Enumerator.js","System/Collections/Enumeration/Enumerator.ts"],"names":["define","require","exports","Types_1","ArrayEnumerator_1","IndexEnumerator_1","from","source","isEnumerable","instance","isEnumerator","forEach","e","action","EmptyEnumerator","get","enumerable","configurable","EmptyEnumerator.moveNext","Empty"],"mappings":";;;;AAIAA,QAAQ,UAAW,UAAW,cAAe,oBAAqB,qBAAsB,SAAUC,EAASC,EAASC,EAASC,EAAmBC,GCKhJ,YA4BA,SAAAC,GAAwBC,GAGvBD,IAAIA,EACHA,MAAOA,EAERA,IAAGA,MAAMA,QAAQA,GAChBA,MAAOA,IAAIA,GAAAA,WAAwBA,EAGpCA,KAAIA,EAAAA,WAAKA,YAAYA,GACrBA,CACCA,GAAGA,EAAAA,WAAKA,YAAeA,GAEtBA,MAAOA,IAAIA,GAAAA,WACVA,WAECA,OACCA,OAAQA,EACRA,OAAQA,EAAOA,OACfA,QAASA,EACTA,KAAMA,IAKVA,IAAGA,EAAgBA,GAClBA,MAAOA,GAAOA,gBAIhBA,KAAMA,IAAIA,OAAMA,uBAGjB,QAAAE,GAAgCC,GAE/BD,MAAOA,GAAAA,WAAKA,gBAAgCA,EAAUA,gBAAiBA,EAAAA,WAAKA,UAG7E,QAAAE,GAAgCD,GAE/BC,MAAOA,GAAAA,WAAKA,gBAAgCA,EAAUA,WAAYA,EAAAA,WAAKA,UAGxE,QAAAC,GACCC,EACAC,GAEAF,GAAGA,EACHA,CACCA,GAAGA,MAAMA,QAAQA,GAGhBA,WADAA,GAAEA,QAAQA,EASXA,IALGA,EAAgBA,KAElBA,EAAqBA,EAAGA,iBAGtBA,EAAgBA,GAIlBA,IAFAA,GAAIA,GAAQA,EAENA,EAAEA,YAEJA,EAAOA,EAAEA,QAASA,QAAWA,MAvFpC,GAAAG,GAAA,WAAAA,QAAAA,MAeAA,MAbCA,QAAAA,eAAIA,EAAAA,UAAAA,WDTOC,ICSXD,aDNWE,YAAY,EACZC,cAAc,ICUzBH,EAAAA,UAAAA,SAAAA,WAECI,OAAOA,GAGRJ,EAAAA,UAAAA,MAAAA,aAEAA,EAAAA,UAAAA,QAAAA,aACDA,KAEMK,EAAQ,GAAIL,EAGFZ,GAAAI,KAAIA,EAkCJJ,EAAAM,aAAYA,EAKZN,EAAAQ,aAAYA,EAKZR,EAAAS,QAAOA","file":"System/Collections/Enumeration/Enumerator.js","sourcesContent":["/*!\n * @author electricessence / https://github.com/electricessence/\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\n */\ndefine([\"require\", \"exports\", '../../Types', './ArrayEnumerator', './IndexEnumerator'], function (require, exports, Types_1, ArrayEnumerator_1, IndexEnumerator_1) {\n 'use strict';\n var EmptyEnumerator = (function () {\n function EmptyEnumerator() {\n }\n Object.defineProperty(EmptyEnumerator.prototype, \"current\", {\n get: function () {\n return undefined;\n },\n enumerable: true,\n configurable: true\n });\n EmptyEnumerator.prototype.moveNext = function () {\n return false;\n };\n EmptyEnumerator.prototype.reset = function () { };\n EmptyEnumerator.prototype.dispose = function () { };\n return EmptyEnumerator;\n })();\n var Empty = new EmptyEnumerator();\n function from(source) {\n if (!source)\n return Empty;\n if (Array.isArray(source))\n return new ArrayEnumerator_1.default(source);\n if (!Types_1.default.isPrimitive(source)) {\n if (Types_1.default.isArrayLike(source)) {\n return new IndexEnumerator_1.default(function () {\n return {\n source: source,\n length: source.length,\n pointer: 0,\n step: 1\n };\n });\n }\n if (isEnumerable(source))\n return source.getEnumerator();\n }\n throw new Error(\"Unknown enumerable.\");\n }\n exports.from = from;\n function isEnumerable(instance) {\n return Types_1.default.hasMemberOfType(instance, \"getEnumerator\", Types_1.default.FUNCTION);\n }\n exports.isEnumerable = isEnumerable;\n function isEnumerator(instance) {\n return Types_1.default.hasMemberOfType(instance, \"moveNext\", Types_1.default.FUNCTION);\n }\n exports.isEnumerator = isEnumerator;\n function forEach(e, action) {\n if (e) {\n if (Array.isArray(e)) {\n e.forEach(action);\n return;\n }\n if (isEnumerable(e)) {\n e = e.getEnumerator();\n }\n if (isEnumerator(e)) {\n var index = 0;\n while (e.moveNext()) {\n if (action(e.current, index++) === false)\n break;\n }\n }\n }\n }\n exports.forEach = forEach;\n});\n","/*!\r\n * @author electricessence / https://github.com/electricessence/\r\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\r\n */\r\n\r\n///\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../../Types';\r\nimport DisposableBase from '../../Disposable/DisposableBase';\r\nimport ArrayEnumerator from './ArrayEnumerator';\r\nimport IndexEnumerator from './IndexEnumerator';\r\n\r\n\r\nclass EmptyEnumerator implements IEnumerator\r\n{\r\n\tget current():any\r\n\t{\r\n\t\treturn undefined;\r\n\t}\r\n\r\n\tmoveNext():boolean\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treset():void { }\r\n\r\n\tdispose():void { }\r\n}\r\n\r\nconst Empty = new EmptyEnumerator();\r\n\r\n// Could be array, or IEnumerable...\r\nexport function from(source:IEnumerable | IArray):IEnumerator\r\n{\r\n\t// To simplify and prevent null reference exceptions:\r\n\tif(!source)\r\n\t\treturn Empty;\r\n\r\n\tif(Array.isArray(source))\r\n\t\treturn new ArrayEnumerator(source);\r\n\r\n\r\n\tif(!Type.isPrimitive(source))\r\n\t{\r\n\t\tif(Type.isArrayLike(source))\r\n\t\t{\r\n\t\t\treturn new IndexEnumerator(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\tlength: source.length,\r\n\t\t\t\t\t\tpointer: 0,\r\n\t\t\t\t\t\tstep: 1\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t);\r\n\t\t}\r\n\t\tif(isEnumerable(source))\r\n\t\t\treturn source.getEnumerator();\r\n\r\n\t}\r\n\r\n\tthrow new Error(\"Unknown enumerable.\");\r\n}\r\n\r\nexport function isEnumerable(instance:any):instance is IEnumerable\r\n{\r\n\treturn Type.hasMemberOfType>(instance, \"getEnumerator\", Type.FUNCTION);\r\n}\r\n\r\nexport function isEnumerator(instance:any):instance is IEnumerator\r\n{\r\n\treturn Type.hasMemberOfType>(instance, \"moveNext\", Type.FUNCTION);\r\n}\r\n\r\nexport function forEach(\r\n\te:T[]|IEnumerator|IEnumerable,\r\n\taction:(element:T, index?:number) => any):void\r\n{\r\n\tif(e)\r\n\t{\r\n\t\tif(Array.isArray(e))\r\n\t\t{\r\n\t\t\te.forEach(action);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif(isEnumerable(e))\r\n\t\t{\r\n\t\t\te = (>e).getEnumerator();\r\n\t\t}\r\n\r\n\t\tif(isEnumerator(e))\r\n\t\t{\r\n\t\t\tvar index = 0;\r\n\t\t\t// Return value of action can be anything, but if it is (===) false then the forEach will discontinue.\r\n\t\t\twhile(e.moveNext())\r\n\t\t\t{\r\n\t\t\t\tif(action(e.current, index++)===false)\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"]} \ No newline at end of file diff --git a/dist/amd/System/Uri/QueryBuilder.js b/dist/amd/System/Uri/QueryBuilder.js index 5761bb4f..a67861b3 100644 --- a/dist/amd/System/Uri/QueryBuilder.js +++ b/dist/amd/System/Uri/QueryBuilder.js @@ -2,5 +2,5 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md */ -var __extends=this&&this.__extends||function(t,r){function e(){this.constructor=t}for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i]);t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)};define(["require","exports","../Types","./QueryParams","../Collections/Dictionaries/OrderedStringKeyDictionary"],function(t,r,e,i,n){"use strict";var o="&",s="=",u=function(t){function r(r,e){void 0===e&&(e=!0),t.call(this),this.importQuery(r,e)}return __extends(r,t),r.prototype.importQuery=function(t,r){return void 0===r&&(r=!0),e["default"].isString(t)?this.importFromString(t,r):Array.isArray(t)?this.importPairs(t):this.importMap(t),this},r.prototype.importFromString=function(t,r,e){void 0===r&&(r=!0),void 0===e&&(e=!0);var n=this;return i.parse(t,function(t,r){if(n.containsKey(t)){var e=n.getValue(t);Array.isArray(e)?e.push(r):n.setValue(t,[e,r])}else n.setValue(t,r)},r,e),this},r.init=function(t,e){return void 0===e&&(e=!0),new r(t,e)},r.prototype.encode=function(t){for(var r=[],e=this.keys,n=0;n\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../Types';\r\nimport * as Serialization from '../Serialization/Utility';\r\nimport * as QueryParams from './QueryParams';\r\nimport OrderedStringKeyDictionary from '../Collections/Dictionaries/OrderedStringKeyDictionary';\r\n\r\nconst\r\nENTRY_SEPARATOR = \"&\",\r\nKEY_VALUE_SEPARATOR = \"=\";\r\n\r\n/**\r\n * Provides a means for parsing and building a set of parameters.\r\n *\r\n * In other languages, dictionaries are not reliable for retaining the order of stored values. So for certainty and flexibility we use an ordered dictionary as a base class.\r\n */\r\nexport default\r\nclass QueryBuilder extends OrderedStringKeyDictionary\r\n{\r\n\r\n\tconstructor(\r\n\t\tquery:string|IUriComponentMap|StringKeyValuePair[],\r\n\t\tdecodeValues:boolean = true)\r\n\t{\r\n\t\tsuper();\r\n\r\n\t\tthis.importQuery(query,decodeValues);\r\n\t}\r\n\r\n\timportQuery(\r\n\t\tquery:string|IUriComponentMap|StringKeyValuePair[],\r\n\t\tdecodeValues:boolean = true):QueryBuilder {\r\n\r\n\t\tif(Type.isString(query))\r\n\t\t{\r\n\t\t\tthis.importFromString(query, decodeValues);\r\n\t\t}\r\n\t\telse if(Array.isArray(query))\r\n\t\t{\r\n\t\t\tthis.importPairs(query);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.importMap(query);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Property parses the components of an URI into their values or array of values.\r\n\t * @param values\r\n\t * @param deserialize\r\n\t * @param decodeValues\r\n\t * @returns {QueryBuilder}\r\n\t */\r\n\timportFromString(\r\n\t\tvalues:string,\r\n\t\tdeserialize:boolean = true,\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tQueryParams.parse(values,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\tif(_.containsKey(key))\r\n\t\t\t\t{\r\n\t\t\t\t\tvar prev = _.getValue(key);\r\n\t\t\t\t\tif(Array.isArray(prev))\r\n\t\t\t\t\t\tprev.push(value);\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\t_.setValue(key, [prev, value]);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t},\r\n\t\t\tdeserialize,\r\n\t\t\tdecodeValues);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tstatic init(\r\n\t\tquery:string|IUriComponentMap|StringKeyValuePair[],\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\treturn new QueryBuilder(query, decodeValues);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Returns the encoded URI string\r\n\t */\r\n\tencode(prefixIfNotEmpty?:boolean):string\r\n\t{\r\n\t\tvar entries:string[] = [];\r\n\t\tvar keys = this.keys;\r\n\t\tfor(let k of keys)\r\n\t\t{\r\n\t\t\tvar value = this.getValue(k);\r\n\t\t\t// Since the values can either be UriComponentValues or an array of UriComponentValues..\r\n\t\t\t// This creates a single code path for both options.\r\n\t\t\tfor(let v of Array.isArray(value) ? value : [value])\r\n\t\t\t{\r\n\t\t\t\tentries.push(\r\n\t\t\t\t\tk + KEY_VALUE_SEPARATOR\r\n\t\t\t\t\t+ QueryParams.encodeValue(v));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn (entries.length && prefixIfNotEmpty ? '?' : '')\r\n\t\t\t+ entries.join(ENTRY_SEPARATOR);\r\n\t}\r\n\r\n\ttoString():string\r\n\t{\r\n\t\treturn this.encode();\r\n\t}\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["System/Uri/QueryBuilder.js","System/Uri/QueryBuilder.ts"],"names":["__extends","this","d","b","__","constructor","p","hasOwnProperty","prototype","Object","create","define","require","exports","Types_1","QueryParams","OrderedStringKeyDictionary_1","Enumerator_1","ENTRY_SEPARATOR","KEY_VALUE_SEPARATOR","QueryBuilder","_super","QueryBuilder.constructor","QueryBuilder.init","QueryBuilder.importQuery","QueryBuilder.importFromString","QueryBuilder.encode","QueryBuilder.toString","defineProperty","value"],"mappings":";;;;AAIA,GAAIA,WAAaC,MAAQA,KAAKD,WAAc,SAAUE,EAAGC,GAErD,QAASC,KAAOH,KAAKI,YAAcH,EADnC,IAAK,GAAII,KAAKH,GAAOA,EAAEI,eAAeD,KAAIJ,EAAEI,GAAKH,EAAEG,GAEnDJ,GAAEM,UAAkB,OAANL,EAAaM,OAAOC,OAAOP,IAAMC,EAAGI,UAAYL,EAAEK,UAAW,GAAIJ,IAEnFO,SAAQ,UAAW,UAAW,WAAY,gBAAiB,yDAA0D,yCAA0C,SAAUC,EAASC,EAASC,EAASC,EAAaC,EAA8BC,GCA/O,YASA,IACAC,GAAsB,IACtBC,EAAsB,IAOtBC,EAAA,SAAAC,GAICD,QAAAA,GACCA,EAIAA,GAAAE,SAAAA,IAAAA,GAAAA,GAEAA,EAAAA,KAAAA,MAEAA,KAAKA,YAAYA,EAAMA,GAoGzBF,MAhH2BA,WAAAA,EAAAA,GAgBnBA,EAAAA,KAAPA,SACCA,EAIAA,GAEAG,MAFAA,UAAAA,IAAAA,GAAAA,GAEOA,GAAIA,GAAaA,EAAOA,IAGhCH,EAAAA,UAAAA,YAAAA,SACCA,EAIAA,GAeAI,MAfAA,UAAAA,IAAAA,GAAAA,GAEGA,EAAAA,WAAKA,SAASA,GAEhBA,KAAKA,iBAAyBA,EAAOA,GAE9BA,MAAMA,QAAQA,IAAUA,EAAAA,aAAaA,GAE5CA,KAAKA,YAAYA,GAIjBA,KAAKA,UAA4BA,GAG3BA,MAURJ,EAAAA,UAAAA,iBAAAA,SACCA,EACAA,EACAA,GADAK,SAAAA,IAAAA,GAAAA,GACAA,SAAAA,IAAAA,GAAAA,EAEAA,IAAIA,GAAIA,IAkBRA,OAjBAA,GAAYA,MAAMA,EACjBA,SAACA,EAAKA,GAELA,GAAGA,EAAEA,YAAYA,GACjBA,CACCA,GAAIA,GAAOA,EAAEA,SAASA,EACnBA,OAAMA,QAAQA,GAChBA,EAAKA,KAAKA,GAEVA,EAAEA,SAASA,GAAyBA,EAAMA,QAG3CA,GAAEA,SAASA,EAAKA,IAElBA,EACAA,GAEMA,MAQRL,EAAAA,UAAAA,OAAAA,SAAOA,GAINM,IAAaA,GAFTA,MACAA,EAAOA,KAAKA,KACHA,EAAAA,EAATA,EAAAA,EAAAA,OAAAA,IAKHA,IAAaA,GALNA,GAAKA,EAAIA,GAEZA,EAAQA,KAAKA,SAASA,GAGbA,EAAAA,EAAAA,EAAAA,MAAMA,QAAQA,GAASA,GAASA,GAAzCA,EAAAA,EAAAA,OAAAA,IAAgDA,CAAhDA,GAAIA,GAACA,EAAAA,EAERA,GAAQA,KACPA,EAAIA,EACFA,EAAYA,YAA+BA,IAIhDA,OAAQA,EAAQA,QAAUA,EAAmBA,IAAMA,IAChDA,EAAQA,KAAKA,IAGjBN,EAAAA,UAAAA,SAAAA,WAECO,MAAOA,MAAKA,UAEdP,GAhH2BJ,EAAAA,WAD3BP,QAAAmB,eAAAf,EAAA,cAAAgB,OAAA,ID+CIhB,EAAAA,WAAkBO","file":"System/Uri/QueryBuilder.js","sourcesContent":["/*!\n * @author electricessence / https://github.com/electricessence/\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\n */\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\ndefine([\"require\", \"exports\", '../Types', './QueryParams', '../Collections/Dictionaries/OrderedStringKeyDictionary', '../Collections/Enumeration/Enumerator'], function (require, exports, Types_1, QueryParams, OrderedStringKeyDictionary_1, Enumerator_1) {\n 'use strict';\n var ENTRY_SEPARATOR = \"&\", KEY_VALUE_SEPARATOR = \"=\";\n var QueryBuilder = (function (_super) {\n __extends(QueryBuilder, _super);\n function QueryBuilder(query, decodeValues) {\n if (decodeValues === void 0) { decodeValues = true; }\n _super.call(this);\n this.importQuery(query, decodeValues);\n }\n QueryBuilder.init = function (query, decodeValues) {\n if (decodeValues === void 0) { decodeValues = true; }\n return new QueryBuilder(query, decodeValues);\n };\n QueryBuilder.prototype.importQuery = function (query, decodeValues) {\n if (decodeValues === void 0) { decodeValues = true; }\n if (Types_1.default.isString(query)) {\n this.importFromString(query, decodeValues);\n }\n else if (Array.isArray(query) || Enumerator_1.isEnumerable(query)) {\n this.importPairs(query);\n }\n else {\n this.importMap(query);\n }\n return this;\n };\n QueryBuilder.prototype.importFromString = function (values, deserialize, decodeValues) {\n if (deserialize === void 0) { deserialize = true; }\n if (decodeValues === void 0) { decodeValues = true; }\n var _ = this;\n QueryParams.parse(values, function (key, value) {\n if (_.containsKey(key)) {\n var prev = _.getValue(key);\n if (Array.isArray(prev))\n prev.push(value);\n else\n _.setValue(key, [prev, value]);\n }\n else\n _.setValue(key, value);\n }, deserialize, decodeValues);\n return this;\n };\n QueryBuilder.prototype.encode = function (prefixIfNotEmpty) {\n var entries = [];\n var keys = this.keys;\n for (var _i = 0; _i < keys.length; _i++) {\n var k = keys[_i];\n var value = this.getValue(k);\n for (var _a = 0, _b = Array.isArray(value) ? value : [value]; _a < _b.length; _a++) {\n var v = _b[_a];\n entries.push(k + KEY_VALUE_SEPARATOR\n + QueryParams.encodeValue(v));\n }\n }\n return (entries.length && prefixIfNotEmpty ? '?' : '')\n + entries.join(ENTRY_SEPARATOR);\n };\n QueryBuilder.prototype.toString = function () {\n return this.encode();\n };\n return QueryBuilder;\n })(OrderedStringKeyDictionary_1.default);\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.default = QueryBuilder;\n});\n","/*!\r\n * @author electricessence / https://github.com/electricessence/\r\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\r\n */\r\n\r\n///\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../Types';\r\nimport * as Serialization from '../Serialization/Utility';\r\nimport * as QueryParams from './QueryParams';\r\nimport OrderedStringKeyDictionary from '../Collections/Dictionaries/OrderedStringKeyDictionary';\r\nimport {isEnumerable} from '../Collections/Enumeration/Enumerator';\r\n\r\n\r\nconst\r\nENTRY_SEPARATOR = \"&\",\r\nKEY_VALUE_SEPARATOR = \"=\";\r\n\r\n/**\r\n * Provides a means for parsing and building a set of parameters.\r\n *\r\n * In other languages, dictionaries are not reliable for retaining the order of stored values. So for certainty and flexibility we use an ordered dictionary as a base class.\r\n */\r\nexport default\r\nclass QueryBuilder extends OrderedStringKeyDictionary\r\n{\r\n\r\n\tconstructor(\r\n\t\tquery:string\r\n\t\t\t|IUriComponentMap\r\n\t\t\t|StringKeyValuePair[]\r\n\t\t\t|IEnumerable>,\r\n\t\tdecodeValues:boolean = true)\r\n\t{\r\n\t\tsuper();\r\n\r\n\t\tthis.importQuery(query,decodeValues);\r\n\t}\r\n\r\n\r\n\tstatic init(\r\n\t\tquery:string\r\n\t\t\t|IUriComponentMap\r\n\t\t\t|StringKeyValuePair[]\r\n\t\t\t|IEnumerable>,\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\treturn new QueryBuilder(query, decodeValues);\r\n\t}\r\n\r\n\timportQuery(\r\n\t\tquery:string\r\n\t\t\t|IUriComponentMap\r\n\t\t\t|StringKeyValuePair[]\r\n\t\t\t|IEnumerable>,\r\n\t\tdecodeValues:boolean = true):QueryBuilder {\r\n\r\n\t\tif(Type.isString(query))\r\n\t\t{\r\n\t\t\tthis.importFromString(query, decodeValues);\r\n\t\t}\r\n\t\telse if(Array.isArray(query) || isEnumerable(query))\r\n\t\t{\r\n\t\t\tthis.importPairs(query);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.importMap(query);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Property parses the components of an URI into their values or array of values.\r\n\t * @param values\r\n\t * @param deserialize\r\n\t * @param decodeValues\r\n\t * @returns {QueryBuilder}\r\n\t */\r\n\timportFromString(\r\n\t\tvalues:string,\r\n\t\tdeserialize:boolean = true,\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tQueryParams.parse(values,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\tif(_.containsKey(key))\r\n\t\t\t\t{\r\n\t\t\t\t\tvar prev = _.getValue(key);\r\n\t\t\t\t\tif(Array.isArray(prev))\r\n\t\t\t\t\t\tprev.push(value);\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\t_.setValue(key, [prev, value]);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t},\r\n\t\t\tdeserialize,\r\n\t\t\tdecodeValues);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\r\n\r\n\t/**\r\n\t * Returns the encoded URI string\r\n\t */\r\n\tencode(prefixIfNotEmpty?:boolean):string\r\n\t{\r\n\t\tvar entries:string[] = [];\r\n\t\tvar keys = this.keys;\r\n\t\tfor(let k of keys)\r\n\t\t{\r\n\t\t\tvar value = this.getValue(k);\r\n\t\t\t// Since the values can either be UriComponentValues or an array of UriComponentValues..\r\n\t\t\t// This creates a single code path for both options.\r\n\t\t\tfor(let v of Array.isArray(value) ? value : [value])\r\n\t\t\t{\r\n\t\t\t\tentries.push(\r\n\t\t\t\t\tk + KEY_VALUE_SEPARATOR\r\n\t\t\t\t\t+ QueryParams.encodeValue(v));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn (entries.length && prefixIfNotEmpty ? '?' : '')\r\n\t\t\t+ entries.join(ENTRY_SEPARATOR);\r\n\t}\r\n\r\n\ttoString():string\r\n\t{\r\n\t\treturn this.encode();\r\n\t}\r\n}\r\n"]} \ No newline at end of file diff --git a/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js b/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js index 538a11e6..1a2283c3 100644 --- a/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js +++ b/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js @@ -8,6 +8,7 @@ var EnumeratorBase_1 = require('../Enumeration/EnumeratorBase'); var ArgumentNullException_1 = require('../../Exceptions/ArgumentNullException'); var InvalidOperationException_1 = require('../../Exceptions/InvalidOperationException'); var KeyValueExtract_1 = require('../../KeyValueExtract'); +var Enumerator_1 = require('../Enumeration/Enumerator'); var VOID0 = void (0); var DictionaryBase = (function () { function DictionaryBase() { @@ -157,9 +158,11 @@ var DictionaryBase = (function () { }; DictionaryBase.prototype.importPairs = function (pairs) { var _ = this; + if (!pairs) + return false; return _.handleUpdate(function () { var changed = false; - pairs.forEach(function (pair) { return KeyValueExtract_1.default(pair, function (key, value) { + Enumerator_1.forEach(pairs, function (pair) { return KeyValueExtract_1.default(pair, function (key, value) { _.setValue(key, value); changed = true; }); }); diff --git a/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js.map b/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js.map index ec85e00c..23a557a3 100644 --- a/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js.map +++ b/dist/commonjs/System/Collections/Dictionaries/DictionaryBase.js.map @@ -1 +1 @@ -{"version":3,"file":"DictionaryBase.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Dictionaries/DictionaryBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,CAAC;AAEb,wBAAuB,eAAe,CAAC,CAAA;AACvC,+BAA2B,+BAA+B,CAAC,CAAA;AAE3D,sCAAkC,wCAAwC,CAAC,CAAA;AAC3E,0CAAsC,4CAA4C,CAAC,CAAA;AACnF,gCAA4B,uBAAuB,CAAC,CAAA;AAEpD,IAAM,KAAK,GAAO,KAAI,CAAC,CAAC,CAAC,CAAC;AAG1B;IAMC;QAEC,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,sBAAI,sCAAU;aAAd,cAA2B,MAAM,CAAC,IAAI,CAAC,gBAAgB,IAAE,CAAC,CAAC,CAAC,CAAC;;;OAAA;IAKnD,uCAAc,GAAxB,UAAyB,GAAQ,EAAE,KAAY,EAAE,GAAU;QAE1D,EAAE,CAAA,CAAC,CAAC,kBAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAC/B,CAAC;YAEA,IAAI,CAAC,GAAG,IAAI,CAAC;YACb,EAAE,CAAA,CAAC,CAAC,CAAC,cAAc,CAAC;gBACnB,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAGnC,EAAE,CAAA,CAAC,CAAC,CAAC,gBAAgB,IAAE,CAAC,CAAC;gBACxB,CAAC,CAAC,UAAU,EAAE,CAAC;QAEjB,CAAC;IACF,CAAC;IAMO,mCAAU,GAAlB;QAEC,IAAI,CAAC,GAAG,IAAI,CAAC;QACb,EAAE,CAAA,CAAC,CAAC,CAAC,SAAS,CAAC;YACd,CAAC,CAAC,SAAS,EAAE,CAAC;IAChB,CAAC;IAGD,qCAAY,GAAZ,UAAa,OAAsB;QAElC,IAAI,CAAC,GAAG,IAAI,EAAE,MAA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,CAAC;QAChB,CAAC,CACD,CAAC;IACH,CAAC;IAED,sCAAa,GAAb;QAEC,IAAI,CAAC,GAAG,IAAI,CAAC;QACb,IAAI,IAAW,EAAE,GAAU,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,IAAI,wBAAc,CACxB;YAEC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;YACd,GAAG,GAAG,IAAI,CAAC,MAAM,CAAA;QAClB,CAAC,EAED,UAAC,OAAO;YAEP,OAAM,CAAC,GAAC,GAAG,EACX,CAAC;gBACA,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC7C,EAAE,CAAA,CAAC,KAAK,KAAG,KAAK,CAAC;oBAChB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC7B,CAAC,CACD,CAAC;IACH,CAAC;IAGF,qBAAC;AAAD,CAAC,AAnRD,IAmRC;AAGD;kBAAe,cAAc,CAAC"} \ No newline at end of file +{"version":3,"file":"DictionaryBase.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Dictionaries/DictionaryBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,CAAC;AAEb,wBAAuB,eAAe,CAAC,CAAA;AACvC,+BAA2B,+BAA+B,CAAC,CAAA;AAE3D,sCAAkC,wCAAwC,CAAC,CAAA;AAC3E,0CAAsC,4CAA4C,CAAC,CAAA;AACnF,gCAA4B,uBAAuB,CAAC,CAAA;AACpD,2BAAsB,2BAA2B,CAAC,CAAA;AAElD,IAAM,KAAK,GAAO,KAAI,CAAC,CAAC,CAAC,CAAC;AAG1B;IAMC;QAEC,IAAI,CAAC,gBAAgB,GAAG,CAAC,C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I,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC7C,EAAE,CAAA,CAAC,KAAK,KAAG,KAAK,CAAC;oBAChB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC7B,CAAC,CACD,CAAC;IACH,CAAC;IAGF,qBAAC;AAAD,CAAC,AApRD,IAoRC;AAGD;kBAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/dist/commonjs/System/Collections/Enumeration/Enumerator.js b/dist/commonjs/System/Collections/Enumeration/Enumerator.js index 4419f872..a7392688 100644 --- a/dist/commonjs/System/Collections/Enumeration/Enumerator.js +++ b/dist/commonjs/System/Collections/Enumeration/Enumerator.js @@ -50,12 +50,25 @@ function isEnumerable(instance) { return Types_1.default.hasMemberOfType(instance, "getEnumerator", Types_1.default.FUNCTION); } exports.isEnumerable = isEnumerable; +function isEnumerator(instance) { + return Types_1.default.hasMemberOfType(instance, "moveNext", Types_1.default.FUNCTION); +} +exports.isEnumerator = isEnumerator; function forEach(e, action) { if (e) { - var index = 0; - while (e.moveNext()) { - if (action(e.current, index++) === false) - break; + if (Array.isArray(e)) { + e.forEach(action); + return; + } + if (isEnumerable(e)) { + e = e.getEnumerator(); + } + if (isEnumerator(e)) { + var index = 0; + while (e.moveNext()) { + if (action(e.current, index++) === false) + break; + } } } } diff --git a/dist/commonjs/System/Collections/Enumeration/Enumerator.js.map b/dist/commonjs/System/Collections/Enumeration/Enumerator.js.map index c6ab1195..668ed945 100644 --- a/dist/commonjs/System/Collections/Enumeration/Enumerator.js.map +++ b/dist/commonjs/System/Collections/Enumeration/Enumerator.js.map @@ -1 +1 @@ -{"version":3,"file":"Enumerator.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Enume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C,CAAC;AAhCe,YAAI,OAgCnB,CAAA;AAED,sBAAgC,QAAY;IAE3C,MAAM,CAAC,eAAI,CAAC,eAAe,CAAiB,QAAQ,EAAE,eAAe,EAAE,eAAI,CAAC,QAAQ,CAAC,CAAC;AACvF,CAAC;AAHe,oBAAY,eAG3B,CAAA;AAED,iBACC,CAAgB,EAChB,MAAwC;IAExC,EAAE,CAAA,CAAC,CAAC,CAAC,CACL,CAAC;QACA,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,OAAM,CAAC,CAAC,QAAQ,EAAE,EAClB,CAAC;YACA,EAAE,CAAA,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,KAAG,KAAK,CAAC;gBACrC,KAAK,CAAC;QACR,CAAC;IACF,CAAC;AACF,CAAC;AAde,eAAO,UActB,CAAA"} \ No newline at end of file +{"version":3,"file":"Enumerator.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Enumeration/Enumerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,CAAC;AAEb,sBAAiB,aAAa,CAAC,CAAA;AAE/B,gCAA4B,mBAAmB,CAAC,CAAA;AAChD,gCAA4B,mBAAmB,CAAC,CAAA;AAGhD;IAAA;IAeA,CAAC;IAbA,sBAAI,oCAAO;aAAX;YAEC,MAAM,CAAC,SAAS,CAAC;QAClB,CAAC;;;OAAA;IAED,kCAAQ,GAAR;QAEC,MAAM,CAAC,KAAK,CAAC;IACd,CAAC;IAED,+BAAK,GAAL,cAAe,CAAC;IAEhB,iCAAO,GAAP,cAAiB,CAAC;IACnB,sBAAC;AAAD,CAAC,AAfD,IAeC;AAED,IAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;AAGpC,cAAwB,MAAiC;IAGxD,EAAE,CAAA,CAAC,CAAC,MAAM,CAAC;QACV,MAAM,CAAC,KAAK,CAAC;IAEd,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;Q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C,CACtB,CAAC;YACA,CAAC,GAAoB,CAAE,CAAC,aAAa,EAAE,CAAC;QACzC,CAAC;QAED,EAAE,CAAA,CAAC,YAAY,CAAI,CAAC,CAAC,CAAC,CACtB,CAAC;YACA,IAAI,KAAK,GAAG,CAAC,CAAC;YAEd,OAAM,CAAC,CAAC,QAAQ,EAAE,EAClB,CAAC;gBACA,EAAE,CAAA,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,KAAG,KAAK,CAAC;oBACrC,KAAK,CAAC;YACR,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AA5Be,eAAO,UA4BtB,CAAA"} \ No newline at end of file diff --git a/dist/commonjs/System/Uri/QueryBuilder.js b/dist/commonjs/System/Uri/QueryBuilder.js index f5853795..445efc0a 100644 --- a/dist/commonjs/System/Uri/QueryBuilder.js +++ b/dist/commonjs/System/Uri/QueryBuilder.js @@ -11,6 +11,7 @@ var __extends = (this && this.__extends) || function (d, b) { var Types_1 = require('../Types'); var QueryParams = require('./QueryParams'); var OrderedStringKeyDictionary_1 = require('../Collections/Dictionaries/OrderedStringKeyDictionary'); +var Enumerator_1 = require('../Collections/Enumeration/Enumerator'); var ENTRY_SEPARATOR = "&", KEY_VALUE_SEPARATOR = "="; var QueryBuilder = (function (_super) { __extends(QueryBuilder, _super); @@ -19,12 +20,16 @@ var QueryBuilder = (function (_super) { _super.call(this); this.importQuery(query, decodeValues); } + QueryBuilder.init = function (query, decodeValues) { + if (decodeValues === void 0) { decodeValues = true; } + return new QueryBuilder(query, decodeValues); + }; QueryBuilder.prototype.importQuery = function (query, decodeValues) { if (decodeValues === void 0) { decodeValues = true; } if (Types_1.default.isString(query)) { this.importFromString(query, decodeValues); } - else if (Array.isArray(query)) { + else if (Array.isArray(query) || Enumerator_1.isEnumerable(query)) { this.importPairs(query); } else { @@ -49,10 +54,6 @@ var QueryBuilder = (function (_super) { }, deserialize, decodeValues); return this; }; - QueryBuilder.init = function (query, decodeValues) { - if (decodeValues === void 0) { decodeValues = true; } - return new QueryBuilder(query, decodeValues); - }; QueryBuilder.prototype.encode = function (prefixIfNotEmpty) { var entries = []; var keys = this.keys; diff --git a/dist/commonjs/System/Uri/QueryBuilder.js.map b/dist/commonjs/System/Uri/QueryBuilder.js.map index ded2316c..861895a9 100644 --- a/dist/commonjs/System/Uri/QueryBuilder.js.map +++ b/dist/commonjs/System/Uri/QueryBuilder.js.map @@ -1 +1 @@ -{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../source/System/Uri/QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,CAAC;;;;;;AAEb,sBAAiB,UAAU,CAAC,CAAA;AAE5B,IAAY,WAAW,WAAM,eAAe,CAAC,CAAA;AAC7C,2CAAuC,wDAAwD,CAAC,CAAA;AAEhG,IACA,eAAe,GAAO,GAAG,EACzB,mBAAmB,GAAG,GAAG,CAAC;AAO1B;IAC2B,gCAAiE;IAG3F,sBACC,KAAyF,EACzF,YAA2B;QAA3B,4BAA2B,GAA3B,mBAA2B;QAE3B,iBAAO,CAAC;QAER,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,YAAY,CAAC,CAAC;IACtC,CAAC;IAED,kCAAW,GAAX,UACC,KAAyF,EACzF,YAA2B;QAA3B,4BAA2B,GAA3B,mBAA2B;QAE3B,EAAE,CAAA,CAAC,eAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACxB,CAAC;YACA,IAAI,CAAC,gBAAgB,CAAS,KAAK,EAAE,YAAY,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAC7B,CAAC;YACA,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,IAAI,CACJ,CAAC;YACA,IAAI,CAAC,SAAS,CAAmB,KAAK,CAAC,CAAC;QACzC,CAAC;QAED,MAAM,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G7B,GAAG,CAAA,CAAU,UAAsC,EAAtC,KAAA,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,EAAtC,cAAsC,EAAtC,IAAsC,CAAC;gBAAhD,IAAI,CAAC,SAAA;gBAER,OAAO,CAAC,IAAI,CACX,CAAC,GAAG,mBAAmB;sBACrB,WAAW,CAAC,WAAW,CAAoB,CAAC,CAAC,CAAC,CAAC;aAClD;SACD;QAED,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC;cACnD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClC,CAAC;IAED,+BAAQ,GAAR;QAEC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;IACF,mBAAC;AAAD,CAAC,AAtGD,CAC2B,oCAA0B,GAqGpD;AAtGD;8BAsGC,CAAA"} \ No newline at end of file +{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../source/System/Uri/QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,CAAC;;;;;;AAEb,sBAAiB,UAAU,CAAC,CAAA;AAE5B,IAAY,WAAW,WAAM,eAAe,CAAC,CAAA;AAC7C,2CAAuC,wDAAwD,CAAC,CAAA;AAChG,2BAA2B,uCAAuC,CAAC,CAAA;AAGnE,IACA,eAAe,GAAO,GAAG,EACzB,mBAAmB,GAAG,GAAG,CAAC;AAO1B;IAC2B,gCAAiE;IAG3F,sBACC,KAGwE,EACxE,YAA2B;QAA3B,4BAA2B,GAA3B,mBAA2B;QAE3B,iBAAO,CAAC;QAER,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,YAAY,CAAC,CAAC;IACtC,CAAC;IAGM,iBAAI,GAAX,UACC,KAGwE,EACxE,YAA2B;QAA3B,4BAA2B,GAA3B,mBAA2B;QAE3B,MAAM,CAAC,IAAI,YAAY,CAAC,K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AAC,CAAC;QACzB,CAAC,EACD,WAAW,EACX,YAAY,CAAC,CAAC;QAEf,MAAM,CAAC,IAAI,CAAC;IACb,CAAC;IAOD,6BAAM,GAAN,UAAO,gBAAyB;QAE/B,IAAI,OAAO,GAAY,EAAE,CAAC;QAC1B,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,GAAG,CAAA,CAAU,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,CAAC;YAAd,IAAI,CAAC,aAAA;YAER,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAG7B,GAAG,CAAA,CAAU,UAAsC,EAAtC,KAAA,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,EAAtC,cAAsC,EAAtC,IAAsC,CAAC;gBAAhD,IAAI,CAAC,SAAA;gBAER,OAAO,CAAC,IAAI,CACX,CAAC,GAAG,mBAAmB;sBACrB,WAAW,CAAC,WAAW,CAAoB,CAAC,CAAC,CAAC,CAAC;aAClD;SACD;QAED,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC;cACnD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClC,CAAC;IAED,+BAAQ,GAAR;QAEC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;IACF,mBAAC;AAAD,CAAC,AAjHD,CAC2B,oCAA0B,GAgHpD;AAjHD;8BAiHC,CAAA"} \ No newline at end of file diff --git a/dist/es6/System/Collections/Dictionaries/DictionaryBase.js b/dist/es6/System/Collections/Dictionaries/DictionaryBase.js index 49838e05..874ded48 100644 --- a/dist/es6/System/Collections/Dictionaries/DictionaryBase.js +++ b/dist/es6/System/Collections/Dictionaries/DictionaryBase.js @@ -8,6 +8,7 @@ import EnumeratorBase from '../Enumeration/EnumeratorBase'; import ArgumentNullException from '../../Exceptions/ArgumentNullException'; import InvalidOperationException from '../../Exceptions/InvalidOperationException'; import extractKeyValue from '../../KeyValueExtract'; +import { forEach } from '../Enumeration/Enumerator'; const VOID0 = void (0); class DictionaryBase { constructor() { @@ -133,9 +134,11 @@ class DictionaryBase { } importPairs(pairs) { var _ = this; + if (!pairs) + return false; return _.handleUpdate(() => { - var changed = false; - pairs.forEach(pair => extractKeyValue(pair, (key, value) => { + let changed = false; + forEach(pairs, pair => extractKeyValue(pair, (key, value) => { _.setValue(key, value); changed = true; })); diff --git a/dist/es6/System/Collections/Dictionaries/DictionaryBase.js.map b/dist/es6/System/Collections/Dictionaries/DictionaryBase.js.map index ba211867..84c0b351 100644 --- a/dist/es6/System/Collections/Dictionaries/DictionaryBase.js.map +++ b/dist/es6/System/Collections/Dictionaries/DictionaryBase.js.map @@ -1 +1 @@ -{"version":3,"file":"DictionaryBase.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Dictionaries/DictionaryBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,CAAC;OAEN,EAAC,QAAQ,EAAC,MAAM,eAAe;OAC/B,cAAc,MAAM,+BAA+B;OAEnD,qBAAqB,MAAM,wCAAwC;OACnE,yBAAyB,MAAM,4CAA4C;OAC3E,eAAe,MAAM,uBAAuB;AAEnD,MAAM,KAAK,GAAO,KAAI,CAAC,CAAC,CAAC,CAAC;AAG1B;IAMC;QAEC,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,UAAU,KAAa,MAAM,CAAC,IAAI,CAAC,gBAAgB,IAAE,CAAC,CAAC,CAAC,CAAC;IAKnD,cAAc,CAAC,GAAQ,EAAE,KAAY,EAAE,GAAU;QAE1D,EAAE,CAAA,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAC/B,CAAC;YAEA,IAAI,CAAC,GAAG,IAAI,CAAC;YACb,EAAE,CAAA,CAAC,CAA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BAEtC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACvB,OAAO,GAAG,IAAI,CAAC;YAChB,CAAC,CAAC,CACF,CAAC;YACF,MAAM,CAAC,OAAO,CAAC;QAChB,CAAC,CACD,CAAC;IACH,CAAC;IAED,aAAa;QAEZ,IAAI,CAAC,GAAG,IAAI,CAAC;QACb,IAAI,IAAW,EAAE,GAAU,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,IAAI,cAAc,CACxB;YAEC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;YACd,GAAG,GAAG,IAAI,CAAC,MAAM,CAAA;QAClB,CAAC,EAED,CAAC,OAAO;YAEP,OAAM,CAAC,GAAC,GAAG,EACX,CAAC;gBACA,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC7C,EAAE,CAAA,CAAC,KAAK,KAAG,KAAK,CAAC;oBAChB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC7B,CAAC,CACD,CAAC;IACH,CAAC;AAGF,CAAC;AAGD,eAAe,cAAc,CAAC"} \ No newline at end of file +{"version":3,"file":"DictionaryBase.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Dictionaries/DictionaryBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,CAAC;OAEN,EAAC,QAAQ,EAAC,MAAM,eAAe;OAC/B,cAAc,MAAM,+BAA+B;OAEnD,qBAAqB,MAAM,wCAAwC;OACnE,yBAAyB,MAAM,4CAA4C;OAC3E,eAAe,MAAM,uBAAuB;OAC5C,EAAC,OAAO,EAAC,MAAM,2BAA2B;AAEjD,MAAM,KAA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AC;YACvD,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC7B,CAAC,CACD,CAAC;IACH,CAAC;AAGF,CAAC;AAGD,eAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/dist/es6/System/Collections/Enumeration/Enumerator.js b/dist/es6/System/Collections/Enumeration/Enumerator.js index d60cfeb4..f7a0b654 100644 --- a/dist/es6/System/Collections/Enumeration/Enumerator.js +++ b/dist/es6/System/Collections/Enumeration/Enumerator.js @@ -41,12 +41,24 @@ export function from(source) { export function isEnumerable(instance) { return Type.hasMemberOfType(instance, "getEnumerator", Type.FUNCTION); } +export function isEnumerator(instance) { + return Type.hasMemberOfType(instance, "moveNext", Type.FUNCTION); +} export function forEach(e, action) { if (e) { - var index = 0; - while (e.moveNext()) { - if (action(e.current, index++) === false) - break; + if (Array.isArray(e)) { + e.forEach(action); + return; + } + if (isEnumerable(e)) { + e = e.getEnumerator(); + } + if (isEnumerator(e)) { + var index = 0; + while (e.moveNext()) { + if (action(e.current, index++) === false) + break; + } } } } diff --git a/dist/es6/System/Collections/Enumeration/Enumerator.js.map b/dist/es6/System/Collections/Enumeration/Enumerator.js.map index 5d198794..8fb41b0d 100644 --- a/dist/es6/System/Collections/Enumeration/Enumerator.js.map +++ b/dist/es6/System/Collections/Enumeration/Enumerator.js.map @@ -1 +1 @@ -{"version":3,"file":"Enumerator.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Enumeration/Enumerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,CAAC;OAEN,IAAI,MAAM,aAAa;OAEvB,eAAe,MAAM,mBAAmB;OACxC,eAAe,MAAM,mBAAmB;AAG/C;IAEC,IAAI,OAAO;QAEV,MAAM,CAAC,SAAS,CAAC;IAClB,CAAC;IAED,QAAQ;QAEP,MAAM,CAAC,KAAK,CAAC;IACd,CAAC;IAED,KAAK,KAAU,CAAC;IAEhB,OAAO,KAAU,CAAC;AACnB,CAAC;AAED,MAAM,KAA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,CAAC"} \ No newline at end of file +{"version":3,"file":"Enumerator.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Enumeration/Enumerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,CAAC;OAEN,IAAI,MAAM,aAAa;OAEvB,eAAe,MAAM,mBAAmB;OACxC,eAAe,MAAM,mBAAmB;AAG/C;IAEC,IAAI,OAAO;QAEV,MAAM,CAAC,SAAS,CAAC;IAClB,CAAC;IAED,QAAQ;QAEP,MAAM,CAAC,KAAK,CAAC;IACd,CAAC;IAED,KAAK,KAAU,CAAC;IAEhB,OAAO,KAAU,CAAC;AACnB,CAAC;AAED,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;AAGpC,qBAAwB,MAAiC;IAGxD,EAAE,CAAA,CAAC,CAAC,MAAM,CAAC;QACV,MAAM,CAAC,KAAK,CAAC;IAEd,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACxB,MAAM,CAAC,IAAI,eAAe,CAAS,MAAM,CAAC,CAAC;IAG5C,EAAE,CAAA,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAC7B,CAAC;QACA,EAAE,CAAA,CAAC,IAAI,CAAC,WAAW,CAAI,MAAM,CAAC,CAAC,CAC/B,CAAC;YACA,MAAM,CAAC,IAAI,eAAe,CACzB;gBAEC,MAAM,CAAC;oBACN,MAAM,EAAE,MAAM;oBACd,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,OAAO,EAAE,CAAC;oBACV,IAAI,EAAE,CAAC;iBACP,CAAA;YACF,CAAC,CACD,CAAC;QACH,CAAC;QACD,EAAE,CAAA,CAAC,YAAY,CAAI,MAAM,CAAC,CAAC;YAC1B,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAEhC,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACxC,CAAC;AAED,6BAAgC,QAAY;IAE3C,MAAM,CAAC,IAAI,CAAC,eAAe,CAAiB,QAAQ,EAAE,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AACvF,CAAC;AAED,6BAAgC,QAAY;IAE3C,MAAM,CAAC,IAAI,CAAC,eAAe,CAAiB,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAClF,CAAC;AAED,wBACC,CAAmC,EACnC,MAAwC;IAExC,EAAE,CAAA,CAAC,CAAC,CAAC,CACL,CAAC;QACA,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CACpB,CAAC;YACA,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,MAAM,CAAC;QACR,CAAC;QAED,EAAE,CAAA,CAAC,YAAY,CAAI,CAAC,CAAC,CAAC,CACtB,CAAC;YACA,CAAC,GAAoB,CAAE,CAAC,aAAa,EAAE,CAAC;QACzC,CAAC;QAED,EAAE,CAAA,CAAC,YAAY,CAAI,CAAC,CAAC,CAAC,CACtB,CAAC;YACA,IAAI,KAAK,GAAG,CAAC,CAAC;YAEd,OAAM,CAAC,CAAC,QAAQ,EAAE,EAClB,CAAC;gBACA,EAAE,CAAA,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,KAAG,KAAK,CAAC;oBACrC,KAAK,CAAC;YACR,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC"} \ No newline at end of file diff --git a/dist/es6/System/Uri/QueryBuilder.js b/dist/es6/System/Uri/QueryBuilder.js index 201f9b35..aac17ca5 100644 --- a/dist/es6/System/Uri/QueryBuilder.js +++ b/dist/es6/System/Uri/QueryBuilder.js @@ -6,17 +6,21 @@ import Type from '../Types'; import * as QueryParams from './QueryParams'; import OrderedStringKeyDictionary from '../Collections/Dictionaries/OrderedStringKeyDictionary'; +import { isEnumerable } from '../Collections/Enumeration/Enumerator'; const ENTRY_SEPARATOR = "&", KEY_VALUE_SEPARATOR = "="; export default class QueryBuilder extends OrderedStringKeyDictionary { constructor(query, decodeValues = true) { super(); this.importQuery(query, decodeValues); } + static init(query, decodeValues = true) { + return new QueryBuilder(query, decodeValues); + } importQuery(query, decodeValues = true) { if (Type.isString(query)) { this.importFromString(query, decodeValues); } - else if (Array.isArray(query)) { + else if (Array.isArray(query) || isEnumerable(query)) { this.importPairs(query); } else { @@ -39,9 +43,6 @@ export default class QueryBuilder extends OrderedStringKeyDictionary { }, deserialize, decodeValues); return this; } - static init(query, decodeValues = true) { - return new QueryBuilder(query, decodeValues); - } encode(prefixIfNotEmpty) { var entries = []; var keys = this.keys; diff --git a/dist/es6/System/Uri/QueryBuilder.js.map b/dist/es6/System/Uri/QueryBuilder.js.map index a6ca66b0..1dbe8720 100644 --- a/dist/es6/System/Uri/QueryBuilder.js.map +++ b/dist/es6/System/Uri/QueryBuilder.js.map @@ -1 +1 @@ -{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../source/System/Uri/QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,CAAC;OAEN,IAAI,MAAM,UAAU;OAEpB,KAAK,WAAW,MAAM,eAAe;OACrC,0BAA0B,MAAM,wDAAwD;AAE/F,MACA,eAAe,GAAO,GAAG,EACzB,mBAAmB,GAAG,GAAG,CAAC;AAO1B,0CAC2B,0BAA0B;IAGpD,YACC,KAAyF,EACzF,YAAY,GAAW,IAAI;QAE3B,OAAO,CAAC;QAER,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,YAAY,CAAC,CAAC;IACtC,CAAC;IAED,WAAW,CACV,KAAyF,EACzF,YAAY,GAAW,IAAI;QAE3B,EAAE,CAAA,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACxB,CAAC;YACA,IAAI,CAAC,gBAAgB,CAAS,KAAK,EAAE,YAAY,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,EAAE,CAAA,CAAC,KAAK,CAAC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AC,CAClB,CAAC;YACA,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAG7B,GAAG,CAAA,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CACpD,CAAC;gBACA,OAAO,CAAC,IAAI,CACX,CAAC,GAAG,mBAAmB;sBACrB,WAAW,CAAC,WAAW,CAAoB,CAAC,CAAC,CAAC,CAAC;YACnD,CAAC;QACF,CAAC;QAED,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC;cACnD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ;QAEP,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;AACF,CAAC;AAAA"} \ No newline at end of file +{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../source/System/Uri/QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,YAAY,CAAC;OAEN,IAAI,MAAM,UAAU;OAEpB,KAAK,WAAW,MAAM,eAAe;OACrC,0BAA0B,MAAM,wDAAwD;OACxF,EAAC,YAAY,EAAC,MAAM,uCAAuC;AAGlE,MACA,eAAe,GAAO,GAAG,EACzB,mBAAmB,GAAG,GAAG,CAAC;AAO1B,0CAC2B,0BAA0B;IAGpD,YACC,KAGwE,EACxE,YAAY,GAAW,IAAI;QAE3B,OAAO,CAAC;QAER,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,YAAY,CAAC,CAAC;IACtC,CAAC;IAGD,OAAO,IAAI,CACV,KAGwE,EACxE,YAAY,GAAW,IAAI;QAE3B,MAAM,CAAC,IAAI,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,WAAW,CACV,KAGwE,EACxE,YAAY,GAAW,IAAI;Q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,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,GAAG,CAAA,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAClB,CAAC;YACA,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAG7B,GAAG,CAAA,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CACpD,CAAC;gBACA,OAAO,CAAC,IAAI,CACX,CAAC,GAAG,mBAAmB;sBACrB,WAAW,CAAC,WAAW,CAAoB,CAAC,CAAC,CAAC,CAAC;YACnD,CAAC;QACF,CAAC;QAED,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC;cACnD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ;QAEP,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;AACF,CAAC;AAAA"} \ No newline at end of file diff --git a/dist/system/System/Collections/Dictionaries/DictionaryBase.js b/dist/system/System/Collections/Dictionaries/DictionaryBase.js index 85fb3942..427c6767 100644 --- a/dist/system/System/Collections/Dictionaries/DictionaryBase.js +++ b/dist/system/System/Collections/Dictionaries/DictionaryBase.js @@ -2,10 +2,10 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md */ -System.register(['../../Compare', '../Enumeration/EnumeratorBase', '../../Exceptions/ArgumentNullException', '../../Exceptions/InvalidOperationException', '../../KeyValueExtract'], function(exports_1, context_1) { +System.register(['../../Compare', '../Enumeration/EnumeratorBase', '../../Exceptions/ArgumentNullException', '../../Exceptions/InvalidOperationException', '../../KeyValueExtract', '../Enumeration/Enumerator'], function(exports_1, context_1) { 'use strict'; var __moduleName = context_1 && context_1.id; - var Compare_1, EnumeratorBase_1, ArgumentNullException_1, InvalidOperationException_1, KeyValueExtract_1; + var Compare_1, EnumeratorBase_1, ArgumentNullException_1, InvalidOperationException_1, KeyValueExtract_1, Enumerator_1; var VOID0, DictionaryBase; return { setters:[ @@ -23,6 +23,9 @@ System.register(['../../Compare', '../Enumeration/EnumeratorBase', '../../Except }, function (KeyValueExtract_1_1) { KeyValueExtract_1 = KeyValueExtract_1_1; + }, + function (Enumerator_1_1) { + Enumerator_1 = Enumerator_1_1; }], execute: function() { VOID0 = void (0); @@ -174,9 +177,11 @@ System.register(['../../Compare', '../Enumeration/EnumeratorBase', '../../Except }; DictionaryBase.prototype.importPairs = function (pairs) { var _ = this; + if (!pairs) + return false; return _.handleUpdate(function () { var changed = false; - pairs.forEach(function (pair) { return KeyValueExtract_1.default(pair, function (key, value) { + Enumerator_1.forEach(pairs, function (pair) { return KeyValueExtract_1.default(pair, function (key, value) { _.setValue(key, value); changed = true; }); }); diff --git a/dist/system/System/Collections/Dictionaries/DictionaryBase.js.map b/dist/system/System/Collections/Dictionaries/DictionaryBase.js.map index dd62a1ba..46970e53 100644 --- a/dist/system/System/Collections/Dictionaries/DictionaryBase.js.map +++ b/dist/system/System/Collections/Dictionaries/DictionaryBase.js.map @@ -1 +1 @@ -{"version":3,"file":"DictionaryBase.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Dictionaries/DictionaryBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;;IAGH,YAAY,CAAC;;;QASP,KAAK;;;;;;;;;;;;;;;;;;;YAAL,KAAK,GAAO,KAAI,CAAC,CAAC,CAAC,CAAC;YAG1B;gBAMC;oBAEC,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;gBAC3B,CAAC;gBAED,sBAAI,sCAAU;yBAAd,cAA2B,MAAM,CAAC,IAAI,CAAC,gBAAgB,IAAE,CAAC,CAAC,CAAC,CAAC;;;mBAAA;gBAKnD,uCAAc,GAAxB,UAAyB,GAAQ,EAAE,KAAY,EAAE,GAAU;oBAE1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E,CAAA,CAAC,KAAK,KAAG,KAAK,CAAC;gCAChB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;wBACvD,CAAC;wBAED,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;oBAC7B,CAAC,CACD,CAAC;gBACH,CAAC;gBAGF,qBAAC;YAAD,CAAC,AAnRD,IAmRC;YAGD,oBAAe,cAAc,EAAC"} \ No newline at end of file +{"version":3,"file":"DictionaryBase.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Dictionaries/DictionaryBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;;IAGH,YAAY,CAAC;;;QAUP,KAAK;;;;;;;;;;;;;;;;;;;;;;YAAL,KAAK,GAAO,KAAI,CAAC,CAAC,CAAC,CAAC;YAG1B;gBAMC;oBAEC,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;gBAC3B,CAAC;gBAED,sBAAI,sCAAU;yBAAd,cAA2B,MAAM,CAAC,IAAI,CAAC,gBAAgB,IAAE,CAAC,CAAC,CAAC,CAAC;;;mBAAA;gBAKnD,uCAAc,GAAxB,UAAyB,GAAQ,EAAE,KAAY,EAAE,GAAU;oBAE1D,EAAE,CAAA,CAAC,CAAC,kBAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAC/B,CAAC;wBAEA,IAAI,CAAC,GAAG,IAAI,CAAC;wBACb,EAAE,CAAA,CAAC,CAAC,CAAC,cAAc,CAAC;4BACnB,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;wBAGnC,EAAE,CAAA,CAAC,CAAC,CAAC,gBAAgB,IAAE,CAAC,CAAC;4BACxB,CAAC,CAAC,UAAU,EAAE,CAAC;oBAEjB,CAAC;gBACF,CAAC;gBAMO,mCAAU,GAAlB;oBAEC,IAAI,CAAC,GAAG,IAAI,CAAC;o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/Collections/Enumeration/Enumerator.js index 02db5415..a5c51bb5 100644 --- a/dist/system/System/Collections/Enumeration/Enumerator.js +++ b/dist/system/System/Collections/Enumeration/Enumerator.js @@ -33,12 +33,25 @@ System.register(['../../Types', './ArrayEnumerator', './IndexEnumerator'], funct return Types_1.default.hasMemberOfType(instance, "getEnumerator", Types_1.default.FUNCTION); } exports_1("isEnumerable", isEnumerable); + function isEnumerator(instance) { + return Types_1.default.hasMemberOfType(instance, "moveNext", Types_1.default.FUNCTION); + } + exports_1("isEnumerator", isEnumerator); function forEach(e, action) { if (e) { - var index = 0; - while (e.moveNext()) { - if (action(e.current, index++) === false) - break; + if (Array.isArray(e)) { + e.forEach(action); + return; + } + if (isEnumerable(e)) { + e = e.getEnumerator(); + } + if (isEnumerator(e)) { + var index = 0; + while (e.moveNext()) { + if (action(e.current, index++) === false) + break; + } } } } diff --git a/dist/system/System/Collections/Enumeration/Enumerator.js.map b/dist/system/System/Collections/Enumeration/Enumerator.js.map index 7aca77f8..8693d823 100644 --- a/dist/system/System/Collections/Enumeration/Enumerator.js.map +++ b/dist/system/System/Collections/Enumeration/Enumerator.js.map @@ -1 +1 @@ -{"version":3,"file":"Enumerator.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Enumeration/Enumerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;IAMH,YAAY,CAAC;;;yBAyBP,KAAK;IAGX,cAAwB,MAAiC;QAGxD,EAAE,CAAA,CAAC,CAAC,MAAM,CAAC;YACV,MAAM,CAAC,KAAK,CAAC;QAEd,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACxB,MAAM,CAAC,IAAI,yBAAe,CAAS,MAAM,CAAC,CAAC;QAG5C,EAAE,CAAA,CAAC,CAAC,eAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAC7B,CAAC;YACA,EAAE,CAAA,CAAC,eAAI,CAAC,WAAW,CAAI,MAAM,CAAC,CAAC,CAC/B,CAAC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No newline at end of file +{"version":3,"file":"Enumerator.js","sourceRoot":"","sources":["../../../../../source/System/Collections/Enumeration/Enumerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;IAMH,YAAY,CAAC;;;yBAyBP,KAAK;IAGX,cAAwB,MAAiC;QAGxD,EAAE,CAAA,CAAC,CAAC,MAAM,CAAC;YACV,MAAM,CAAC,KAAK,CAAC;QAEd,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACxB,MAAM,CAAC,IAAI,yBAAe,CAAS,MAAM,CAAC,CAAC;QAG5C,EAAE,CAAA,CAAC,CAAC,eAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAC7B,CAAC;YACA,EAAE,CAAA,CAAC,eAAI,CAAC,WAAW,CAAI,MAAM,CAAC,CAAC,CAC/B,CAAC;gBACA,MAAM,CAAC,IAAI,yBAAe,CACzB;oBAEC,MAAM,CAAC;wBACN,MAAM,EAAE,MAAM;wBACd,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,OAAO,EAAE,CAAC;wBACV,IAAI,EAAE,CAAC;qBACP,CAAA;gBACF,CAAC,CACD,CAAC;YACH,CAAC;YACD,EAAE,CAAA,CAAC,YAAY,CAAI,MAAM,CAAC,CAAC;gBAC1B,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;QAEhC,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACxC,CAAC;IAhCD,uBAgCC,CAAA;IAED,sBAAgC,QAAY;QAE3C,MAAM,CAAC,eAAI,CAAC,eAAe,CAAiB,QAAQ,EAAE,eAAe,EAAE,eAAI,CAAC,QAAQ,CAAC,CAAC;IACvF,CAAC;IAHD,uCAGC,CAAA;IAED,sBAAgC,QAAY;QAE3C,MAAM,CAAC,eAAI,CAAC,eAAe,CAAiB,QAAQ,EAAE,UAAU,EAAE,eAAI,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAHD,uCAGC,CAAA;IAED,iBACC,CAAmC,EACnC,MAAwC;QAExC,EAAE,CAAA,CAAC,CAAC,CAAC,CACL,CAAC;YACA,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CACpB,CAAC;gBACA,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,MAAM,CAAC;YACR,CAAC;YAED,EAAE,CAAA,CAAC,YAAY,CAAI,CAAC,CAAC,CAAC,CACtB,CAAC;gBACA,CAAC,GAAoB,CAAE,CAAC,aAAa,EAAE,CAAC;YACzC,CAAC;YAED,EAAE,CAAA,CAAC,YAAY,CAAI,CAAC,CAAC,CAAC,CACtB,CAAC;gBACA,IAAI,KAAK,GAAG,CAAC,CAAC;gBAEd,OAAM,CAAC,CAAC,QAAQ,EAAE,EAClB,CAAC;oBACA,EAAE,CAAA,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,KAAG,KAAK,CAAC;wBACrC,KAAK,CAAC;gBACR,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IA5BD,6BA4BC,CAAA;;;;;;;;;;;;;YA5FD;gBAAA;gBAeA,CAAC;gBAbA,sBAAI,oCAAO;yBAAX;wBAEC,MAAM,CAAC,SAAS,CAAC;oBAClB,CAAC;;;mBAAA;gBAED,kCAAQ,GAAR;oBAEC,MAAM,CAAC,KAAK,CAAC;gBACd,CAAC;gBAED,+BAAK,GAAL,cAAe,CAAC;gBAEhB,iCAAO,GAAP,cAAiB,CAAC;gBACnB,sBAAC;YAAD,CAAC,AAfD,IAeC;YAEK,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/system/System/Uri/QueryBuilder.js b/dist/system/System/Uri/QueryBuilder.js index 10800cca..41d84704 100644 --- a/dist/system/System/Uri/QueryBuilder.js +++ b/dist/system/System/Uri/QueryBuilder.js @@ -2,7 +2,7 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md */ -System.register(['../Types', './QueryParams', '../Collections/Dictionaries/OrderedStringKeyDictionary'], function(exports_1, context_1) { +System.register(['../Types', './QueryParams', '../Collections/Dictionaries/OrderedStringKeyDictionary', '../Collections/Enumeration/Enumerator'], function(exports_1, context_1) { 'use strict'; var __moduleName = context_1 && context_1.id; var __extends = (this && this.__extends) || function (d, b) { @@ -10,7 +10,7 @@ System.register(['../Types', './QueryParams', '../Collections/Dictionaries/Order function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - var Types_1, QueryParams, OrderedStringKeyDictionary_1; + var Types_1, QueryParams, OrderedStringKeyDictionary_1, Enumerator_1; var ENTRY_SEPARATOR, KEY_VALUE_SEPARATOR, QueryBuilder; return { setters:[ @@ -22,6 +22,9 @@ System.register(['../Types', './QueryParams', '../Collections/Dictionaries/Order }, function (OrderedStringKeyDictionary_1_1) { OrderedStringKeyDictionary_1 = OrderedStringKeyDictionary_1_1; + }, + function (Enumerator_1_1) { + Enumerator_1 = Enumerator_1_1; }], execute: function() { ENTRY_SEPARATOR = "&", KEY_VALUE_SEPARATOR = "="; @@ -32,12 +35,16 @@ System.register(['../Types', './QueryParams', '../Collections/Dictionaries/Order _super.call(this); this.importQuery(query, decodeValues); } + QueryBuilder.init = function (query, decodeValues) { + if (decodeValues === void 0) { decodeValues = true; } + return new QueryBuilder(query, decodeValues); + }; QueryBuilder.prototype.importQuery = function (query, decodeValues) { if (decodeValues === void 0) { decodeValues = true; } if (Types_1.default.isString(query)) { this.importFromString(query, decodeValues); } - else if (Array.isArray(query)) { + else if (Array.isArray(query) || Enumerator_1.isEnumerable(query)) { this.importPairs(query); } else { @@ -62,10 +69,6 @@ System.register(['../Types', './QueryParams', '../Collections/Dictionaries/Order }, deserialize, decodeValues); return this; }; - QueryBuilder.init = function (query, decodeValues) { - if (decodeValues === void 0) { decodeValues = true; } - return new QueryBuilder(query, decodeValues); - }; QueryBuilder.prototype.encode = function (prefixIfNotEmpty) { var entries = []; var keys = this.keys; diff --git a/dist/system/System/Uri/QueryBuilder.js.map b/dist/system/System/Uri/QueryBuilder.js.map index c7bf15e0..3843d72b 100644 --- a/dist/system/System/Uri/QueryBuilder.js.map +++ b/dist/system/System/Uri/QueryBuilder.js.map @@ -1 +1 @@ -{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../source/System/Uri/QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;;IAMH,YAAY,CAAC;;;;;;;;QAQb,eAAe,EACf,mBAAmB;;;;;;;;;;;;;YADnB,eAAe,GAAO,GAAG,EACzB,mBAAmB,GAAG,GAAG,CAAC;YAO1B;gBAC2B,gCAAiE;gBAG3F,sBACC,KAAyF,EACzF,YAA2B;oBAA3B,4BAA2B,GAA3B,mBAA2B;oBAE3B,iBAAO,CAAC;oBAER,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,YAAY,CAAC,CAAC;gBACtC,CAAC;gBAED,kCAAW,GAAX,UACC,KAAyF,EACzF,YAA2B;oBAA3B,4BAA2B,GAA3B,mBAA2B;oBAE3B,EAAE,CAAA,CAAC,eAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACxB,CAAC;wBACA,IAAI,CAAC,gBAAgB,CAAS,KAAK,EAAE,YAAY,CAAC,CAAC;oBACpD,CAAC;oBACD,IAAI,CAAC,EAAE,CAAA,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAC7B,CAAC;wBACA,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBACzB,CAAC;oBACD,IAAI,CACJ,CAAC;wBACA,IAAI,CAAC,SAAS,CAAmB,KAAK,CAAC,CAAC;oBACzC,CAAC;oBAED,MAAM,CAAC,IAAI,CAAC;gBACb,CAAC;gBASD,uCAAgB,GAAhB,UACC,MAAa,EACb,WAA0B,EAC1B,YAA2B;oBAD3B,2BAA0B,GAA1B,kBAA0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GAAG,CAAC,KAAK,CAAC,EAAtC,cAAsC,EAAtC,IAAsC,CAAC;4BAAhD,IAAI,CAAC,SAAA;4BAER,OAAO,CAAC,IAAI,CACX,CAAC,GAAG,mBAAmB;kCACrB,WAAW,CAAC,WAAW,CAAoB,CAAC,CAAC,CAAC,CAAC;yBAClD;qBACD;oBAED,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC;0BACnD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAClC,CAAC;gBAED,+BAAQ,GAAR;oBAEC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACtB,CAAC;gBACF,mBAAC;YAAD,CAAC,AAtGD,CAC2B,oCAA0B,GAqGpD;YAtGD,kCAsGC,CAAA"} \ No newline at end of file +{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["../../../../source/System/Uri/QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;;IAMH,YAAY,CAAC;;;;;;;;QAUb,eAAe,EACf,mBAAmB;;;;;;;;;;;;;;;;YADnB,eAAe,GAAO,GAAG,EACzB,mBAAmB,GAAG,GAAG,CAAC;YAO1B;gBAC2B,gCAAiE;gBAG3F,sBACC,KAGwE,EACxE,YAA2B;oBAA3B,4BAA2B,GAA3B,mBAA2B;oBAE3B,iBAAO,CAAC;oBAER,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,YAAY,CAAC,CAAC;gBACtC,CAAC;gBAGM,iBAAI,GAAX,UACC,KAGwE,EACxE,YAA2B;oBAA3B,4BAA2B,GAA3B,mBAA2B;oBAE3B,MAAM,CAAC,IAAI,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;gBAC9C,CAAC;gBAED,kCAAW,GAAX,UACC,KAGwE,EACxE,YAA2B;oBAA3B,4BAA2B,GAA3B,mBAA2B;oBAE3B,EAAE,CAAA,CAAC,eAAI,CAAC,QAAQ,CAAC,KAA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,OAAO,GAAY,EAAE,CAAC;oBAC1B,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;oBACrB,GAAG,CAAA,CAAU,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,CAAC;wBAAd,IAAI,CAAC,aAAA;wBAER,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;wBAG7B,GAAG,CAAA,CAAU,UAAsC,EAAtC,KAAA,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,EAAtC,cAAsC,EAAtC,IAAsC,CAAC;4BAAhD,IAAI,CAAC,SAAA;4BAER,OAAO,CAAC,IAAI,CACX,CAAC,GAAG,mBAAmB;kCACrB,WAAW,CAAC,WAAW,CAAoB,CAAC,CAAC,CAAC,CAAC;yBAClD;qBACD;oBAED,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC;0BACnD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAClC,CAAC;gBAED,+BAAQ,GAAR;oBAEC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACtB,CAAC;gBACF,mBAAC;YAAD,CAAC,AAjHD,CAC2B,oCAA0B,GAgHpD;YAjHD,kCAiHC,CAAA"} \ No newline at end of file diff --git a/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js b/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js index 3b6414c8..3780716a 100644 --- a/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js +++ b/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js @@ -2,5 +2,5 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md */ -!function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define(["require","exports","../../Compare","../Enumeration/EnumeratorBase","../../Exceptions/ArgumentNullException","../../Exceptions/InvalidOperationException","../../KeyValueExtract"],e)}(function(e,t){"use strict";var n=e("../../Compare"),r=e("../Enumeration/EnumeratorBase"),o=e("../../Exceptions/ArgumentNullException"),u=e("../../Exceptions/InvalidOperationException"),a=e("../../KeyValueExtract"),i=void 0,p=function(){function e(){this._updateRecursion=0}return Object.defineProperty(e.prototype,"isUpdating",{get:function(){return 0!=this._updateRecursion},enumerable:!0,configurable:!0}),e.prototype._onValueUpdate=function(e,t,r){if(!n.areEqual(t,r,!0)){var o=this;o.onValueChanged&&o.onValueChanged(e,t,r),0==o._updateRecursion&&o._onUpdated()}},e.prototype._onUpdated=function(){var e=this;e.onUpdated&&e.onUpdated()},e.prototype.handleUpdate=function(e){var t,n=this;if(e){n._updateRecursion++;try{t=e()}finally{n._updateRecursion--}}else t=0==n._updateRecursion;return t&&0==n._updateRecursion&&n._onUpdated(),t},Object.defineProperty(e.prototype,"isReadOnly",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this.getCount()},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this;if(!e)throw new o["default"]("item","Dictionaries must use a valid key/value pair. '"+e+"' is not allowed.");a["default"](e,function(e,n){return t.addByKeyValue(e,n)})},e.prototype.clear=function(){var e=this,t=e.keys,n=t.length;return n&&e.handleUpdate(function(){return t.forEach(function(t){e.removeByKey(t)}),!0}),0!=e.count&&console.warn("Dictionary clear() results in mismatched count."),n},e.prototype.contains=function(e){var t=this;return e?a["default"](e,function(e,r){var o=t.getValue(e);return n.areEqual(r,o)}):!1},e.prototype.copyTo=function(e,t){if(void 0===t&&(t=0),!e)throw new o["default"]("array");for(var n=this.getEnumerator();n.moveNext();)e[t++]=n.current;return e},e.prototype.toArray=function(){return this.copyTo([],0)},e.prototype.remove=function(e){var t=this;return e?a["default"](e,function(e,r){var o=t.getValue(e);return n.areEqual(r,o)&&t.removeByKey(e)?1:0}):0},Object.defineProperty(e.prototype,"keys",{get:function(){return this.getKeys()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this.getValues()},enumerable:!0,configurable:!0}),e.prototype.addByKeyValue=function(e,t){var n=this;if(n.containsKey(e)){var r=new u["default"]("Adding a key/value when the key already exists.");throw r.data.key=e,r.data.value=t,r}n.setValue(e,t)},e.prototype.containsKey=function(e){var t=this.getValue(e);return t!==i},e.prototype.containsValue=function(e){for(var t=this.getEnumerator(),r=n.areEqual;t.moveNext();)if(r(t.current,e,!0))return t.dispose(),!0;return!1},e.prototype.removeByKey=function(e){return this.setValue(e,void 0)},e.prototype.removeByValue=function(e){var t=this,r=0,o=n.areEqual;return t.keys.forEach(function(n){o(t.getValue(n),e,!0)&&(t.removeByKey(n),++r)}),r},e.prototype.importPairs=function(e){var t=this;return t.handleUpdate(function(){var n=!1;return e.forEach(function(e){return a["default"](e,function(e,r){t.setValue(e,r),n=!0})}),n})},e.prototype.getEnumerator=function(){var e,t,n=this,o=0;return new r["default"](function(){e=n.keys,t=e.length},function(r){for(;t>o;){var u=e[o++],a=n.getValue(u);if(a!==i)return r.yieldReturn({key:u,value:a})}return r.yieldBreak()})},e}();Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=p}); +!function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define(["require","exports","../../Compare","../Enumeration/EnumeratorBase","../../Exceptions/ArgumentNullException","../../Exceptions/InvalidOperationException","../../KeyValueExtract","../Enumeration/Enumerator"],e)}(function(e,t){"use strict";var n=e("../../Compare"),r=e("../Enumeration/EnumeratorBase"),o=e("../../Exceptions/ArgumentNullException"),u=e("../../Exceptions/InvalidOperationException"),a=e("../../KeyValueExtract"),i=e("../Enumeration/Enumerator"),p=void 0,c=function(){function e(){this._updateRecursion=0}return Object.defineProperty(e.prototype,"isUpdating",{get:function(){return 0!=this._updateRecursion},enumerable:!0,configurable:!0}),e.prototype._onValueUpdate=function(e,t,r){if(!n.areEqual(t,r,!0)){var o=this;o.onValueChanged&&o.onValueChanged(e,t,r),0==o._updateRecursion&&o._onUpdated()}},e.prototype._onUpdated=function(){var e=this;e.onUpdated&&e.onUpdated()},e.prototype.handleUpdate=function(e){var t,n=this;if(e){n._updateRecursion++;try{t=e()}finally{n._updateRecursion--}}else t=0==n._updateRecursion;return t&&0==n._updateRecursion&&n._onUpdated(),t},Object.defineProperty(e.prototype,"isReadOnly",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this.getCount()},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this;if(!e)throw new o["default"]("item","Dictionaries must use a valid key/value pair. '"+e+"' is not allowed.");a["default"](e,function(e,n){return t.addByKeyValue(e,n)})},e.prototype.clear=function(){var e=this,t=e.keys,n=t.length;return n&&e.handleUpdate(function(){return t.forEach(function(t){e.removeByKey(t)}),!0}),0!=e.count&&console.warn("Dictionary clear() results in mismatched count."),n},e.prototype.contains=function(e){var t=this;return e?a["default"](e,function(e,r){var o=t.getValue(e);return n.areEqual(r,o)}):!1},e.prototype.copyTo=function(e,t){if(void 0===t&&(t=0),!e)throw new o["default"]("array");for(var n=this.getEnumerator();n.moveNext();)e[t++]=n.current;return e},e.prototype.toArray=function(){return this.copyTo([],0)},e.prototype.remove=function(e){var t=this;return e?a["default"](e,function(e,r){var o=t.getValue(e);return n.areEqual(r,o)&&t.removeByKey(e)?1:0}):0},Object.defineProperty(e.prototype,"keys",{get:function(){return this.getKeys()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this.getValues()},enumerable:!0,configurable:!0}),e.prototype.addByKeyValue=function(e,t){var n=this;if(n.containsKey(e)){var r=new u["default"]("Adding a key/value when the key already exists.");throw r.data.key=e,r.data.value=t,r}n.setValue(e,t)},e.prototype.containsKey=function(e){var t=this.getValue(e);return t!==p},e.prototype.containsValue=function(e){for(var t=this.getEnumerator(),r=n.areEqual;t.moveNext();)if(r(t.current,e,!0))return t.dispose(),!0;return!1},e.prototype.removeByKey=function(e){return this.setValue(e,void 0)},e.prototype.removeByValue=function(e){var t=this,r=0,o=n.areEqual;return t.keys.forEach(function(n){o(t.getValue(n),e,!0)&&(t.removeByKey(n),++r)}),r},e.prototype.importPairs=function(e){var t=this;return e?t.handleUpdate(function(){var n=!1;return i.forEach(e,function(e){return a["default"](e,function(e,r){t.setValue(e,r),n=!0})}),n}):!1},e.prototype.getEnumerator=function(){var e,t,n=this,o=0;return new r["default"](function(){e=n.keys,t=e.length},function(r){for(;t>o;){var u=e[o++],a=n.getValue(u);if(a!==p)return r.yieldReturn({key:u,value:a})}return r.yieldBreak()})},e}();Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=c}); //# sourceMappingURL=DictionaryBase.js.map diff --git a/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js.map b/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js.map index fa18db1e..fe71947e 100644 --- a/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js.map +++ b/dist/umd.min/System/Collections/Dictionaries/DictionaryBase.js.map @@ -1 +1 @@ -{"version":3,"sources":["System/Collections/Dictionaries/DictionaryBase.js","System/Collections/Dictionaries/DictionaryBase.ts"],"names":["factory","module","exports","v","require","undefined","define","amd","Compare_1","EnumeratorBase_1","ArgumentNullException_1","InvalidOperationException_1","KeyValueExtract_1","VOID0","DictionaryBase","DictionaryBase.constructor","get","DictionaryBase.isUpdating","enumerable","configurable","DictionaryBase._onValueUpdate","DictionaryBase._onUpdated","DictionaryBase.handleUpdate","DictionaryBase.isReadOnly","DictionaryBase.count","DictionaryBase.add","DictionaryBase.clear","DictionaryBase.contains","DictionaryBase.copyTo","DictionaryBase.toArray","DictionaryBase.remove","DictionaryBase.keys","DictionaryBase.values","DictionaryBase.addByKeyValue","DictionaryBase.containsKey","DictionaryBase.containsValue","DictionaryBase.removeByKey","Dictionary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,OAPAA,GAAMA,QACLA,SAAAA,GAAMA,MAAAA,GAAAA,WAAgBA,EAAMA,SAACA,EAAKA,GAEjCA,EAAEA,SAASA,EAAKA,GAChBA,GAAUA,MAGLA,KAKVxB,EAAAA,UAAAA,cAAAA,WAECyB,GACIA,GAAaA,EADbA,EAAIA,KACqBA,EAAIA,CACjCA,OAAOA,IAAIA,GAAAA,WACVA,WAECA,EAAOA,EAAEA,KACTA,EAAMA,EAAKA,QAGZA,SAACA,GAEAA,KAAQA,EAAFA,GACNA,CACCA,GAAIA,GAAMA,EAAKA,KAAMA,EAAQA,EAAEA,SAASA,EACxCA,IAAGA,IAAQA,EACVA,MAAOA,GAAQA,aAAaA,IAAKA,EAAKA,MAAOA,IAG/CA,MAAOA,GAAQA,gBAMnBzB,IAGA0B,QAAAC,eAAAvC,EAAA,cAAAwC,OAAA,IDtGIxC,EAAAA,WCsGWY","file":"System/Collections/Dictionaries/DictionaryBase.js","sourcesContent":["/*!\n * @author electricessence / https://github.com/electricessence/\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\n */\n(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define([\"require\", \"exports\", '../../Compare', '../Enumeration/EnumeratorBase', '../../Exceptions/ArgumentNullException', '../../Exceptions/InvalidOperationException', '../../KeyValueExtract'], factory);\n }\n})(function (require, exports) {\n 'use strict';\n var Compare_1 = require('../../Compare');\n var EnumeratorBase_1 = require('../Enumeration/EnumeratorBase');\n var ArgumentNullException_1 = require('../../Exceptions/ArgumentNullException');\n var InvalidOperationException_1 = require('../../Exceptions/InvalidOperationException');\n var KeyValueExtract_1 = require('../../KeyValueExtract');\n var VOID0 = void (0);\n var DictionaryBase = (function () {\n function DictionaryBase() {\n this._updateRecursion = 0;\n }\n Object.defineProperty(DictionaryBase.prototype, \"isUpdating\", {\n get: function () { return this._updateRecursion != 0; },\n enumerable: true,\n configurable: true\n });\n DictionaryBase.prototype._onValueUpdate = function (key, value, old) {\n if (!Compare_1.areEqual(value, old, true)) {\n var _ = this;\n if (_.onValueChanged)\n _.onValueChanged(key, value, old);\n if (_._updateRecursion == 0)\n _._onUpdated();\n }\n };\n DictionaryBase.prototype._onUpdated = function () {\n var _ = this;\n if (_.onUpdated)\n _.onUpdated();\n };\n DictionaryBase.prototype.handleUpdate = function (closure) {\n var _ = this, result;\n if (closure) {\n _._updateRecursion++;\n try {\n result = closure();\n }\n finally {\n _._updateRecursion--;\n }\n }\n else\n result = _._updateRecursion == 0;\n if (result && _._updateRecursion == 0)\n _._onUpdated();\n return result;\n };\n Object.defineProperty(DictionaryBase.prototype, \"isReadOnly\", {\n get: function () { return false; },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(DictionaryBase.prototype, \"count\", {\n get: function () { return this.getCount(); },\n enumerable: true,\n configurable: true\n });\n DictionaryBase.prototype.add = function (item) {\n var _this = this;\n if (!item)\n throw new ArgumentNullException_1.default('item', 'Dictionaries must use a valid key/value pair. \\'' + item + '\\' is not allowed.');\n KeyValueExtract_1.default(item, function (key, value) { return _this.addByKeyValue(key, value); });\n };\n DictionaryBase.prototype.clear = function () {\n var _ = this, keys = _.keys, count = keys.length;\n if (count)\n _.handleUpdate(function () {\n keys.forEach(function (key) { _.removeByKey(key); });\n return true;\n });\n if (_.count != 0)\n console.warn(\"Dictionary clear() results in mismatched count.\");\n return count;\n };\n DictionaryBase.prototype.contains = function (item) {\n var _this = this;\n if (!item)\n return false;\n return KeyValueExtract_1.default(item, function (key, value) {\n var v = _this.getValue(key);\n return Compare_1.areEqual(value, v);\n });\n };\n DictionaryBase.prototype.copyTo = function (array, index) {\n if (index === void 0) { index = 0; }\n if (!array)\n throw new ArgumentNullException_1.default('array');\n var e = this.getEnumerator();\n while (e.moveNext()) {\n array[index++] = e.current;\n }\n return array;\n };\n DictionaryBase.prototype.toArray = function () {\n return this.copyTo([], 0);\n };\n DictionaryBase.prototype.remove = function (item) {\n var _this = this;\n if (!item)\n return 0;\n return KeyValueExtract_1.default(item, function (key, value) {\n var v = _this.getValue(key);\n return (Compare_1.areEqual(value, v) && _this.removeByKey(key))\n ? 1 : 0;\n });\n };\n Object.defineProperty(DictionaryBase.prototype, \"keys\", {\n get: function () { return this.getKeys(); },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(DictionaryBase.prototype, \"values\", {\n get: function () { return this.getValues(); },\n enumerable: true,\n configurable: true\n });\n DictionaryBase.prototype.addByKeyValue = function (key, value) {\n var _ = this;\n if (_.containsKey(key)) {\n var ex = new InvalidOperationException_1.default(\"Adding a key/value when the key already exists.\");\n ex.data['key'] = key;\n ex.data['value'] = value;\n throw ex;\n }\n _.setValue(key, value);\n };\n DictionaryBase.prototype.containsKey = function (key) {\n var value = this.getValue(key);\n return value !== VOID0;\n };\n DictionaryBase.prototype.containsValue = function (value) {\n var e = this.getEnumerator(), equal = Compare_1.areEqual;\n while (e.moveNext()) {\n if (equal(e.current, value, true)) {\n e.dispose();\n return true;\n }\n }\n return false;\n };\n DictionaryBase.prototype.removeByKey = function (key) {\n return this.setValue(key, undefined);\n };\n DictionaryBase.prototype.removeByValue = function (value) {\n var _ = this, count = 0, equal = Compare_1.areEqual;\n _.keys.forEach(function (key) {\n if (equal(_.getValue(key), value, true)) {\n _.removeByKey(key);\n ++count;\n }\n });\n return count;\n };\n DictionaryBase.prototype.importPairs = function (pairs) {\n var _ = this;\n return _.handleUpdate(function () {\n var changed = false;\n pairs.forEach(function (pair) { return KeyValueExtract_1.default(pair, function (key, value) {\n _.setValue(key, value);\n changed = true;\n }); });\n return changed;\n });\n };\n DictionaryBase.prototype.getEnumerator = function () {\n var _ = this;\n var keys, len, i = 0;\n return new EnumeratorBase_1.default(function () {\n keys = _.keys;\n len = keys.length;\n }, function (yielder) {\n while (i < len) {\n var key = keys[i++], value = _.getValue(key);\n if (value !== VOID0)\n return yielder.yieldReturn({ key: key, value: value });\n }\n return yielder.yieldBreak();\n });\n };\n return DictionaryBase;\n })();\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.default = DictionaryBase;\n});\n","/*!\r\n * @author electricessence / https://github.com/electricessence/\r\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\r\n */\r\n\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport {areEqual} from '../../Compare';\r\nimport EnumeratorBase from '../Enumeration/EnumeratorBase';\r\nimport ArgumentException from '../../Exceptions/ArgumentException';\r\nimport ArgumentNullException from '../../Exceptions/ArgumentNullException';\r\nimport InvalidOperationException from '../../Exceptions/InvalidOperationException';\r\nimport extractKeyValue from '../../KeyValueExtract';\r\n\r\nconst VOID0:any = void(0);\r\n\r\n// Design Note: Should DictionaryAbstractBase be IDisposable?\r\nabstract class DictionaryBase\r\nimplements IDictionary\r\n{\r\n\t// This allows for batch updates in order to improve the efficiency of responsive systems.\r\n\tprivate _updateRecursion:number;\r\n\r\n\tconstructor()\r\n\t{\r\n\t\tthis._updateRecursion = 0;\r\n\t}\r\n\r\n\tget isUpdating():boolean { return this._updateRecursion!=0; }\r\n\r\n\t// Could implement an event dispatcher pattern here easily...\r\n\tonValueChanged:(key:TKey, value:TValue, old:TValue) => void;\r\n\r\n\tprotected _onValueUpdate(key:TKey, value:TValue, old:TValue):void\r\n\t{\r\n\t\tif(!areEqual(value, old, true))\r\n\t\t{\r\n\r\n\t\t\tvar _ = this;\r\n\t\t\tif(_.onValueChanged)\r\n\t\t\t\t_.onValueChanged(key, value, old);\r\n\r\n\t\t\t// If the update recursion is zero, then we are finished with updates.\r\n\t\t\tif(_._updateRecursion==0)\r\n\t\t\t\t_._onUpdated();\r\n\r\n\t\t}\r\n\t}\r\n\r\n\t// Listening to every value update can get noisy. Here we allow for batch update signaling.\r\n\t// The consumer of this class can also wire up their own event system.\r\n\tonUpdated:() => void;\r\n\r\n\tprivate _onUpdated():void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.onUpdated)\r\n\t\t\t_.onUpdated();\r\n\t}\r\n\r\n\t// Takes a closure that if returning true will propagate an update signal.\r\n\thandleUpdate(closure?:() => boolean):boolean\r\n\t{\r\n\t\tvar _ = this, result:boolean;\r\n\t\tif(closure)\r\n\t\t{\r\n\t\t\t_._updateRecursion++;\r\n\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tresult = closure();\r\n\t\t\t}\r\n\t\t\tfinally\r\n\t\t\t{\r\n\t\t\t\t_._updateRecursion--;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t\tresult = _._updateRecursion==0;\r\n\r\n\t\tif(result && _._updateRecursion==0)\r\n\t\t\t_._onUpdated();\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// ICollection\r\n\t/////////////////////////////////////////\r\n\tget isReadOnly():boolean { return false; }\r\n\r\n\tprotected abstract getCount():number;\r\n\r\n\tget count():number { return this.getCount(); }\r\n\r\n\tadd(item:KeyValuePair):void\r\n\t{\r\n\t\tif(!item)\r\n\t\t\tthrow new ArgumentNullException(\r\n\t\t\t\t'item', 'Dictionaries must use a valid key/value pair. \\'' + item + '\\' is not allowed.'\r\n\t\t\t);\r\n\r\n\t\textractKeyValue(item,\r\n\t\t\t(key, value)=>this.addByKeyValue(key, value));\r\n\t}\r\n\r\n\tclear():number\r\n\t{\r\n\t\tvar _ = this, keys = _.keys, count = keys.length;\r\n\r\n\t\tif(count)\r\n\t\t\t_.handleUpdate(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\tkeys.forEach(key=> { _.removeByKey(key); });\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t);\r\n\r\n\t\tif(_.count!=0) // After they've all been removed, then should be zero.\r\n\t\t\tconsole.warn(\"Dictionary clear() results in mismatched count.\");\r\n\r\n\t\treturn count;\r\n\t}\r\n\r\n\tcontains(item:KeyValuePair):boolean\r\n\t{\r\n\t\t// Should never have a null object in the collection.\r\n\t\tif(!item) return false;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn areEqual(value, v);\r\n\t\t\t});\r\n\r\n\t}\r\n\r\n\tcopyTo(array:IKeyValuePair[], index:number = 0):IKeyValuePair[]\r\n\t{\r\n\t\tif(!array) throw new ArgumentNullException('array');\r\n\r\n\t\t// This is a generic implementation that will work for all derived classes.\r\n\t\t// It can be overridden and optimized.\r\n\t\tvar e = this.getEnumerator();\r\n\t\twhile(e.moveNext()) // Disposes when finished.\r\n\t\t{\r\n\t\t\tarray[index++] = e.current;\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\r\n\ttoArray():IKeyValuePair[]\r\n\t{\r\n\t\treturn this.copyTo([], 0);\r\n\t}\r\n\r\n\tremove(item:IKeyValuePair|[TKey,TValue]):number\r\n\t{\r\n\t\tif(!item) return 0;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn (areEqual(value, v) && this.removeByKey(key))\r\n\t\t\t\t\t? 1 : 0;\r\n\t\t\t});\r\n\r\n\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// IDictionary\r\n\t/////////////////////////////////////////\r\n\r\n\tprotected abstract getKeys():TKey[];\r\n\r\n\tget keys():TKey[] { return this.getKeys(); }\r\n\r\n\tprotected abstract getValues():TValue[];\r\n\r\n\tget values():TValue[] { return this.getValues(); }\r\n\r\n\r\n\taddByKeyValue(key:TKey, value:TValue):void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.containsKey(key))\r\n\t\t{\r\n\t\t\tvar ex = new InvalidOperationException(\"Adding a key/value when the key already exists.\");\r\n\t\t\tex.data['key'] = key;\r\n\t\t\tex.data['value'] = value;\r\n\t\t\tthrow ex;\r\n\t\t}\r\n\r\n\t\t_.setValue(key, value);\r\n\t}\r\n\r\n\tabstract getValue(key:TKey):TValue;\r\n\r\n\tabstract setValue(key:TKey, value:TValue):boolean;\r\n\r\n\tcontainsKey(key:TKey):boolean\r\n\t{\r\n\t\tvar value = this.getValue(key);\r\n\t\treturn value!==VOID0;\r\n\t}\r\n\r\n\tcontainsValue(value:TValue):boolean\r\n\t{\r\n\t\tvar e = this.getEnumerator(), equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\r\n\t\twhile(e.moveNext())\r\n\t\t{\r\n\t\t\tif(equal(e.current, value, true))\r\n\t\t\t{\r\n\t\t\t\te.dispose();\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\tremoveByKey(key:TKey):boolean\r\n\t{\r\n\t\treturn this.setValue(key, undefined);\r\n\t}\r\n\r\n\tremoveByValue(value:TValue):number\r\n\t{\r\n\t\tvar _ = this, count = 0, equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\t\t_.keys.forEach(key=>\r\n\t\t{\r\n\t\t\tif(equal(_.getValue(key), value, true))\r\n\t\t\t{\r\n\t\t\t\t_.removeByKey(key);\r\n\t\t\t\t++count;\r\n\t\t\t}\r\n\t\t});\r\n\t\treturn count;\r\n\t}\r\n\r\n\timportPairs(pairs:KeyValuePair[]):boolean\r\n\t{\r\n\t\tvar _ = this;\r\n\t\treturn _.handleUpdate(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tvar changed:boolean = false;\r\n\t\t\t\tpairs.forEach(\r\n\t\t\t\t\tpair=>extractKeyValue(pair, (key, value)=>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t\t\t\tchanged = true;\r\n\t\t\t\t\t})\r\n\t\t\t\t);\r\n\t\t\t\treturn changed;\r\n\t\t\t}\r\n\t\t);\r\n\t}\r\n\r\n\tgetEnumerator():IEnumerator>\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tvar keys:TKey[], len:number, i = 0;\r\n\t\treturn new EnumeratorBase>(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tkeys = _.keys;\r\n\t\t\t\tlen = keys.length\r\n\t\t\t},\r\n\r\n\t\t\t(yielder)=>\r\n\t\t\t{\r\n\t\t\t\twhile(i\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport {areEqual} from '../../Compare';\r\nimport EnumeratorBase from '../Enumeration/EnumeratorBase';\r\nimport ArgumentException from '../../Exceptions/ArgumentException';\r\nimport ArgumentNullException from '../../Exceptions/ArgumentNullException';\r\nimport InvalidOperationException from '../../Exceptions/InvalidOperationException';\r\nimport extractKeyValue from '../../KeyValueExtract';\r\nimport {forEach} from '../Enumeration/Enumerator';\r\n\r\nconst VOID0:any = void(0);\r\n\r\n// Design Note: Should DictionaryAbstractBase be IDisposable?\r\nabstract class DictionaryBase\r\nimplements IDictionary\r\n{\r\n\t// This allows for batch updates in order to improve the efficiency of responsive systems.\r\n\tprivate _updateRecursion:number;\r\n\r\n\tconstructor()\r\n\t{\r\n\t\tthis._updateRecursion = 0;\r\n\t}\r\n\r\n\tget isUpdating():boolean { return this._updateRecursion!=0; }\r\n\r\n\t// Could implement an event dispatcher pattern here easily...\r\n\tonValueChanged:(key:TKey, value:TValue, old:TValue) => void;\r\n\r\n\tprotected _onValueUpdate(key:TKey, value:TValue, old:TValue):void\r\n\t{\r\n\t\tif(!areEqual(value, old, true))\r\n\t\t{\r\n\r\n\t\t\tvar _ = this;\r\n\t\t\tif(_.onValueChanged)\r\n\t\t\t\t_.onValueChanged(key, value, old);\r\n\r\n\t\t\t// If the update recursion is zero, then we are finished with updates.\r\n\t\t\tif(_._updateRecursion==0)\r\n\t\t\t\t_._onUpdated();\r\n\r\n\t\t}\r\n\t}\r\n\r\n\t// Listening to every value update can get noisy. Here we allow for batch update signaling.\r\n\t// The consumer of this class can also wire up their own event system.\r\n\tonUpdated:() => void;\r\n\r\n\tprivate _onUpdated():void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.onUpdated)\r\n\t\t\t_.onUpdated();\r\n\t}\r\n\r\n\t// Takes a closure that if returning true will propagate an update signal.\r\n\thandleUpdate(closure?:() => boolean):boolean\r\n\t{\r\n\t\tvar _ = this, result:boolean;\r\n\t\tif(closure)\r\n\t\t{\r\n\t\t\t_._updateRecursion++;\r\n\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tresult = closure();\r\n\t\t\t}\r\n\t\t\tfinally\r\n\t\t\t{\r\n\t\t\t\t_._updateRecursion--;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t\tresult = _._updateRecursion==0;\r\n\r\n\t\tif(result && _._updateRecursion==0)\r\n\t\t\t_._onUpdated();\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// ICollection\r\n\t/////////////////////////////////////////\r\n\tget isReadOnly():boolean { return false; }\r\n\r\n\tprotected abstract getCount():number;\r\n\r\n\tget count():number { return this.getCount(); }\r\n\r\n\tadd(item:KeyValuePair):void\r\n\t{\r\n\t\tif(!item)\r\n\t\t\tthrow new ArgumentNullException(\r\n\t\t\t\t'item', 'Dictionaries must use a valid key/value pair. \\'' + item + '\\' is not allowed.'\r\n\t\t\t);\r\n\r\n\t\textractKeyValue(item,\r\n\t\t\t(key, value)=>this.addByKeyValue(key, value));\r\n\t}\r\n\r\n\tclear():number\r\n\t{\r\n\t\tvar _ = this, keys = _.keys, count = keys.length;\r\n\r\n\t\tif(count)\r\n\t\t\t_.handleUpdate(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\tkeys.forEach(key=> { _.removeByKey(key); });\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t);\r\n\r\n\t\tif(_.count!=0) // After they've all been removed, then should be zero.\r\n\t\t\tconsole.warn(\"Dictionary clear() results in mismatched count.\");\r\n\r\n\t\treturn count;\r\n\t}\r\n\r\n\tcontains(item:KeyValuePair):boolean\r\n\t{\r\n\t\t// Should never have a null object in the collection.\r\n\t\tif(!item) return false;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn areEqual(value, v);\r\n\t\t\t});\r\n\r\n\t}\r\n\r\n\tcopyTo(array:IKeyValuePair[], index:number = 0):IKeyValuePair[]\r\n\t{\r\n\t\tif(!array) throw new ArgumentNullException('array');\r\n\r\n\t\t// This is a generic implementation that will work for all derived classes.\r\n\t\t// It can be overridden and optimized.\r\n\t\tvar e = this.getEnumerator();\r\n\t\twhile(e.moveNext()) // Disposes when finished.\r\n\t\t{\r\n\t\t\tarray[index++] = e.current;\r\n\t\t}\r\n\t\treturn array;\r\n\t}\r\n\r\n\r\n\ttoArray():IKeyValuePair[]\r\n\t{\r\n\t\treturn this.copyTo([], 0);\r\n\t}\r\n\r\n\tremove(item:IKeyValuePair|[TKey,TValue]):number\r\n\t{\r\n\t\tif(!item) return 0;\r\n\r\n\t\treturn extractKeyValue(item,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\t// Leave as variable for debugging...\r\n\t\t\t\tlet v = this.getValue(key);\r\n\t\t\t\treturn (areEqual(value, v) && this.removeByKey(key))\r\n\t\t\t\t\t? 1 : 0;\r\n\t\t\t});\r\n\r\n\r\n\t}\r\n\r\n\t/////////////////////////////////////////\r\n\t// IDictionary\r\n\t/////////////////////////////////////////\r\n\r\n\tprotected abstract getKeys():TKey[];\r\n\r\n\tget keys():TKey[] { return this.getKeys(); }\r\n\r\n\tprotected abstract getValues():TValue[];\r\n\r\n\tget values():TValue[] { return this.getValues(); }\r\n\r\n\r\n\taddByKeyValue(key:TKey, value:TValue):void\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(_.containsKey(key))\r\n\t\t{\r\n\t\t\tvar ex = new InvalidOperationException(\"Adding a key/value when the key already exists.\");\r\n\t\t\tex.data['key'] = key;\r\n\t\t\tex.data['value'] = value;\r\n\t\t\tthrow ex;\r\n\t\t}\r\n\r\n\t\t_.setValue(key, value);\r\n\t}\r\n\r\n\tabstract getValue(key:TKey):TValue;\r\n\r\n\tabstract setValue(key:TKey, value:TValue):boolean;\r\n\r\n\tcontainsKey(key:TKey):boolean\r\n\t{\r\n\t\tvar value = this.getValue(key);\r\n\t\treturn value!==VOID0;\r\n\t}\r\n\r\n\tcontainsValue(value:TValue):boolean\r\n\t{\r\n\t\tvar e = this.getEnumerator(), equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\r\n\t\twhile(e.moveNext())\r\n\t\t{\r\n\t\t\tif(equal(e.current, value, true))\r\n\t\t\t{\r\n\t\t\t\te.dispose();\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\tremoveByKey(key:TKey):boolean\r\n\t{\r\n\t\treturn this.setValue(key, undefined);\r\n\t}\r\n\r\n\tremoveByValue(value:TValue):number\r\n\t{\r\n\t\tvar _ = this, count = 0, equal:(a:any, b:any, strict?:boolean) => boolean = areEqual;\r\n\t\t_.keys.forEach(key=>\r\n\t\t{\r\n\t\t\tif(equal(_.getValue(key), value, true))\r\n\t\t\t{\r\n\t\t\t\t_.removeByKey(key);\r\n\t\t\t\t++count;\r\n\t\t\t}\r\n\t\t});\r\n\t\treturn count;\r\n\t}\r\n\r\n\timportPairs(pairs:KeyValuePair[]|IEnumerable>):boolean\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tif(!pairs) return false;\r\n\t\treturn _.handleUpdate(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tlet changed:boolean = false;\r\n\t\t\t\tforEach(pairs,\r\n\t\t\t\t\tpair=>extractKeyValue(pair, (key, value)=>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t\t\t\tchanged = true;\r\n\t\t\t\t\t})\r\n\t\t\t\t);\r\n\t\t\t\treturn changed;\r\n\t\t\t}\r\n\t\t);\r\n\t}\r\n\r\n\tgetEnumerator():IEnumerator>\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tvar keys:TKey[], len:number, i = 0;\r\n\t\treturn new EnumeratorBase>(\r\n\t\t\t() =>\r\n\t\t\t{\r\n\t\t\t\tkeys = _.keys;\r\n\t\t\t\tlen = keys.length\r\n\t\t\t},\r\n\r\n\t\t\t(yielder)=>\r\n\t\t\t{\r\n\t\t\t\twhile(i\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../../Types';\r\nimport DisposableBase from '../../Disposable/DisposableBase';\r\nimport ArrayEnumerator from './ArrayEnumerator';\r\nimport IndexEnumerator from './IndexEnumerator';\r\n\r\n\r\nclass EmptyEnumerator implements IEnumerator\r\n{\r\n\tget current():any\r\n\t{\r\n\t\treturn undefined;\r\n\t}\r\n\r\n\tmoveNext():boolean\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treset():void { }\r\n\r\n\tdispose():void { }\r\n}\r\n\r\nconst Empty = new EmptyEnumerator();\r\n\r\n// Could be array, or IEnumerable...\r\nexport function from(source:IEnumerable | IArray):IEnumerator\r\n{\r\n\t// To simplify and prevent null reference exceptions:\r\n\tif(!source)\r\n\t\treturn Empty;\r\n\r\n\tif(Array.isArray(source))\r\n\t\treturn new ArrayEnumerator(source);\r\n\r\n\r\n\tif(!Type.isPrimitive(source))\r\n\t{\r\n\t\tif(Type.isArrayLike(source))\r\n\t\t{\r\n\t\t\treturn new IndexEnumerator(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\tlength: source.length,\r\n\t\t\t\t\t\tpointer: 0,\r\n\t\t\t\t\t\tstep: 1\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t);\r\n\t\t}\r\n\t\tif(isEnumerable(source))\r\n\t\t\treturn source.getEnumerator();\r\n\r\n\t}\r\n\r\n\tthrow new Error(\"Unknown enumerable.\");\r\n}\r\n\r\nexport function isEnumerable(instance:any):instance is IEnumerable\r\n{\r\n\treturn Type.hasMemberOfType>(instance, \"getEnumerator\", Type.FUNCTION);\r\n}\r\n\r\nexport function forEach(\r\n\te:IEnumerator,\r\n\taction:(element:T, index?:number) => any):void\r\n{\r\n\tif(e)\r\n\t{\r\n\t\tvar index = 0;\r\n\t\t// Return value of action can be anything, but if it is (===) false then the forEach will discontinue.\r\n\t\twhile(e.moveNext())\r\n\t\t{\r\n\t\t\tif(action(e.current, index++)===false)\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["System/Collections/Enumeration/Enumerator.js","System/Collections/Enumeration/Enumerator.ts"],"names":["factory","module","exports","v","require","undefined","define","amd","from","source","isEnumerable","instance","isEnumerator","forEach","e","action","Types_1","ArrayEnumerator_1","IndexEnumerator_1","EmptyEnumerator","get","enumerable","configurable","EmptyEnumerator.moveNext","Empty"],"mappings":";;;;CAIA,SAAWA,GACP,GAAsB,gBAAXC,SAAiD,gBAAnBA,QAAOC,QAAsB,CAClE,GAAIC,GAAIH,EAAQI,QAASF,QAAoBG,UAANF,IAAiBF,OAAOC,QAAUC,OAElD,kBAAXG,SAAyBA,OAAOC,KAC5CD,QAAQ,UAAW,UAAW,cAAe,oBAAqB,qBAAsBN,IAE7F,SAAUI,EAASF,GCFtB,YA4BA,SAAAM,GAAwBC,GAGvBD,IAAIA,EACHA,MAAOA,EAERA,IAAGA,MAAMA,QAAQA,GAChBA,MAAOA,IAAIA,GAAAA,WAAwBA,EAGpCA,KAAIA,EAAAA,WAAKA,YAAYA,GACrBA,CACCA,GAAGA,EAAAA,WAAKA,YAAeA,GAEtBA,MAAOA,IAAIA,GAAAA,WACVA,WAECA,OACCA,OAAQA,EACRA,OAAQA,EAAOA,OACfA,QAASA,EACTA,KAAMA,IAKVA,IAAGA,EAAgBA,GAClBA,MAAOA,GAAOA,gBAIhBA,KAAMA,IAAIA,OAAMA,uBAGjB,QAAAE,GAAgCC,GAE/BD,MAAOA,GAAAA,WAAKA,gBAAgCA,EAAUA,gBAAiBA,EAAAA,WAAKA,UAG7E,QAAAE,GAAgCD,GAE/BC,MAAOA,GAAAA,WAAKA,gBAAgCA,EAAUA,WAAYA,EAAAA,WAAKA,UAGxE,QAAAC,GACCC,EACAC,GAEAF,GAAGA,EACHA,CACCA,GAAGA,MAAMA,QAAQA,GAGhBA,WADAA,GAAEA,QAAQA,EASXA,IALGA,EAAgBA,KAElBA,EAAqBA,EAAGA,iBAGtBA,EAAgBA,GAIlBA,IAFAA,GAAIA,GAAQA,EAENA,EAAEA,YAEJA,EAAOA,EAAEA,QAASA,QAAWA,MA7FpC,GAAAG,GAAAZ,EAAiB,eAEjBa,EAAAb,EAA4B,qBAC5Bc,EAAAd,EAA4B,qBAG5Be,EAAA,WAAAA,QAAAA,MAeAA,MAbCA,QAAAA,eAAIA,EAAAA,UAAAA,WDCOC,ICDXD,aDIWE,YAAY,EACZC,cAAc,ICAzBH,EAAAA,UAAAA,SAAAA,WAECI,OAAOA,GAGRJ,EAAAA,UAAAA,MAAAA,aAEAA,EAAAA,UAAAA,QAAAA,aACDA,KAEMK,EAAQ,GAAIL,EAGFjB,GAAAM,KAAIA,EAkCJN,EAAAQ,aAAYA,EAKZR,EAAAU,aAAYA,EAKZV,EAAAW,QAAOA","file":"System/Collections/Enumeration/Enumerator.js","sourcesContent":["/*!\n * @author electricessence / https://github.com/electricessence/\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\n */\n(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define([\"require\", \"exports\", '../../Types', './ArrayEnumerator', './IndexEnumerator'], factory);\n }\n})(function (require, exports) {\n 'use strict';\n var Types_1 = require('../../Types');\n var ArrayEnumerator_1 = require('./ArrayEnumerator');\n var IndexEnumerator_1 = require('./IndexEnumerator');\n var EmptyEnumerator = (function () {\n function EmptyEnumerator() {\n }\n Object.defineProperty(EmptyEnumerator.prototype, \"current\", {\n get: function () {\n return undefined;\n },\n enumerable: true,\n configurable: true\n });\n EmptyEnumerator.prototype.moveNext = function () {\n return false;\n };\n EmptyEnumerator.prototype.reset = function () { };\n EmptyEnumerator.prototype.dispose = function () { };\n return EmptyEnumerator;\n })();\n var Empty = new EmptyEnumerator();\n function from(source) {\n if (!source)\n return Empty;\n if (Array.isArray(source))\n return new ArrayEnumerator_1.default(source);\n if (!Types_1.default.isPrimitive(source)) {\n if (Types_1.default.isArrayLike(source)) {\n return new IndexEnumerator_1.default(function () {\n return {\n source: source,\n length: source.length,\n pointer: 0,\n step: 1\n };\n });\n }\n if (isEnumerable(source))\n return source.getEnumerator();\n }\n throw new Error(\"Unknown enumerable.\");\n }\n exports.from = from;\n function isEnumerable(instance) {\n return Types_1.default.hasMemberOfType(instance, \"getEnumerator\", Types_1.default.FUNCTION);\n }\n exports.isEnumerable = isEnumerable;\n function isEnumerator(instance) {\n return Types_1.default.hasMemberOfType(instance, \"moveNext\", Types_1.default.FUNCTION);\n }\n exports.isEnumerator = isEnumerator;\n function forEach(e, action) {\n if (e) {\n if (Array.isArray(e)) {\n e.forEach(action);\n return;\n }\n if (isEnumerable(e)) {\n e = e.getEnumerator();\n }\n if (isEnumerator(e)) {\n var index = 0;\n while (e.moveNext()) {\n if (action(e.current, index++) === false)\n break;\n }\n }\n }\n }\n exports.forEach = forEach;\n});\n","/*!\r\n * @author electricessence / https://github.com/electricessence/\r\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\r\n */\r\n\r\n///\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../../Types';\r\nimport DisposableBase from '../../Disposable/DisposableBase';\r\nimport ArrayEnumerator from './ArrayEnumerator';\r\nimport IndexEnumerator from './IndexEnumerator';\r\n\r\n\r\nclass EmptyEnumerator implements IEnumerator\r\n{\r\n\tget current():any\r\n\t{\r\n\t\treturn undefined;\r\n\t}\r\n\r\n\tmoveNext():boolean\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\treset():void { }\r\n\r\n\tdispose():void { }\r\n}\r\n\r\nconst Empty = new EmptyEnumerator();\r\n\r\n// Could be array, or IEnumerable...\r\nexport function from(source:IEnumerable | IArray):IEnumerator\r\n{\r\n\t// To simplify and prevent null reference exceptions:\r\n\tif(!source)\r\n\t\treturn Empty;\r\n\r\n\tif(Array.isArray(source))\r\n\t\treturn new ArrayEnumerator(source);\r\n\r\n\r\n\tif(!Type.isPrimitive(source))\r\n\t{\r\n\t\tif(Type.isArrayLike(source))\r\n\t\t{\r\n\t\t\treturn new IndexEnumerator(\r\n\t\t\t\t() =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\tlength: source.length,\r\n\t\t\t\t\t\tpointer: 0,\r\n\t\t\t\t\t\tstep: 1\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t);\r\n\t\t}\r\n\t\tif(isEnumerable(source))\r\n\t\t\treturn source.getEnumerator();\r\n\r\n\t}\r\n\r\n\tthrow new Error(\"Unknown enumerable.\");\r\n}\r\n\r\nexport function isEnumerable(instance:any):instance is IEnumerable\r\n{\r\n\treturn Type.hasMemberOfType>(instance, \"getEnumerator\", Type.FUNCTION);\r\n}\r\n\r\nexport function isEnumerator(instance:any):instance is IEnumerator\r\n{\r\n\treturn Type.hasMemberOfType>(instance, \"moveNext\", Type.FUNCTION);\r\n}\r\n\r\nexport function forEach(\r\n\te:T[]|IEnumerator|IEnumerable,\r\n\taction:(element:T, index?:number) => any):void\r\n{\r\n\tif(e)\r\n\t{\r\n\t\tif(Array.isArray(e))\r\n\t\t{\r\n\t\t\te.forEach(action);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif(isEnumerable(e))\r\n\t\t{\r\n\t\t\te = (>e).getEnumerator();\r\n\t\t}\r\n\r\n\t\tif(isEnumerator(e))\r\n\t\t{\r\n\t\t\tvar index = 0;\r\n\t\t\t// Return value of action can be anything, but if it is (===) false then the forEach will discontinue.\r\n\t\t\twhile(e.moveNext())\r\n\t\t\t{\r\n\t\t\t\tif(action(e.current, index++)===false)\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"]} \ No newline at end of file diff --git a/dist/umd.min/System/Uri/QueryBuilder.js b/dist/umd.min/System/Uri/QueryBuilder.js index 675f6b7a..f1bacc03 100644 --- a/dist/umd.min/System/Uri/QueryBuilder.js +++ b/dist/umd.min/System/Uri/QueryBuilder.js @@ -2,5 +2,5 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md */ -var __extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)};!function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define(["require","exports","../Types","./QueryParams","../Collections/Dictionaries/OrderedStringKeyDictionary"],e)}(function(e,t){"use strict";var r=e("../Types"),i=e("./QueryParams"),o=e("../Collections/Dictionaries/OrderedStringKeyDictionary"),n="&",s="=",u=function(e){function t(t,r){void 0===r&&(r=!0),e.call(this),this.importQuery(t,r)}return __extends(t,e),t.prototype.importQuery=function(e,t){return void 0===t&&(t=!0),r["default"].isString(e)?this.importFromString(e,t):Array.isArray(e)?this.importPairs(e):this.importMap(e),this},t.prototype.importFromString=function(e,t,r){void 0===t&&(t=!0),void 0===r&&(r=!0);var o=this;return i.parse(e,function(e,t){if(o.containsKey(e)){var r=o.getValue(e);Array.isArray(r)?r.push(t):o.setValue(e,[r,t])}else o.setValue(e,t)},t,r),this},t.init=function(e,r){return void 0===r&&(r=!0),new t(e,r)},t.prototype.encode=function(e){for(var t=[],r=this.keys,o=0;o\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../Types';\r\nimport * as Serialization from '../Serialization/Utility';\r\nimport * as QueryParams from './QueryParams';\r\nimport OrderedStringKeyDictionary from '../Collections/Dictionaries/OrderedStringKeyDictionary';\r\n\r\nconst\r\nENTRY_SEPARATOR = \"&\",\r\nKEY_VALUE_SEPARATOR = \"=\";\r\n\r\n/**\r\n * Provides a means for parsing and building a set of parameters.\r\n *\r\n * In other languages, dictionaries are not reliable for retaining the order of stored values. So for certainty and flexibility we use an ordered dictionary as a base class.\r\n */\r\nexport default\r\nclass QueryBuilder extends OrderedStringKeyDictionary\r\n{\r\n\r\n\tconstructor(\r\n\t\tquery:string|IUriComponentMap|StringKeyValuePair[],\r\n\t\tdecodeValues:boolean = true)\r\n\t{\r\n\t\tsuper();\r\n\r\n\t\tthis.importQuery(query,decodeValues);\r\n\t}\r\n\r\n\timportQuery(\r\n\t\tquery:string|IUriComponentMap|StringKeyValuePair[],\r\n\t\tdecodeValues:boolean = true):QueryBuilder {\r\n\r\n\t\tif(Type.isString(query))\r\n\t\t{\r\n\t\t\tthis.importFromString(query, decodeValues);\r\n\t\t}\r\n\t\telse if(Array.isArray(query))\r\n\t\t{\r\n\t\t\tthis.importPairs(query);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.importMap(query);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Property parses the components of an URI into their values or array of values.\r\n\t * @param values\r\n\t * @param deserialize\r\n\t * @param decodeValues\r\n\t * @returns {QueryBuilder}\r\n\t */\r\n\timportFromString(\r\n\t\tvalues:string,\r\n\t\tdeserialize:boolean = true,\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tQueryParams.parse(values,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\tif(_.containsKey(key))\r\n\t\t\t\t{\r\n\t\t\t\t\tvar prev = _.getValue(key);\r\n\t\t\t\t\tif(Array.isArray(prev))\r\n\t\t\t\t\t\tprev.push(value);\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\t_.setValue(key, [prev, value]);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t},\r\n\t\t\tdeserialize,\r\n\t\t\tdecodeValues);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\tstatic init(\r\n\t\tquery:string|IUriComponentMap|StringKeyValuePair[],\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\treturn new QueryBuilder(query, decodeValues);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Returns the encoded URI string\r\n\t */\r\n\tencode(prefixIfNotEmpty?:boolean):string\r\n\t{\r\n\t\tvar entries:string[] = [];\r\n\t\tvar keys = this.keys;\r\n\t\tfor(let k of keys)\r\n\t\t{\r\n\t\t\tvar value = this.getValue(k);\r\n\t\t\t// Since the values can either be UriComponentValues or an array of UriComponentValues..\r\n\t\t\t// This creates a single code path for both options.\r\n\t\t\tfor(let v of Array.isArray(value) ? value : [value])\r\n\t\t\t{\r\n\t\t\t\tentries.push(\r\n\t\t\t\t\tk + KEY_VALUE_SEPARATOR\r\n\t\t\t\t\t+ QueryParams.encodeValue(v));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn (entries.length && prefixIfNotEmpty ? '?' : '')\r\n\t\t\t+ entries.join(ENTRY_SEPARATOR);\r\n\t}\r\n\r\n\ttoString():string\r\n\t{\r\n\t\treturn this.encode();\r\n\t}\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["System/Uri/QueryBuilder.js","System/Uri/QueryBuilder.ts"],"names":["__extends","this","d","b","__","constructor","p","hasOwnProperty","prototype","Object","create","factory","module","exports","v","require","undefined","define","amd","Types_1","QueryParams","OrderedStringKeyDictionary_1","Enumerator_1","ENTRY_SEPARATOR","KEY_VALUE_SEPARATOR","QueryBuilder","_super","QueryBuilder.constructor","QueryBuilder.init","QueryBuilder.importQuery","QueryBuilder.importFromString","QueryBuilder.encode","QueryBuilder.toString","defineProperty","value"],"mappings":";;;;AAIA,GAAIA,WAAaC,MAAQA,KAAKD,WAAc,SAAUE,EAAGC,GAErD,QAASC,KAAOH,KAAKI,YAAcH,EADnC,IAAK,GAAII,KAAKH,GAAOA,EAAEI,eAAeD,KAAIJ,EAAEI,GAAKH,EAAEG,GAEnDJ,GAAEM,UAAkB,OAANL,EAAaM,OAAOC,OAAOP,IAAMC,EAAGI,UAAYL,EAAEK,UAAW,GAAIJ,MAEnF,SAAWO,GACP,GAAsB,gBAAXC,SAAiD,gBAAnBA,QAAOC,QAAsB,CAClE,GAAIC,GAAIH,EAAQI,QAASF,QAAoBG,UAANF,IAAiBF,OAAOC,QAAUC,OAElD,kBAAXG,SAAyBA,OAAOC,KAC5CD,QAAQ,UAAW,UAAW,WAAY,gBAAiB,yDAA0D,yCAA0CN,IAEpK,SAAUI,EAASF,GCPtB,YAEA,IAAAM,GAAAJ,EAAiB,YAELK,EAAWL,EAAM,iBAC7BM,EAAAN,EAAuC,0DACvCO,EAAAP,EAA2B,yCAI3BQ,EAAsB,IACtBC,EAAsB,IAOtBC,EAAA,SAAAC,GAICD,QAAAA,GACCA,EAIAA,GAAAE,SAAAA,IAAAA,GAAAA,GAEAA,EAAAA,KAAAA,MAEAA,KAAKA,YAAYA,EAAMA,GAoGzBF,MAhH2BA,WAAAA,EAAAA,GAgBnBA,EAAAA,KAAPA,SACCA,EAIAA,GAEAG,MAFAA,UAAAA,IAAAA,GAAAA,GAEOA,GAAIA,GAAaA,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ence / https://github.com/electricessence/\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\n */\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\n(function (factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define([\"require\", \"exports\", '../Types', './QueryParams', '../Collections/Dictionaries/OrderedStringKeyDictionary', '../Collections/Enumeration/Enumerator'], factory);\n }\n})(function (require, exports) {\n 'use strict';\n var Types_1 = require('../Types');\n var QueryParams = require('./QueryParams');\n var OrderedStringKeyDictionary_1 = require('../Collections/Dictionaries/OrderedStringKeyDictionary');\n var Enumerator_1 = require('../Collections/Enumeration/Enumerator');\n var ENTRY_SEPARATOR = \"&\", KEY_VALUE_SEPARATOR = \"=\";\n var QueryBuilder = (function (_super) {\n __extends(QueryBuilder, _super);\n function QueryBuilder(query, decodeValues) {\n if (decodeValues === void 0) { decodeValues = true; }\n _super.call(this);\n this.importQuery(query, decodeValues);\n }\n QueryBuilder.init = function (query, decodeValues) {\n if (decodeValues === void 0) { decodeValues = true; }\n return new QueryBuilder(query, decodeValues);\n };\n QueryBuilder.prototype.importQuery = function (query, decodeValues) {\n if (decodeValues === void 0) { decodeValues = true; }\n if (Types_1.default.isString(query)) {\n this.importFromString(query, decodeValues);\n }\n else if (Array.isArray(query) || Enumerator_1.isEnumerable(query)) {\n this.importPairs(query);\n }\n else {\n this.importMap(query);\n }\n return this;\n };\n QueryBuilder.prototype.importFromString = function (values, deserialize, decodeValues) {\n if (deserialize === void 0) { deserialize = true; }\n if (decodeValues === void 0) { decodeValues = true; }\n var _ = this;\n QueryParams.parse(values, function (key, value) {\n if (_.containsKey(key)) {\n var prev = _.getValue(key);\n if (Array.isArray(prev))\n prev.push(value);\n else\n _.setValue(key, [prev, value]);\n }\n else\n _.setValue(key, value);\n }, deserialize, decodeValues);\n return this;\n };\n QueryBuilder.prototype.encode = function (prefixIfNotEmpty) {\n var entries = [];\n var keys = this.keys;\n for (var _i = 0; _i < keys.length; _i++) {\n var k = keys[_i];\n var value = this.getValue(k);\n for (var _a = 0, _b = Array.isArray(value) ? value : [value]; _a < _b.length; _a++) {\n var v = _b[_a];\n entries.push(k + KEY_VALUE_SEPARATOR\n + QueryParams.encodeValue(v));\n }\n }\n return (entries.length && prefixIfNotEmpty ? '?' : '')\n + entries.join(ENTRY_SEPARATOR);\n };\n QueryBuilder.prototype.toString = function () {\n return this.encode();\n };\n return QueryBuilder;\n })(OrderedStringKeyDictionary_1.default);\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.default = QueryBuilder;\n});\n","/*!\r\n * @author electricessence / https://github.com/electricessence/\r\n * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md\r\n */\r\n\r\n///\r\n///\r\n///\r\n///\r\n'use strict'; // For compatibility with (let, const, function, class);\r\n\r\nimport Type from '../Types';\r\nimport * as Serialization from '../Serialization/Utility';\r\nimport * as QueryParams from './QueryParams';\r\nimport OrderedStringKeyDictionary from '../Collections/Dictionaries/OrderedStringKeyDictionary';\r\nimport {isEnumerable} from '../Collections/Enumeration/Enumerator';\r\n\r\n\r\nconst\r\nENTRY_SEPARATOR = \"&\",\r\nKEY_VALUE_SEPARATOR = \"=\";\r\n\r\n/**\r\n * Provides a means for parsing and building a set of parameters.\r\n *\r\n * In other languages, dictionaries are not reliable for retaining the order of stored values. So for certainty and flexibility we use an ordered dictionary as a base class.\r\n */\r\nexport default\r\nclass QueryBuilder extends OrderedStringKeyDictionary\r\n{\r\n\r\n\tconstructor(\r\n\t\tquery:string\r\n\t\t\t|IUriComponentMap\r\n\t\t\t|StringKeyValuePair[]\r\n\t\t\t|IEnumerable>,\r\n\t\tdecodeValues:boolean = true)\r\n\t{\r\n\t\tsuper();\r\n\r\n\t\tthis.importQuery(query,decodeValues);\r\n\t}\r\n\r\n\r\n\tstatic init(\r\n\t\tquery:string\r\n\t\t\t|IUriComponentMap\r\n\t\t\t|StringKeyValuePair[]\r\n\t\t\t|IEnumerable>,\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\treturn new QueryBuilder(query, decodeValues);\r\n\t}\r\n\r\n\timportQuery(\r\n\t\tquery:string\r\n\t\t\t|IUriComponentMap\r\n\t\t\t|StringKeyValuePair[]\r\n\t\t\t|IEnumerable>,\r\n\t\tdecodeValues:boolean = true):QueryBuilder {\r\n\r\n\t\tif(Type.isString(query))\r\n\t\t{\r\n\t\t\tthis.importFromString(query, decodeValues);\r\n\t\t}\r\n\t\telse if(Array.isArray(query) || isEnumerable(query))\r\n\t\t{\r\n\t\t\tthis.importPairs(query);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.importMap(query);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Property parses the components of an URI into their values or array of values.\r\n\t * @param values\r\n\t * @param deserialize\r\n\t * @param decodeValues\r\n\t * @returns {QueryBuilder}\r\n\t */\r\n\timportFromString(\r\n\t\tvalues:string,\r\n\t\tdeserialize:boolean = true,\r\n\t\tdecodeValues:boolean = true):QueryBuilder\r\n\t{\r\n\t\tvar _ = this;\r\n\t\tQueryParams.parse(values,\r\n\t\t\t(key, value)=>\r\n\t\t\t{\r\n\t\t\t\tif(_.containsKey(key))\r\n\t\t\t\t{\r\n\t\t\t\t\tvar prev = _.getValue(key);\r\n\t\t\t\t\tif(Array.isArray(prev))\r\n\t\t\t\t\t\tprev.push(value);\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\t_.setValue(key, [prev, value]);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\t_.setValue(key, value);\r\n\t\t\t},\r\n\t\t\tdeserialize,\r\n\t\t\tdecodeValues);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\r\n\r\n\t/**\r\n\t * Returns the encoded URI string\r\n\t */\r\n\tencode(prefixIfNotEmpty?:boolean):string\r\n\t{\r\n\t\tvar entries:string[] = [];\r\n\t\tvar keys = this.keys;\r\n\t\tfor(let k of keys)\r\n\t\t{\r\n\t\t\tvar value = this.getValue(k);\r\n\t\t\t// Since the values can either be UriComponentValues or an array of UriComponentValues..\r\n\t\t\t// This creates a single code path for both options.\r\n\t\t\tfor(let v of Array.isArray(value) ? value : [value])\r\n\t\t\t{\r\n\t\t\t\tentries.push(\r\n\t\t\t\t\tk + KEY_VALUE_SEPARATOR\r\n\t\t\t\t\t+ QueryParams.encodeValue(v));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn (entries.length && prefixIfNotEmpty ? '?' : '')\r\n\t\t\t+ entries.join(ENTRY_SEPARATOR);\r\n\t}\r\n\r\n\ttoString():string\r\n\t{\r\n\t\treturn this.encode();\r\n\t}\r\n}\r\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 8134e566..010320ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typescript-dotnet", - "version": "2.6.3", + "version": "2.6.4", "license": "MIT", "author": "electricessence ", "description": "A JavaScript-Friendly .NET Based TypeScript Library.", diff --git a/source/System/Collections/Dictionaries/DictionaryBase.js b/source/System/Collections/Dictionaries/DictionaryBase.js index caaa0356..647717c1 100644 --- a/source/System/Collections/Dictionaries/DictionaryBase.js +++ b/source/System/Collections/Dictionaries/DictionaryBase.js @@ -7,7 +7,7 @@ var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(["require", "exports", '../../Compare', '../Enumeration/EnumeratorBase', '../../Exceptions/ArgumentNullException', '../../Exceptions/InvalidOperationException', '../../KeyValueExtract'], factory); + define(["require", "exports", '../../Compare', '../Enumeration/EnumeratorBase', '../../Exceptions/ArgumentNullException', '../../Exceptions/InvalidOperationException', '../../KeyValueExtract', '../Enumeration/Enumerator'], factory); } })(function (require, exports) { 'use strict'; @@ -16,6 +16,7 @@ var ArgumentNullException_1 = require('../../Exceptions/ArgumentNullException'); var InvalidOperationException_1 = require('../../Exceptions/InvalidOperationException'); var KeyValueExtract_1 = require('../../KeyValueExtract'); + var Enumerator_1 = require('../Enumeration/Enumerator'); var VOID0 = void (0); var DictionaryBase = (function () { function DictionaryBase() { @@ -165,9 +166,11 @@ }; DictionaryBase.prototype.importPairs = function (pairs) { var _ = this; + if (!pairs) + return false; return _.handleUpdate(function () { var changed = false; - pairs.forEach(function (pair) { return KeyValueExtract_1.default(pair, function (key, value) { + Enumerator_1.forEach(pairs, function (pair) { return KeyValueExtract_1.default(pair, function (key, value) { _.setValue(key, value); changed = true; }); }); diff --git a/source/System/Collections/Dictionaries/DictionaryBase.js.map b/source/System/Collections/Dictionaries/DictionaryBase.js.map index 119bf983..78d43ed0 100644 --- a/source/System/Collections/Dictionaries/DictionaryBase.js.map +++ b/source/System/Collections/Dictionaries/DictionaryBase.js.map @@ -1 +1 @@ -{"version":3,"file":"DictionaryBase.js","sourceRoot":"","sources":["DictionaryBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;IAGH,YAAY,CAAC;IAEb,wBAAuB,eAAe,CAAC,CAAA;IACvC,+BAA2B,+BAA+B,CAAC,CAAA;IAE3D,sCAAkC,wCAAwC,CAAC,CAAA;IAC3E,0CAAsC,4CAA4C,CAAC,CAAA;IACnF,gCAA4B,uBAAuB,CAAC,CAAA;IAEpD,IAAM,KAAK,GAAO,KAAI,CAAC,CAAC,CAAC,CAAC;IAG1B;QAMC;YAEC,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC3B,CAAC;QAED,sBAAI,sCAAU;iBAAd,cAA2B,MAAM,CAAC,IAAI,CAAC,gBAAgB,IAAE,CAAC,CAAC,CAAC,CAAC;;;WAAA;QAKnD,uCAAc,GAAxB,UAAyB,GAAQ,EAAE,KAAY,EAAE,GAAU;YAE1D,EAAE,CAAA,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C,IAAI,OAAO,GAAW,KAAK,CAAC;gBAC5B,oBAAO,CAAC,KAAK,EACZ,UAAA,IAAI,IAAE,OAAA,yBAAe,CAAC,IAAI,EAAE,UAAC,GAAG,EAAE,KAAK;oBAEtC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;oBACvB,OAAO,GAAG,IAAI,CAAC;gBAChB,CAAC,CAAC,EAJI,CAIJ,CACF,CAAC;gBACF,MAAM,CAAC,OAAO,CAAC;YAChB,CAAC,CACD,CAAC;QACH,CAAC;QAED,sCAAa,GAAb;YAEC,IAAI,CAAC,GAAG,IAAI,CAAC;YACb,IAAI,IAAW,EAAE,GAAU,EAAE,CAAC,GAAG,CAAC,CAAC;YACnC,MAAM,CAAC,IAAI,wBAAc,CACxB;gBAEC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;gBACd,GAAG,GAAG,IAAI,CAAC,MAAM,CAAA;YAClB,CAAC,EAED,UAAC,OAAO;gBAEP,OAAM,CAAC,GAAC,GAAG,EACX,CAAC;oBACA,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;oBAC7C,EAAE,CAAA,CAAC,KAAK,KAAG,KAAK,CAAC;wBAChB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;gBACvD,CAAC;gBAED,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YAC7B,CAAC,CACD,CAAC;QACH,CAAC;QAGF,qBAAC;IAAD,CAAC,AApRD,IAoRC;IAGD;sBAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/source/System/Collections/Dictionaries/DictionaryBase.ts b/source/System/Collections/Dictionaries/DictionaryBase.ts index f185bbf6..3a4c2be7 100644 --- a/source/System/Collections/Dictionaries/DictionaryBase.ts +++ b/source/System/Collections/Dictionaries/DictionaryBase.ts @@ -12,6 +12,7 @@ import ArgumentException from '../../Exceptions/ArgumentException'; import ArgumentNullException from '../../Exceptions/ArgumentNullException'; import InvalidOperationException from '../../Exceptions/InvalidOperationException'; import extractKeyValue from '../../KeyValueExtract'; +import {forEach} from '../Enumeration/Enumerator'; const VOID0:any = void(0); @@ -246,14 +247,15 @@ implements IDictionary return count; } - importPairs(pairs:KeyValuePair[]):boolean + importPairs(pairs:KeyValuePair[]|IEnumerable>):boolean { var _ = this; + if(!pairs) return false; return _.handleUpdate( () => { - var changed:boolean = false; - pairs.forEach( + let changed:boolean = false; + forEach(pairs, pair=>extractKeyValue(pair, (key, value)=> { _.setValue(key, value); diff --git a/source/System/Collections/Enumeration/Enumerator.js b/source/System/Collections/Enumeration/Enumerator.js index 4a319d12..726c5653 100644 --- a/source/System/Collections/Enumeration/Enumerator.js +++ b/source/System/Collections/Enumeration/Enumerator.js @@ -58,12 +58,25 @@ return Types_1.default.hasMemberOfType(instance, "getEnumerator", Types_1.default.FUNCTION); } exports.isEnumerable = isEnumerable; + function isEnumerator(instance) { + return Types_1.default.hasMemberOfType(instance, "moveNext", Types_1.default.FUNCTION); + } + exports.isEnumerator = isEnumerator; function forEach(e, action) { if (e) { - var index = 0; - while (e.moveNext()) { - if (action(e.current, index++) === false) - break; + if (Array.isArray(e)) { + e.forEach(action); + return; + } + if (isEnumerable(e)) { + e = e.getEnumerator(); + } + if (isEnumerator(e)) { + var index = 0; + while (e.moveNext()) { + if (action(e.current, index++) === false) + break; + } } } } diff --git a/source/System/Collections/Enumeration/Enumerator.js.map b/source/System/Collections/Enumeration/Enumerator.js.map index 29f565c1..369590f5 100644 --- a/source/System/Collections/Enumeration/Enumerator.js.map +++ b/source/System/Collections/Enumeration/Enumerator.js.map @@ -1 +1 @@ -{"version":3,"file":"Enumerator.js","sourceRoot":"","sources":["Enumerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;IAMH,YAAY,CAAC;IAE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C;YACzC,CAAC;YAED,EAAE,CAAA,CAAC,YAAY,CAAI,CAAC,CAAC,CAAC,CACtB,CAAC;gBACA,IAAI,KAAK,GAAG,CAAC,CAAC;gBAEd,OAAM,CAAC,CAAC,QAAQ,EAAE,EAClB,CAAC;oBACA,EAAE,CAAA,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,KAAG,KAAK,CAAC;wBACrC,KAAK,CAAC;gBACR,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IA5Be,eAAO,UA4BtB,CAAA"} \ No newline at end of file diff --git a/source/System/Collections/Enumeration/Enumerator.ts b/source/System/Collections/Enumeration/Enumerator.ts index fa53d792..78af516d 100644 --- a/source/System/Collections/Enumeration/Enumerator.ts +++ b/source/System/Collections/Enumeration/Enumerator.ts @@ -74,18 +74,37 @@ export function isEnumerable(instance:any):instance is IEnumerable return Type.hasMemberOfType>(instance, "getEnumerator", Type.FUNCTION); } +export function isEnumerator(instance:any):instance is IEnumerator +{ + return Type.hasMemberOfType>(instance, "moveNext", Type.FUNCTION); +} + export function forEach( - e:IEnumerator, + e:T[]|IEnumerator|IEnumerable, action:(element:T, index?:number) => any):void { if(e) { - var index = 0; - // Return value of action can be anything, but if it is (===) false then the forEach will discontinue. - while(e.moveNext()) + if(Array.isArray(e)) + { + e.forEach(action); + return; + } + + if(isEnumerable(e)) + { + e = (>e).getEnumerator(); + } + + if(isEnumerator(e)) { - if(action(e.current, index++)===false) - break; + var index = 0; + // Return value of action can be anything, but if it is (===) false then the forEach will discontinue. + while(e.moveNext()) + { + if(action(e.current, index++)===false) + break; + } } } } diff --git a/source/System/Uri/QueryBuilder.js b/source/System/Uri/QueryBuilder.js index a5437ce2..4e7c3add 100644 --- a/source/System/Uri/QueryBuilder.js +++ b/source/System/Uri/QueryBuilder.js @@ -12,13 +12,14 @@ var __extends = (this && this.__extends) || function (d, b) { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(["require", "exports", '../Types', './QueryParams', '../Collections/Dictionaries/OrderedStringKeyDictionary'], factory); + define(["require", "exports", '../Types', './QueryParams', '../Collections/Dictionaries/OrderedStringKeyDictionary', '../Collections/Enumeration/Enumerator'], factory); } })(function (require, exports) { 'use strict'; var Types_1 = require('../Types'); var QueryParams = require('./QueryParams'); var OrderedStringKeyDictionary_1 = require('../Collections/Dictionaries/OrderedStringKeyDictionary'); + var Enumerator_1 = require('../Collections/Enumeration/Enumerator'); var ENTRY_SEPARATOR = "&", KEY_VALUE_SEPARATOR = "="; var QueryBuilder = (function (_super) { __extends(QueryBuilder, _super); @@ -27,12 +28,16 @@ var __extends = (this && this.__extends) || function (d, b) { _super.call(this); this.importQuery(query, decodeValues); } + QueryBuilder.init = function (query, decodeValues) { + if (decodeValues === void 0) { decodeValues = true; } + return new QueryBuilder(query, decodeValues); + }; QueryBuilder.prototype.importQuery = function (query, decodeValues) { if (decodeValues === void 0) { decodeValues = true; } if (Types_1.default.isString(query)) { this.importFromString(query, decodeValues); } - else if (Array.isArray(query)) { + else if (Array.isArray(query) || Enumerator_1.isEnumerable(query)) { this.importPairs(query); } else { @@ -57,10 +62,6 @@ var __extends = (this && this.__extends) || function (d, b) { }, deserialize, decodeValues); return this; }; - QueryBuilder.init = function (query, decodeValues) { - if (decodeValues === void 0) { decodeValues = true; } - return new QueryBuilder(query, decodeValues); - }; QueryBuilder.prototype.encode = function (prefixIfNotEmpty) { var entries = []; var keys = this.keys; diff --git a/source/System/Uri/QueryBuilder.js.map b/source/System/Uri/QueryBuilder.js.map index 3881ff12..3532d0a7 100644 --- a/source/System/Uri/QueryBuilder.js.map +++ b/source/System/Uri/QueryBuilder.js.map @@ -1 +1 @@ -{"version":3,"file":"QueryBuilder.js","sourceRoot":"","sources":["QueryBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;;IAMH,YAAY,CAAC;IAEb,sBAAiB,UAAU,CAAC,CAAA;IAE5B,IAAY,WAAW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AAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,EAAtC,cAAsC,EAAtC,IAAsC,CAAC;oBAAhD,IAAI,CAAC,SAAA;oBAER,OAAO,CAAC,IAAI,CACX,CAAC,GAAG,mBAAmB;0BACrB,WAAW,CAAC,WAAW,CAAoB,CAAC,CAAC,CAAC,CAAC;iBAClD;aACD;YAED,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG,GAAG,EAAE,CAAC;kBACnD,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAClC,CAAC;QAED,+BAAQ,GAAR;YAEC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;QACF,mBAAC;IAAD,CAAC,AAjHD,CAC2B,oCAA0B,GAgHpD;IAjHD;kCAiHC,CAAA"} \ No newline at end of file diff --git a/source/System/Uri/QueryBuilder.ts b/source/System/Uri/QueryBuilder.ts index f4403e91..0f9322ca 100644 --- a/source/System/Uri/QueryBuilder.ts +++ b/source/System/Uri/QueryBuilder.ts @@ -13,6 +13,8 @@ import Type from '../Types'; import * as Serialization from '../Serialization/Utility'; import * as QueryParams from './QueryParams'; import OrderedStringKeyDictionary from '../Collections/Dictionaries/OrderedStringKeyDictionary'; +import {isEnumerable} from '../Collections/Enumeration/Enumerator'; + const ENTRY_SEPARATOR = "&", @@ -28,7 +30,10 @@ class QueryBuilder extends OrderedStringKeyDictionary[], + query:string + |IUriComponentMap + |StringKeyValuePair[] + |IEnumerable>, decodeValues:boolean = true) { super(); @@ -36,15 +41,29 @@ class QueryBuilder extends OrderedStringKeyDictionary[] + |IEnumerable>, + decodeValues:boolean = true):QueryBuilder + { + return new QueryBuilder(query, decodeValues); + } + importQuery( - query:string|IUriComponentMap|StringKeyValuePair[], + query:string + |IUriComponentMap + |StringKeyValuePair[] + |IEnumerable>, decodeValues:boolean = true):QueryBuilder { if(Type.isString(query)) { this.importFromString(query, decodeValues); } - else if(Array.isArray(query)) + else if(Array.isArray(query) || isEnumerable(query)) { this.importPairs(query); } @@ -89,12 +108,6 @@ class QueryBuilder extends OrderedStringKeyDictionary[], - decodeValues:boolean = true):QueryBuilder - { - return new QueryBuilder(query, decodeValues); - } /**