arrayRemoveDuplicates-0263f42c.js.map 5.0 KB

1
  1. {"version":3,"file":"arrayRemoveDuplicates-0263f42c.js","sources":["../../../../Source/Core/arrayRemoveDuplicates.js"],"sourcesContent":["import Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport CesiumMath from \"./Math.js\";\n\nvar removeDuplicatesEpsilon = CesiumMath.EPSILON10;\n\n/**\n * Removes adjacent duplicate values in an array of values.\n *\n * @param {Array.<*>} [values] The array of values.\n * @param {Function} equalsEpsilon Function to compare values with an epsilon. Boolean equalsEpsilon(left, right, epsilon).\n * @param {Boolean} [wrapAround=false] Compare the last value in the array against the first value.\n * @returns {Array.<*>|undefined} A new array of values with no adjacent duplicate values or the input array if no duplicates were found.\n *\n * @example\n * // Returns [(1.0, 1.0, 1.0), (2.0, 2.0, 2.0), (3.0, 3.0, 3.0), (1.0, 1.0, 1.0)]\n * var values = [\n * new Cesium.Cartesian3(1.0, 1.0, 1.0),\n * new Cesium.Cartesian3(1.0, 1.0, 1.0),\n * new Cesium.Cartesian3(2.0, 2.0, 2.0),\n * new Cesium.Cartesian3(3.0, 3.0, 3.0),\n * new Cesium.Cartesian3(1.0, 1.0, 1.0)];\n * var nonDuplicatevalues = Cesium.PolylinePipeline.removeDuplicates(values, Cartesian3.equalsEpsilon);\n *\n * @example\n * // Returns [(1.0, 1.0, 1.0), (2.0, 2.0, 2.0), (3.0, 3.0, 3.0)]\n * var values = [\n * new Cesium.Cartesian3(1.0, 1.0, 1.0),\n * new Cesium.Cartesian3(1.0, 1.0, 1.0),\n * new Cesium.Cartesian3(2.0, 2.0, 2.0),\n * new Cesium.Cartesian3(3.0, 3.0, 3.0),\n * new Cesium.Cartesian3(1.0, 1.0, 1.0)];\n * var nonDuplicatevalues = Cesium.PolylinePipeline.removeDuplicates(values, Cartesian3.equalsEpsilon, true);\n *\n * @private\n */\nfunction arrayRemoveDuplicates(values, equalsEpsilon, wrapAround) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"equalsEpsilon\", equalsEpsilon);\n //>>includeEnd('debug');\n\n if (!defined(values)) {\n return undefined;\n }\n\n wrapAround = defaultValue(wrapAround, false);\n\n var length = values.length;\n if (length < 2) {\n return values;\n }\n\n var i;\n var v0;\n var v1;\n\n for (i = 1; i < length; ++i) {\n v0 = values[i - 1];\n v1 = values[i];\n if (equalsEpsilon(v0, v1, removeDuplicatesEpsilon)) {\n break;\n }\n }\n\n if (i === length) {\n if (\n wrapAround &&\n equalsEpsilon(\n values[0],\n values[values.length - 1],\n removeDuplicatesEpsilon\n )\n ) {\n return values.slice(1);\n }\n return values;\n }\n\n var cleanedvalues = values.slice(0, i);\n for (; i < length; ++i) {\n // v0 is set by either the previous loop, or the previous clean point.\n v1 = values[i];\n if (!equalsEpsilon(v0, v1, removeDuplicatesEpsilon)) {\n cleanedvalues.push(v1);\n v0 = v1;\n }\n }\n\n if (\n wrapAround &&\n cleanedvalues.length > 1 &&\n equalsEpsilon(\n cleanedvalues[0],\n cleanedvalues[cleanedvalues.length - 1],\n removeDuplicatesEpsilon\n )\n ) {\n cleanedvalues.shift();\n }\n\n return cleanedvalues;\n}\nexport default arrayRemoveDuplicates;\n"],"names":["CesiumMath","Check","defined","defaultValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAKA,IAAI,uBAAuB,GAAGA,gBAAU,CAAC,SAAS,CAAC;AACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE;EAClE;EACA,EAAEC,WAAK,CAAC,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;EAChD;AACA;EACA,EAAE,IAAI,CAACC,YAAO,CAAC,MAAM,CAAC,EAAE;EACxB,IAAI,OAAO,SAA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