add exists
This commit is contained in:
parent
6a20519361
commit
b69e650d54
4
file.go
4
file.go
@ -17,6 +17,10 @@ var fileMD string
|
||||
|
||||
func init() {
|
||||
obj := map[string]any{
|
||||
"exists": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
|
||||
args := gojs.MakeArgs(&argsIn, vm).Check(1)
|
||||
return vm.ToValue(u.FileExists(args.Path(0)))
|
||||
},
|
||||
"read": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
|
||||
args := gojs.MakeArgs(&argsIn, vm).Check(1)
|
||||
if r, err := u.ReadFile(args.Path(0)); err == nil {
|
||||
|
22
file.ts
22
file.ts
@ -1,6 +1,7 @@
|
||||
// just for develop
|
||||
|
||||
export default {
|
||||
exists,
|
||||
read,
|
||||
readBytes,
|
||||
write,
|
||||
@ -13,16 +14,17 @@ export default {
|
||||
cache
|
||||
}
|
||||
|
||||
function read(filename: string): string {return ''}
|
||||
function readBytes(filename: string): any {return null}
|
||||
function write(filename: string, data: any): void {}
|
||||
function dir(filename: string): Array<FileInfo> {return null as any}
|
||||
function stat(filename: string): FileInfo {return null as any}
|
||||
function find(filename: string): string {return ''}
|
||||
function remove(filename: string): void {}
|
||||
function rename(from: string, to: string): void {}
|
||||
function copy(from: string, to: string): void {}
|
||||
function cache(filename: string, isCompress: boolean): void {}
|
||||
function exists(filename: string): boolean { return false }
|
||||
function read(filename: string): string { return '' }
|
||||
function readBytes(filename: string): any { return null }
|
||||
function write(filename: string, data: any): void { }
|
||||
function dir(filename: string): Array<FileInfo> { return null as any }
|
||||
function stat(filename: string): FileInfo { return null as any }
|
||||
function find(filename: string): string { return '' }
|
||||
function remove(filename: string): void { }
|
||||
function rename(from: string, to: string): void { }
|
||||
function copy(from: string, to: string): void { }
|
||||
function cache(filename: string, isCompress: boolean): void { }
|
||||
|
||||
interface FileInfo {
|
||||
name: string
|
||||
|
Loading…
Reference in New Issue
Block a user