@@ -10,6 +10,23 @@ import { Dictionary } from "./type.ts";
10
10
const SOURCE = new URL ( "./dictionary" , import . meta. url ) ;
11
11
const DESTINATION = new URL ( "./dictionary.ts" , import . meta. url ) ;
12
12
13
+ export async function buildWithDictionary (
14
+ dictionary : Dictionary ,
15
+ ) : Promise < void > {
16
+ const json = JSON . stringify (
17
+ Object . fromEntries ( dictionary ) ,
18
+ undefined ,
19
+ 2 ,
20
+ ) ;
21
+ const code = `\
22
+ // This code is autogenerated
23
+
24
+ import { Dictionary } from "./type.ts";
25
+
26
+ export const dictionary: Dictionary = new Map(Object.entries(${ json } ));
27
+ ` ;
28
+ await Deno . writeTextFile ( DESTINATION , code ) ;
29
+ }
13
30
export async function build ( ) : Promise < boolean > {
14
31
console . log ( "Building dictionary..." ) ;
15
32
const start = performance . now ( ) ;
@@ -24,19 +41,7 @@ export async function build(): Promise<boolean> {
24
41
displayError ( text , result . errors ) ;
25
42
return false ;
26
43
}
27
- const json = JSON . stringify (
28
- Object . fromEntries ( dictionary ) ,
29
- undefined ,
30
- 2 ,
31
- ) ;
32
- const code = `\
33
- // This code is autogenerated
34
-
35
- import { Dictionary } from "./type.ts";
36
-
37
- export const dictionary: Dictionary = new Map(Object.entries(${ json } ));
38
- ` ;
39
- await Deno . writeTextFile ( DESTINATION , code ) ;
44
+ await buildWithDictionary ( dictionary ) ;
40
45
const end = performance . now ( ) ;
41
46
const total = Math . floor ( end - start ) ;
42
47
const parsing = Math . floor ( endDictionary - startDictionary ) ;
0 commit comments