File tree Expand file tree Collapse file tree 3 files changed +5
-7
lines changed
Expand file tree Collapse file tree 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";
1616import { loadCustomDictionary } from "./dictionary.ts" ;
1717import { checkLocalStorage , setIgnoreError } from "./local_storage.ts" ;
1818import { translate } from "./mod.ts" ;
19- import { clearCache } from "./parser/parser_lib.ts" ;
2019import { settings } from "./settings.ts" ;
2120import {
2221 loadFromElements ,
@@ -219,7 +218,6 @@ function main(): void {
219218 confirmButton . addEventListener ( "click" , ( ) => {
220219 loadFromElements ( ) ;
221220 updateLabel ( ) ;
222- clearCache ( ) ;
223221 settingsDialogBox . close ( ) ;
224222 } ) ;
225223 cancelButton . addEventListener ( "click" , ( ) => {
@@ -271,7 +269,6 @@ function main(): void {
271269 try {
272270 loadCustomDictionary ( value ) ;
273271 setIgnoreError ( DICTIONARY_KEY , value ) ;
274- clearCache ( ) ;
275272 customDictionaryDialogBox . close ( ) ;
276273 } catch ( error ) {
277274 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";
88
99export { ArrayResultError , type ArrayResultOptions } from "./array_result.ts" ;
1010export { loadCustomDictionary } from "./dictionary.ts" ;
11- export { clearCache } from "./parser/parser_lib.ts" ;
1211export {
1312 defaultSettings ,
1413 type RedundancySettings ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ type InnerParser<T> = (input: Input) => ParserResult<T>;
1010let source = "" ;
1111const allMemo : Set < WeakRef < SourceMemo < unknown > > > = new Set ( ) ;
1212
13- export function clearCache ( ) : void {
13+ function clearCache ( ) : void {
1414 for ( const memo of allMemo ) {
1515 const ref = memo . deref ( ) ;
1616 if ( ref == null ) {
@@ -68,9 +68,11 @@ export class Parser<T> {
6868 ) ;
6969 }
7070 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 } )
7374 . map ( ( { value } ) => value ) ;
75+ } ;
7476 }
7577 map < U > ( mapper : ( value : T ) => U ) : Parser < U > {
7678 return new Parser ( ( input ) =>
You can’t perform that action at this time.
0 commit comments