File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ import {
2626import { translate } from "./translator/translator.ts" ;
2727
2828const DICTIONARY_AUTO_PARSE_THRESHOLD = 9000 ;
29- const PAGE_SIZE = 100 ;
29+ const INITIAL_PAGE_SIZE = 100 ;
30+ const MAX_PAGE_SIZE = 10000 ;
3031
3132// never change this
3233const DICTIONARY_KEY = "dictionary" ;
@@ -190,6 +191,7 @@ function main() {
190191
191192 // state for output
192193 let output : null | Generator < Result < string > > = null ;
194+ let size = 0 ;
193195
194196 // load custom dictionary
195197 if ( ! currentDictionary . isError ( ) ) {
@@ -254,13 +256,14 @@ function main() {
254256 errorDisplay . innerText = "" ;
255257 loadMoreButton . style . display = "" ;
256258 output = translate ( inputTextBox . value ) . iterable ( ) ;
259+ size = 0 ;
257260 moreOutput ( ) ;
258261 }
259262 function moreOutput ( ) {
260263 const errors : Array < ResultError > = [ ] ;
261264 let yielded = false ;
262265 let i = 0 ;
263- while ( i < PAGE_SIZE ) {
266+ while ( i < Math . min ( INITIAL_PAGE_SIZE * 2 ** size , MAX_PAGE_SIZE ) ) {
264267 const next = output ! . next ( ) ;
265268 if ( ! next . done ) {
266269 const result = next . value ;
@@ -282,6 +285,9 @@ function main() {
282285 break ;
283286 }
284287 }
288+ if ( size < Math . log2 ( MAX_PAGE_SIZE / INITIAL_PAGE_SIZE ) ) {
289+ size ++ ;
290+ }
285291 if ( ! yielded ) {
286292 switch ( errors . length ) {
287293 case 0 :
You can’t perform that action at this time.
0 commit comments