inputTest.js 434 B

12345678910111213141516171819
  1. import { Input } from './../io/input';
  2. export class InputTest extends Input {
  3. constructor (inputList) {
  4. super();
  5. this.index = 0;
  6. this.inputList = inputList;
  7. }
  8. requestInput (callback) {
  9. if(this.index < this.inputList.length) {
  10. callback(this.inputList[this.index]);
  11. this.index++;
  12. } else {
  13. throw new Error('The amount of requests exceeded the amount of available inputs');
  14. }
  15. }
  16. }