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 e2869f8 commit 4346b79
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions js/common/frozen_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@ func (f *freezing) deepFreeze(val goja.Value) error {

for _, key := range o.Keys() {
prop := o.Get(key)
if prop != nil {
frozen, err := f.isFrozen(goja.Undefined(), prop)
if err != nil {
return err
}
if !frozen.ToBoolean() { // prevent cycles
if err = f.deepFreeze(prop); err != nil {
return fmt.Errorf("deep freezing the property %s failed: %w", key, err)
}
}
if prop == nil {
continue
}
frozen, err := f.isFrozen(goja.Undefined(), prop)
if err != nil {
return err
}
if frozen.ToBoolean() { // prevent cycles
continue
}
if err = f.deepFreeze(prop); err != nil {
return fmt.Errorf("deep freezing the property %s failed: %w", key, err)
}
}

Expand Down

0 comments on commit 4346b79

Please sign in to comment.