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 {
26
26
import { translate } from "./translator/translator.ts" ;
27
27
28
28
const DICTIONARY_AUTO_PARSE_THRESHOLD = 9000 ;
29
- const PAGE_SIZE = 100 ;
29
+ const INITIAL_PAGE_SIZE = 100 ;
30
+ const MAX_PAGE_SIZE = 10000 ;
30
31
31
32
// never change this
32
33
const DICTIONARY_KEY = "dictionary" ;
@@ -190,6 +191,7 @@ function main() {
190
191
191
192
// state for output
192
193
let output : null | Generator < Result < string > > = null ;
194
+ let size = 0 ;
193
195
194
196
// load custom dictionary
195
197
if ( ! currentDictionary . isError ( ) ) {
@@ -254,13 +256,14 @@ function main() {
254
256
errorDisplay . innerText = "" ;
255
257
loadMoreButton . style . display = "" ;
256
258
output = translate ( inputTextBox . value ) . iterable ( ) ;
259
+ size = 0 ;
257
260
moreOutput ( ) ;
258
261
}
259
262
function moreOutput ( ) {
260
263
const errors : Array < ResultError > = [ ] ;
261
264
let yielded = false ;
262
265
let i = 0 ;
263
- while ( i < PAGE_SIZE ) {
266
+ while ( i < Math . min ( INITIAL_PAGE_SIZE * 2 ** size , MAX_PAGE_SIZE ) ) {
264
267
const next = output ! . next ( ) ;
265
268
if ( ! next . done ) {
266
269
const result = next . value ;
@@ -282,6 +285,9 @@ function main() {
282
285
break ;
283
286
}
284
287
}
288
+ if ( size < Math . log2 ( MAX_PAGE_SIZE / INITIAL_PAGE_SIZE ) ) {
289
+ size ++ ;
290
+ }
285
291
if ( ! yielded ) {
286
292
switch ( errors . length ) {
287
293
case 0 :
You can’t perform that action at this time.
0 commit comments