diff --git a/jsmod.go b/jsmod.go index 7110f98..d6c548d 100644 --- a/jsmod.go +++ b/jsmod.go @@ -20,6 +20,14 @@ func Get(ctx context.Context, key string) any { return nil } +// NewContext returns a new context with the provided injection map. +func NewContext(parent context.Context, injects map[string]any) context.Context { + if parent == nil { + parent = context.Background() + } + return context.WithValue(parent, internalContextKey, injects) +} + // IsSafeMode checks if the provided context indicates that the execution is in safe mode. func IsSafeMode(ctx context.Context) bool { if sm, ok := Get(ctx, "SafeMode").(bool); ok {