From b82e66e59699d433c952683942b164400acd199e Mon Sep 17 00:00:00 2001 From: AI Engineer Date: Wed, 10 Jun 2026 10:09:55 +0800 Subject: [PATCH] feat: add NewContext helper (by AI) --- jsmod.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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 {