MCPcopy Create free account
hub / github.com/GNOME/gjs / keysCommand

Function keysCommand

modules/script/_bootstrap/debugger.js:443–470  ·  view source on GitHub ↗
(rest)

Source from the content-addressed store, hash-verified

441expressions, or $$ for the most recently printed expression.`;
442
443function keysCommand(rest) {
444 if (!rest) {
445 print("Missing argument. See 'help keys'");
446 return;
447 }
448
449 const result = evalInFrame(rest);
450 if (!result)
451 return;
452
453 const dv = result.value;
454 if (!(dv instanceof Debugger.Object)) {
455 print(`${rest} is ${dvToString(dv)}, not an object`);
456 return;
457 }
458 const names = dv.getOwnPropertyNames();
459 const symbols = dv.getOwnPropertySymbols();
460 const privateFields = dv.getOwnPrivateProperties();
461 const keys = [
462 ...names.map(s => `"${s}"`),
463 ...symbols.map(s => `Symbol("${s.description}")`),
464 ...privateFields.map(s => `${s.description}`),
465 ];
466 if (keys.length === 0)
467 print('No own properties');
468 else
469 print(keys.join(', '));
470}
471keysCommand.summary = 'Prints own properties of the given object';
472keysCommand.helpText = `USAGE
473 keys <obj>

Callers

nothing calls this directly

Calls 2

evalInFrameFunction · 0.85
dvToStringFunction · 0.85

Tested by

no test coverage detected