app/assets/htmls/gobstones-code-runner.html in gobstones-code-runner-0.9.0 vs app/assets/htmls/gobstones-code-runner.html in gobstones-code-runner-0.10.0

- old
+ new

@@ -4172,34 +4172,40 @@ } } run({ ast, request, throttle, callbacks }) { const { states, returnValue, actualReturnValue } = this._interpret(ast, request); - this._runWithThrottle(states, { returnValue, actualReturnValue }, throttle, callbacks); + this._runWithThrottle(states, { returnValue, actualReturnValue }, throttle, request, callbacks); } clear() { this.handles.forEach(clearInterval); this.handles = []; } - _runWithThrottle(states, { returnValue, actualReturnValue }, throttle, { onResult, onStop, onReturnValue }) { + _runWithThrottle(states, { returnValue, actualReturnValue }, throttle, request, { onResult, onStop, onReturnValue }) { const _onResult = (state) => onResult(state.board || state, state); const _onEnd = () => { onStop("end"); onReturnValue(returnValue, actualReturnValue); } - if (throttle === 0) { - const lastState = states[states.length - 1]; - _onResult(lastState); - return _onEnd(); - } - const firstState = states[0]; _onResult(firstState); if (states.length === 1) return _onEnd(); + + if (throttle === 0) { + const initialBoardTime = request.initialBoardTime || 0; + + setTimeout(() => { + const lastState = states[states.length - 1]; + _onResult(lastState); + _onEnd(); + }, initialBoardTime); + + return; + } this.handles = states.slice(1).map((state, i) => { const ii = i + 1; return setTimeout(() => { \ No newline at end of file