File tree 3 files changed +5
-7
lines changed
3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ import { ArrayResultError, isArrayResult } from "./array_result.ts";
16
16
import { loadCustomDictionary } from "./dictionary.ts" ;
17
17
import { checkLocalStorage , setIgnoreError } from "./local_storage.ts" ;
18
18
import { translate } from "./mod.ts" ;
19
- import { clearCache } from "./parser/parser_lib.ts" ;
20
19
import { settings } from "./settings.ts" ;
21
20
import {
22
21
loadFromElements ,
@@ -219,7 +218,6 @@ function main(): void {
219
218
confirmButton . addEventListener ( "click" , ( ) => {
220
219
loadFromElements ( ) ;
221
220
updateLabel ( ) ;
222
- clearCache ( ) ;
223
221
settingsDialogBox . close ( ) ;
224
222
} ) ;
225
223
cancelButton . addEventListener ( "click" , ( ) => {
@@ -271,7 +269,6 @@ function main(): void {
271
269
try {
272
270
loadCustomDictionary ( value ) ;
273
271
setIgnoreError ( DICTIONARY_KEY , value ) ;
274
- clearCache ( ) ;
275
272
customDictionaryDialogBox . close ( ) ;
276
273
} catch ( error ) {
277
274
const errors = flattenError ( error ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import { translate as rawTranslate } from "./translator/translator.ts";
8
8
9
9
export { ArrayResultError , type ArrayResultOptions } from "./array_result.ts" ;
10
10
export { loadCustomDictionary } from "./dictionary.ts" ;
11
- export { clearCache } from "./parser/parser_lib.ts" ;
12
11
export {
13
12
defaultSettings ,
14
13
type RedundancySettings ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ type InnerParser<T> = (input: Input) => ParserResult<T>;
10
10
let source = "" ;
11
11
const allMemo : Set < WeakRef < SourceMemo < unknown > > > = new Set ( ) ;
12
12
13
- export function clearCache ( ) : void {
13
+ function clearCache ( ) : void {
14
14
for ( const memo of allMemo ) {
15
15
const ref = memo . deref ( ) ;
16
16
if ( ref == null ) {
@@ -68,9 +68,11 @@ export class Parser<T> {
68
68
) ;
69
69
}
70
70
generateParser ( ) : ( source : string ) => ArrayResult < T > {
71
- return ( input ) =>
72
- this . rawParser ( { source : input , position : 0 } )
71
+ return ( input ) => {
72
+ clearCache ( ) ;
73
+ return this . rawParser ( { source : input , position : 0 } )
73
74
. map ( ( { value } ) => value ) ;
75
+ } ;
74
76
}
75
77
map < U > ( mapper : ( value : T ) => U ) : Parser < U > {
76
78
return new Parser ( ( input ) =>
You can’t perform that action at this time.
0 commit comments