aboutsummaryrefslogtreecommitdiff
path: root/src/console/completion.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-17 09:00:41 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-17 09:00:41 +0900
commitcd4708898134f5966f87df4aeaa8ed8c60e7943f (patch)
treedb082d9cb2ec426010556dbc24ab439c9757afbd /src/console/completion.js
parentc5529958d53146c8c6826673abe6431a19f1924d (diff)
parent9ae814dfe45426f8df9b89b305392770344a7d50 (diff)
Merge branch 'lint'
Diffstat (limited to 'src/console/completion.js')
-rw-r--r--src/console/completion.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/console/completion.js b/src/console/completion.js
index 0c21cb0..4c69afb 100644
--- a/src/console/completion.js
+++ b/src/console/completion.js
@@ -3,15 +3,16 @@ export default class Completion {
if (typeof completions.length !== 'number') {
throw new TypeError('completions does not have a length in number');
}
- this.completions = completions
+ this.completions = completions;
this.index = 0;
}
prev() {
- if (this.completions.length === 0) {
+ let length = this.completions.length;
+ if (length === 0) {
return null;
}
- this.index = (this.index + this.completions.length - 1) % this.completions.length
+ this.index = (this.index + length - 1) % length;
return this.completions[this.index];
}
@@ -20,7 +21,7 @@ export default class Completion {
return null;
}
let item = this.completions[this.index];
- this.index = (this.index + 1) % this.completions.length
+ this.index = (this.index + 1) % this.completions.length;
return item;
}
}