From eb6b5d7258d386a7d0d07d3837b4e850564629a2 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Thu, 14 Nov 2024 09:54:52 +0000 Subject: [PATCH] Refactor to a switch This allows us to work with a more go way of working with conditional branching. --- js/modules/gomodule.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/modules/gomodule.go b/js/modules/gomodule.go index 8193b2fdde4..21c06cc3f8a 100644 --- a/js/modules/gomodule.go +++ b/js/modules/gomodule.go @@ -25,10 +25,14 @@ func (gm *goModule) Instantiate(rt *sobek.Runtime) (sobek.CyclicModuleInstance, if gm.exportedNames == nil { named := mi.Exports().Named - gm.exportedNames = make([]string, len(named)) - for name := range named { - gm.exportedNames = append(gm.exportedNames, name) + switch { + default: + gm.exportedNames = make([]string, len(named)) + for name := range named { + gm.exportedNames = append(gm.exportedNames, name) + } } + for _, callback := range gm.exportedNamesCallbacks { callback(gm.exportedNames) }