File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change
1
+ import { PathLike } from 'fs'
2
+
1
3
import { Adapter , SyncAdapter } from '../../core/Low.js'
2
4
import { TextFile , TextFileSync } from './TextFile.js'
3
5
4
6
export class JSONFile < T > implements Adapter < T > {
5
7
#adapter: TextFile
6
8
7
- constructor ( filename : string ) {
9
+ constructor ( filename : PathLike ) {
8
10
this . #adapter = new TextFile ( filename )
9
11
}
10
12
@@ -25,7 +27,7 @@ export class JSONFile<T> implements Adapter<T> {
25
27
export class JSONFileSync < T > implements SyncAdapter < T > {
26
28
#adapter: TextFileSync
27
29
28
- constructor ( filename : string ) {
30
+ constructor ( filename : PathLike ) {
29
31
this . #adapter = new TextFileSync ( filename )
30
32
}
31
33
Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ import { Writer } from 'steno'
7
7
import { Adapter , SyncAdapter } from '../../core/Low.js'
8
8
9
9
export class TextFile implements Adapter < string > {
10
- #filename: string
10
+ #filename: fs . PathLike
11
11
#writer: Writer
12
12
13
- constructor ( filename : string ) {
13
+ constructor ( filename : fs . PathLike ) {
14
14
this . #filename = filename
15
15
this . #writer = new Writer ( filename )
16
16
}
@@ -36,15 +36,13 @@ export class TextFile implements Adapter<string> {
36
36
}
37
37
38
38
export class TextFileSync implements SyncAdapter < string > {
39
- #tempFilename: string
40
- #filename: string
39
+ #tempFilename: fs . PathLike
40
+ #filename: fs . PathLike
41
41
42
- constructor ( filename : string ) {
42
+ constructor ( filename : fs . PathLike ) {
43
43
this . #filename = filename
44
- this . #tempFilename = path . join (
45
- path . dirname ( filename ) ,
46
- `.${ path . basename ( filename ) } .tmp` ,
47
- )
44
+ const f = filename . toString ( )
45
+ this . #tempFilename = path . join ( path . dirname ( f ) , `.${ path . basename ( f ) } .tmp` )
48
46
}
49
47
50
48
read ( ) : string | null {
You can’t perform that action at this time.
0 commit comments