{"aliases":["default"],"browsers":{"ie":"<12","safari":"<7.1","firefox":"<29","chrome":"<38","android":"*","firefox_mob":"<29","ie_mob":"*","opera_mob":"*","ios_saf":"<8"},"dependencies":["Array.prototype.indexOf","Symbol","Symbol.iterator","Symbol.species","Object.defineProperty","Number.isNaN"],"notes":["For compatibility with very old engines, `Set.prototype.delete` must be accessed using square bracket notation because 'delete' is a reserved word. `mySet.delete()` is an error in IE8. Use `mySet['delete']()` instead.","The test suite for this polyfill is derived from work of Andrea Giammarchi which is [published under an MIT licence](https://github.com/WebReflection/es6-collections)"],"baseDir":"Set","hasTests":true,"rawSource":"\n// Set\n(function(global) {\n\n\n\t// Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.\n\tvar undefMarker = Symbol('undef');\n\n\t// NaN cannot be found in an array using indexOf, so we encode NaNs using a private symbol.\n\tvar NaNMarker = Symbol('NaN');\n\n\tfunction encodeVal(data) {\n\t\treturn Number.isNaN(data) ? NaNMarker : data;\n\t}\n\tfunction decodeVal(encodedData) {\n\t\treturn (encodedData === NaNMarker) ? NaN : encodedData;\n\t}\n\n\tfunction makeIterator(setInst, getter) {\n\t\tvar nextIdx = 0;\n\t\tvar done = false;\n\t\treturn {\n\t\t\tnext: function() {\n\t\t\t\tif (nextIdx === setInst._values.length) done = true;\n\t\t\t\tif (!done) {\n\t\t\t\t\twhile (setInst._values[nextIdx] === undefMarker) nextIdx++;\n\t\t\t\t\treturn {value: getter.call(setInst, nextIdx++), done: false};\n\t\t\t\t} else {\n\t\t\t\t\treturn {done:true};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction calcSize(setInst) {\n\t\tvar size = 0;\n\t\tfor (var i=0, s=setInst._values.length; i<s; i++) {\n\t\t\tif (setInst._values[i] !== undefMarker) size++;\n\t\t}\n\t\treturn size;\n\t}\n\n\tvar ACCESSOR_SUPPORT = true;\n\n\tvar Set = function(data) {\n\t\tthis._values = [];\n\n\t\t// If `data` is iterable (indicated by presence of a forEach method), pre-populate the set\n\t\tdata && (typeof data.forEach === 'function') && data.forEach(function (item) {\n\t\t\tthis.add.call(this, item);\n\t\t}, this);\n\n\t\tif (!ACCESSOR_SUPPORT) this.size = calcSize(this);\n\t};\n\n\t// Some old engines do not support ES5 getters/setters.  Since Set only requires these for the size property, we can fall back to setting the size property statically each time the size of the set changes.\n\ttry {\n\t\tObject.defineProperty(Set.prototype, 'size', {\n\t\t\tget: function() {\n\t\t\t\treturn calcSize(this);\n\t\t\t}\n\t\t});\n\t} catch(e) {\n\t\tACCESSOR_SUPPORT = false;\n\t}\n\n\tSet.prototype['add'] = function(value) {\n\t\tvalue = encodeVal(value);\n\t\tif (this._values.indexOf(value) === -1) {\n\t\t\tthis._values.push(value);\n\t\t\tif (!ACCESSOR_SUPPORT) this.size = calcSize(this);\n\t\t}\n\t\treturn this;\n\t};\n\tSet.prototype['has'] = function(value) {\n\t\treturn (this._values.indexOf(encodeVal(value)) !== -1);\n\t};\n\tSet.prototype['delete'] = function(value) {\n\t\tvar idx = this._values.indexOf(encodeVal(value));\n\t\tif (idx === -1) return false;\n\t\tthis._values[idx] = undefMarker;\n\t\tif (!ACCESSOR_SUPPORT) this.size = calcSize(this);\n\t\treturn true;\n\t};\n\tSet.prototype['clear'] = function() {\n\t\tthis._values = [];\n\t\tif (!ACCESSOR_SUPPORT) this.size = 0;\n\t};\n\tSet.prototype['values'] =\n\tSet.prototype['keys'] = function() {\n\t\treturn makeIterator(this, function(i) { return decodeVal(this._values[i]); });\n\t};\n\tSet.prototype['entries'] =\n\tSet.prototype[Symbol.iterator] = function() {\n\t\treturn makeIterator(this, function(i) { return [decodeVal(this._values[i]), decodeVal(this._values[i])]; });\n\t};\n\tSet.prototype['forEach'] = function(callbackFn, thisArg) {\n\t\tthisArg = thisArg || global;\n\t\tvar iterator = this.entries();\n\t\tresult = iterator.next();\n\t\twhile (result.done === false) {\n\t\t\tcallbackFn.call(thisArg, result.value[1], result.value[0], this);\n\t\t\tresult = iterator.next();\n\t\t}\n\t};\n\tSet.prototype['constructor'] =\n\tSet.prototype[Symbol.species] = Set;\n\n\tSet.length = 0;\n\n\t// Export the object\n\tthis.Set = Set;\n\n})(this);\n","minSource":"!function(t){function e(t){return Number.isNaN(t)?o:t}function n(t){return t===o?NaN:t}function r(t,e){var n=0,r=!1;return{next:function(){if(n===t._values.length&&(r=!0),r)return{done:!0};for(;t._values[n]===s;)n++;return{value:e.call(t,n++),done:!1}}}}function i(t){for(var e=0,n=0,r=t._values.length;r>n;n++)t._values[n]!==s&&e++;return e}var s=Symbol(\"undef\"),o=Symbol(\"NaN\"),u=!0,a=function(t){this._values=[],t&&\"function\"==typeof t.forEach&&t.forEach(function(t){this.add.call(this,t)},this),u||(this.size=i(this))};try{Object.defineProperty(a.prototype,\"size\",{get:function(){return i(this)}})}catch(l){u=!1}a.prototype.add=function(t){return t=e(t),-1===this._values.indexOf(t)&&(this._values.push(t),u||(this.size=i(this))),this},a.prototype.has=function(t){return-1!==this._values.indexOf(e(t))},a.prototype[\"delete\"]=function(t){var n=this._values.indexOf(e(t));return-1===n?!1:(this._values[n]=s,u||(this.size=i(this)),!0)},a.prototype.clear=function(){this._values=[],u||(this.size=0)},a.prototype.values=a.prototype.keys=function(){return r(this,function(t){return n(this._values[t])})},a.prototype.entries=a.prototype[Symbol.iterator]=function(){return r(this,function(t){return[n(this._values[t]),n(this._values[t])]})},a.prototype.forEach=function(e,n){n=n||t;var r=this.entries();for(result=r.next();result.done===!1;)e.call(n,result.value[1],result.value[0],this),result=r.next()},a.prototype.constructor=a.prototype[Symbol.species]=a,a.length=0,this.Set=a}(this);","detectSource":"'Set' in this && (function() {\n\treturn (new Set([1,2])).size === 2;\n}())"}