48 lines
1.0 KiB
Markdown
48 lines
1.0 KiB
Markdown
# file for GoJS
|
|
|
|
## usage
|
|
|
|
```go
|
|
import (
|
|
"apigo.cc/gojs"
|
|
_ "apigo.cc/gojs/file"
|
|
)
|
|
|
|
func main() {
|
|
r, err := gojs.Run(`
|
|
import file from 'apigo.cc/gojs/file'
|
|
|
|
function main(args){
|
|
return file.read('test.txt')
|
|
}
|
|
`, "test.js")
|
|
|
|
fmt.Println(r, err)
|
|
}
|
|
```
|
|
|
|
## cache file for proformance
|
|
|
|
```javascript
|
|
import file from 'apigo.cc/gojs/file'
|
|
file.cache('test.txt', true)
|
|
file.cache('images/test.png')
|
|
```
|
|
|
|
## module.exports
|
|
|
|
```ts
|
|
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 {}
|
|
```
|
|
|
|
## full api see [file.ts](https://apigo.cc/gojs/file/file.ts)
|