Skip to content

Commit

Permalink
fixup! js/common: Helper for Object.freeze from Go
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed Apr 19, 2022
1 parent 6ed3c84 commit e2869f8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions js/common/frozen_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ import (

// FreezeObject replicates the JavaScript Object.freeze function.
func FreezeObject(rt *goja.Runtime, obj goja.Value) error {
global := rt.GlobalObject().Get("Object")
freeze, _ := goja.AssertFunction(global.ToObject(rt).Get("freeze"))
isFrozen, _ := goja.AssertFunction(rt.GlobalObject().Get("Object").ToObject(rt).Get("isFrozen"))
global := rt.GlobalObject().Get("Object").ToObject(rt)
freeze, ok := goja.AssertFunction(global.Get("freeze"))
if !ok {
panic(fmt.Errorf("failed to get the Object.freeze function from the runtime"))
}
isFrozen, ok := goja.AssertFunction(global.Get("isFrozen"))
if !ok {
panic(fmt.Errorf("failed to get the Object.isFrozen function from the runtime"))
}
fobj := &freezing{
global: global,
rt: rt,
Expand Down

0 comments on commit e2869f8

Please sign in to comment.