Skip to content

Commit

Permalink
refactor: use for-of instead of for-in loops
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatRefrigerator committed Apr 9, 2024
1 parent 3c7b9e8 commit 0ff7847
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ export default {
const highlightData = { extraKey: extraKey, sectionTitle, sections: [] }

let index = 0
for (const summaryKey in this.routeExtras[extraKey].summary) {
const summary = this.routeExtras[extraKey].summary[summaryKey]
for (const summary of this.routeExtras[extraKey].summary) {
const polylineData = this.buildExtraHighlightPolylineData(extraKey, index, summary.value)
highlightData.sections.push(polylineData)
index++
Expand Down
20 changes: 9 additions & 11 deletions src/fragments/map-view/map-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,16 +1156,15 @@ export default {
} else {
// Add the routes coordinates to the polyline that must
// be considered to the all features bounds
for (const rKey in this.localMapViewData.routes) {
if (this.localMapViewData.routes[rKey].geometry.coordinates) {
const coords = this.localMapViewData.routes[rKey].geometry.coordinates
for (const route of this.localMapViewData.routes) {
if (route.geometry.coordinates) {
const coords = route.geometry.coordinates
polylineData = polylineData.concat(coords)
}
}
// Add the polygons coordinates to the polyline that must
// be considered to the all features bounds
for (const pKey in this.localMapViewData.polygons) {
const polygon = this.localMapViewData.polygons[pKey]
for (const polygon of this.localMapViewData.polygons) {
if (polygon) {
const coords = PolygonUtils.flatCoordinates(polygon.geometry.coordinates)
polylineData = polylineData.concat(coords)
Expand All @@ -1189,10 +1188,10 @@ export default {
let polylineData = []
const coordinates = this.localMapViewData.routes[this.$store.getters.activeRouteIndex].geometry.coordinates
const highlightData = routeData.buildHighlightedPolylines(coordinates, this.extraInfo)
for (let key in highlightData) {
let polylines = highlightData[key].polylines
for (let plKey in polylines) {
polylineData = polylineData.concat(polylines[plKey])
for (const highlightDatum of highlightData) {
let polylines = highlightDatum.polylines
for (const polyline of polylines) {
polylineData = polylineData.concat(polyline)
}
}
return polylineData
Expand Down Expand Up @@ -1440,8 +1439,7 @@ export default {
*/
isThereAnPolygonInEditMode () {
let polygons = this.extractAvoidPolygonsFromMap()
for (let key in polygons) {
let polygon = polygons[key]
for (const polygon of polygons) {
if (polygon.editing && polygon.editing._enabled) {
return polygon
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ const routeData = {
// Build the sections
// Each section contains a label, a color and
// may contain multiple polylines
for (const key in extraInfo.sections) {
const section = extraInfo.sections[key]
for (const section of extraInfo.sections) {
const polylineHighlighted = {
label: section.label,
color: section.color,
polylines: [] // It starts empty and will be populated below
}
// Use the intervals data to extract the
// polyline data for the given interval
for (const intervalKey in section.intervals) {
const interval = section.intervals[intervalKey]
for (const interval of section.intervals) {
// since we are getting items from an array
// starting with the index 0, the amount of
// items is the final position + 1
Expand Down

0 comments on commit 0ff7847

Please sign in to comment.