MCPcopy
hub / github.com/jestjs/jest / isReadonlyProp

Function isReadonlyProp

packages/jest-mock/src/index.ts:457–484  ·  view source on GitHub ↗
(object: unknown, prop: string)

Source from the content-addressed store, hash-verified

455}
456
457function isReadonlyProp(object: unknown, prop: string): boolean {
458 if (
459 prop === 'arguments' ||
460 prop === 'caller' ||
461 prop === 'callee' ||
462 prop === 'name' ||
463 prop === 'length'
464 ) {
465 const typeName = getObjectType(object);
466 return (
467 typeName === 'Function' ||
468 typeName === 'AsyncFunction' ||
469 typeName === 'GeneratorFunction' ||
470 typeName === 'AsyncGeneratorFunction'
471 );
472 }
473
474 if (
475 prop === 'source' ||
476 prop === 'global' ||
477 prop === 'ignoreCase' ||
478 prop === 'multiline'
479 ) {
480 return getObjectType(object) === 'RegExp';
481 }
482
483 return false;
484}
485
486export class ModuleMocker {
487 private readonly _environmentGlobal: typeof globalThis;

Callers 1

_getSlotsMethod · 0.85

Calls 1

getObjectTypeFunction · 0.85

Tested by

no test coverage detected