Browse Source

var->let/const

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
c24db583ca
  1. 18
      client/src/types/segment_array.ts

18
client/src/types/segment_array.ts

@ -17,9 +17,9 @@ export class SegmentArray<T extends Segment> implements SegmentsSet<T> {
if(to === undefined) { if(to === undefined) {
to = Infinity; to = Infinity;
} }
var result = []; let result = [];
for(var i = 0; i < this._segments.length; i++) { for(let i = 0; i < this._segments.length; i++) {
var s = this._segments[i]; const s = this._segments[i];
if(from <= s.from && s.to <= to) { if(from <= s.from && s.to <= to) {
result.push(s); result.push(s);
} }
@ -53,10 +53,10 @@ export class SegmentArray<T extends Segment> implements SegmentsSet<T> {
} }
removeInRange(from: number, to: number): T[] { removeInRange(from: number, to: number): T[] {
var deleted = []; let deleted = [];
var newSegments = []; let newSegments = [];
for(var i = 0; i < this._segments.length; i++) { for(let i = 0; i < this._segments.length; i++) {
var s = this._segments[i]; let s = this._segments[i];
if(from <= s.from && s.to <= to) { if(from <= s.from && s.to <= to) {
this._keyToSegment.delete(s.id); this._keyToSegment.delete(s.id);
deleted.push(s); deleted.push(s);
@ -85,14 +85,14 @@ export class SegmentArray<T extends Segment> implements SegmentsSet<T> {
if(!this.has(key)) { if(!this.has(key)) {
return false; return false;
} }
var index = this._segments.findIndex(s => s.id === key); const index = this._segments.findIndex(s => s.id === key);
this._segments.splice(index, 1); this._segments.splice(index, 1);
this._keyToSegment.delete(key); this._keyToSegment.delete(key);
return true; return true;
} }
updateId(fromKey: SegmentId, toKey: SegmentId) { updateId(fromKey: SegmentId, toKey: SegmentId) {
var segment = this._keyToSegment.get(fromKey); const segment = this._keyToSegment.get(fromKey);
this._keyToSegment.delete(fromKey); this._keyToSegment.delete(fromKey);
segment.id = toKey; segment.id = toKey;
this._keyToSegment.set(toKey, segment); this._keyToSegment.set(toKey, segment);

Loading…
Cancel
Save