< Summary

Information
Class: Elsa.Expressions.JavaScript.ObjectConverters.ByteArrayConverter
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/ObjectConverters/ByteArrayConverter.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 24
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TryConvert(...)100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/ObjectConverters/ByteArrayConverter.cs

#LineLine coverage
 1using System.Diagnostics.CodeAnalysis;
 2using Jint;
 3using Jint.Native;
 4using Jint.Runtime.Interop;
 5
 6namespace Elsa.Expressions.JavaScript.ObjectConverters;
 7
 8/// <summary>
 9/// Converts a byte array to a <see cref="JsValue"/> instance representing a Uint8Array.
 10/// </summary>
 11internal class ByteArrayConverter : IObjectConverter
 12{
 13    public bool TryConvert(Engine engine, object value, [NotNullWhen(true)] out JsValue? result)
 14    {
 657515        if (value is byte[] bytes)
 16        {
 617            result = engine.Intrinsics.ArrayBuffer.Construct(bytes);
 618            return true;
 19        }
 20
 656921        result = JsValue.Null;
 656922        return false;
 23    }
 24}