Skip to content

Commit

Permalink
Added readFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
dop251 committed Feb 16, 2017
1 parent 6416a5b commit 77b8a67
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions goja/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ func run() error {
return load(vm, call)
})

vm.Set("readFile", func(name string) (string, error) {
b, err := ioutil.ReadFile(name)
if err != nil {
return "", err
}
return string(b), nil
})

if *timelimit > 0 {
time.AfterFunc(time.Duration(*timelimit)*time.Second, func() {
vm.Interrupt("timeout")
Expand Down

0 comments on commit 77b8a67

Please sign in to comment.