client/README.md
2024-10-13 23:12:55 +08:00

71 lines
1.7 KiB
Markdown

# util for GoJS
## usage
```go
import (
"apigo.cc/gojs"
_ "apigo.cc/gojs/util"
)
func main() {
r, err := gojs.Run(`
import util from 'apigo.cc/gojs/util'
function main(args){
return util.sha512('hello 123')
}
`, "test.js")
fmt.Println(r, err, r == "27d0d415a3b14bdeb5ab5b2298ed3aed272361688927250eaef201603b84dd8bebb57cae089d6b5f1e9aee122a67917ccdf8a9ba5e499c64b35e133c7f6b007a")
}
```
## module.exports
```ts
function json(data:any)
function jsonP(data:any)
function unJson(data:string)
function yaml(data:any)
function unYaml(data:string)
function load(filename:string)
function save(filename:string, data:any)
function base64(data:any)
function unBase64(data:string)
function urlBase64(data:any)
function unUrlBase64(data:string)
function hex(data:any)
function unHex(data:string)
function aes(data:any, key:string, iv:string)
function unAes(data:string, key:string, iv:string)
function gzip(data:any)
function gunzip(data:string)
function id()
function uniqueId()
function token(size:number)
function md5(data:any)
function sha1(data:any)
function sha256(data:any)
function sha512(data:any)
function tpl(text:string, data:any, functions?:Object)
function sleep(ms:number)
function setTimeout(callback:()=>void, ms?:number, ...args:any)
function shell(cmd:string, ...args:string[])
function toDatetime(timestamp:number)
function fromDatetime(datetimeStr:string)
function toDate(timestamp:number)
function fromDate(dateStr:string)
function os()
function arch()
function joinPath(...paths:string[])
function getPathDir(path:string)
function getPathBase(path:string)
function getPathVolume(path:string)
function absPath(path:string)
function cleanPath(path:string)
function isLocalPath(path:string)
```
## full api see [util.ts](https://apigo.cc/gojs/util/util.ts)