MCPcopy Create free account
hub / github.com/Snapchat/Valdi / jsArrayToValue

Function jsArrayToValue

valdi/src/valdi/runtime/JavaScript/JavaScriptUtils.cpp:492–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490 if (!exceptionTracker) {
491 return output;
492 }
493
494 if (output.isUndefined()) {
495 // No proxy objects found in the object, marshall as a plain map
496 return untypedJsObjectToValue(jsContext, jsValue, referenceInfoBuilder, exceptionTracker);
497 } else {
498 // Proxy object found, return it
499 return output;
500 }
501}
502
503size_t jsArrayGetLength(IJavaScriptContext& jsContext, const JSValue& jsValue, JSExceptionTracker& exceptionTracker) {
504 static auto kLength = STRING_LITERAL("length");
505
506 auto length = jsContext.getObjectProperty(jsValue, jsContext.getPropertyNameCached(kLength), exceptionTracker);
507 if (!exceptionTracker) {
508 return 0;
509 }
510
511 return static_cast<size_t>(jsContext.valueToInt(length.get(), exceptionTracker));
512}
513
514Value jsArrayToValue(IJavaScriptContext& jsContext,
515 const JSValue& jsValue,
516 const ReferenceInfoBuilder& referenceInfoBuilder,
517 JSExceptionTracker& exceptionTracker) {
518 auto arrayLength = jsArrayGetLength(jsContext, jsValue, exceptionTracker);
519 if (!exceptionTracker) {
520 return Value::undefined();
521 }
522

Callers 1

jsValueToValueFunction · 0.85

Calls 7

jsArrayGetLengthFunction · 0.85
jsValueToValueFunction · 0.85
withArrayIndexMethod · 0.80
getMethod · 0.65
ValueClass · 0.50
emplaceMethod · 0.45

Tested by

no test coverage detected