diff options
Diffstat (limited to 'helpers.go')
-rw-r--r-- | helpers.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/helpers.go b/helpers.go new file mode 100644 index 0000000..a842899 --- /dev/null +++ b/helpers.go @@ -0,0 +1,12 @@ +package lexpr + +import "context" + +func (l *Lexpr) OneResult(ctx context.Context, expression string) (any, error) { + select { + case r := <-l.Eval(ctx, expression): + return r.Value, r.Error + case <-ctx.Done(): + return nil, nil + } +} |