diff options
author | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2022-06-13 04:31:31 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2022-06-13 04:31:31 +0300 |
commit | 05626592208f56d88523887e2b80c0514f8ac210 (patch) | |
tree | b0db34890e7366008754e975a8f28e878c5b28bf /helpers.go |
initial
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 + } +} |