MCPcopy Create free account
hub / github.com/NativeScript/android / ForEach

Method ForEach

test-app/runtime/src/main/cpp/URLSearchParamsImpl.cpp:155–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153 }
154
155 void URLSearchParamsImpl::ForEach(const v8::FunctionCallbackInfo<v8::Value> &args) {
156 URLSearchParamsImpl *ptr = GetPointer(args.This());
157 auto isolate = args.GetIsolate();
158 auto context = isolate->GetCurrentContext();
159 if (ptr == nullptr) {
160 return;
161 }
162 auto callback = args[0].As<v8::Function>();
163 auto searchParams = args.This();
164 // Use thisArg if provided, otherwise undefined
165 auto thisArg = args.Length() > 1 ? args[1] : v8::Undefined(isolate).As<v8::Value>();
166 // Use get_entries() to correctly handle duplicate keys
167 auto entries = ptr->GetURLSearchParams()->get_entries();
168 while (entries.has_next()) {
169 auto entry = entries.next();
170 if (entry) {
171 auto& [key, value] = entry.value();
172 // Per spec, forEach callback receives (value, key, searchParams)
173 v8::Local<v8::Value> callbackArgs[] = {
174 ArgConverter::ConvertToV8String(isolate, value.data()),
175 ArgConverter::ConvertToV8String(isolate, key.data()),
176 searchParams,
177 };
178 v8::Local<v8::Value> result;
179 if (!callback->Call(context, thisArg, 3, callbackArgs).ToLocal(&result)) {
180 // If the callback throws an exception, stop iteration
181 return;
182 }
183 }
184 }
185 }
186
187 void URLSearchParamsImpl::Get(const v8::FunctionCallbackInfo<v8::Value> &args) {
188 URLSearchParamsImpl *ptr = GetPointer(args.This());

Callers

nothing calls this directly

Calls 11

ThisMethod · 0.80
get_entriesMethod · 0.80
GetURLSearchParamsMethod · 0.80
has_nextMethod · 0.80
valueMethod · 0.80
ToLocalMethod · 0.80
GetIsolateMethod · 0.45
LengthMethod · 0.45
nextMethod · 0.45
dataMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected