MCPcopy Index your code
hub / github.com/NativeScript/capacitor / _getter

Method _getter

testing/browser.ts:397–477  ·  view source on GitHub ↗
(target: any, prop: any, _receiver: any)

Source from the content-addressed store, hash-verified

395
396 // eslint-disable-next-line @typescript-eslint/no-unused-vars
397 _getter(target: any, prop: any, _receiver: any) {
398 if (DEBUGGING) {
399 if (
400 typeof prop !== 'symbol' &&
401 prop !== '__func' &&
402 prop !== '__isProxy' &&
403 prop !== 'then'
404 ) {
405 nativeLog('Getter:', target[NS_PROXY_FULL_PROP] + '.' + prop);
406 }
407 }
408 switch (prop) {
409 case 'then':
410 return undefined;
411 case 'symbol':
412 return null;
413 case 'toString':
414 return function () {
415 return '[NativeScript Proxy Object]';
416 };
417 case '__isProxy':
418 return true;
419 case '__func':
420 return target;
421 case 'set':
422 return value => {
423 return NativeScriptProxy.instance.marshall(
424 NS_MARSHALL_SET,
425 target,
426 target[NS_PROXY_PROP],
427 value,
428 );
429 };
430 case 'get':
431 nativeLog(
432 'Getting Value',
433 target[NS_PROXY_IS_FUNCTION] ? 'Function' : '',
434 target[NS_PROXY_HAS_WAITING_VALUE] ? 'Waiting' : '',
435 );
436 if (
437 target[NS_PROXY_IS_FUNCTION] ||
438 target[NS_PROXY_HAS_WAITING_VALUE]
439 ) {
440 if (typeof target[NS_PROXY_VALUE] !== 'undefined') {
441 const t = Promise.resolve(target[NS_PROXY_VALUE]);
442 target[NS_PROXY_VALUE] = undefined;
443 target[NS_PROXY_HAS_WAITING_VALUE] = false;
444 return t;
445 }
446
447 // If the Function call is still pending, then we have to wait until it is done before we send the get...
448 if (target[NS_FUNCTION_PENDING]) {
449 return new Promise(resolve => {
450 target[NS_FUNCTION_PENDING_LIST].push(resolve);
451 }).then(() => {
452 if (target[NS_PROXY_HAS_WAITING_VALUE]) {
453 if (typeof target[NS_PROXY_VALUE] !== 'undefined') {
454 const t = Promise.resolve(target[NS_PROXY_VALUE]);

Callers 1

browser.tsFile · 0.80

Calls 3

nativeLogFunction · 0.85
marshallMethod · 0.80
getProxyMethod · 0.80

Tested by

no test coverage detected