File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -5,27 +5,27 @@ import { ArrayResult, ArrayResultError } from "../array_result.ts";
5
5
6
6
type ParserResult < T > = ArrayResult < Readonly < { value : T ; length : number } > > ;
7
7
type InnerParser < T > = ( input : number ) => ParserResult < T > ;
8
- type Memo < T > = Map < number , MemoizationCacheResult < ParserResult < T > > > ;
8
+ type Cache < T > = Map < number , MemoizationCacheResult < ParserResult < T > > > ;
9
9
10
10
let currentSource = "" ;
11
- const allMemo : Set < WeakRef < Memo < unknown > > > = new Set ( ) ;
11
+ const allCache : Set < WeakRef < Cache < unknown > > > = new Set ( ) ;
12
12
13
13
export class Parser < T > {
14
14
readonly rawParser : InnerParser < T > ;
15
15
constructor ( parser : InnerParser < T > ) {
16
- const cache : Memo < T > = new Map ( ) ;
17
- allMemo . add ( new WeakRef ( cache ) ) ;
18
- this . rawParser = memoize < InnerParser < T > , number , Memo < T > > (
16
+ const cache : Cache < T > = new Map ( ) ;
17
+ allCache . add ( new WeakRef ( cache ) ) ;
18
+ this . rawParser = memoize < InnerParser < T > , number , Cache < T > > (
19
19
parser ,
20
20
{ cache } ,
21
21
) ;
22
22
}
23
23
parse ( source : string ) : ArrayResult < T > {
24
24
currentSource = source ;
25
- for ( const memo of allMemo ) {
25
+ for ( const memo of allCache ) {
26
26
const ref = memo . deref ( ) ;
27
27
if ( ref == null ) {
28
- allMemo . delete ( memo ) ;
28
+ allCache . delete ( memo ) ;
29
29
} else {
30
30
ref . clear ( ) ;
31
31
}
You can’t perform that action at this time.
0 commit comments