MCPcopy
hub / github.com/mongodb/node-mongodb-native / isRecord

Function isRecord

src/utils.ts:597–623  ·  view source on GitHub ↗
(
  value: unknown,
  requiredKeys: string[] | undefined = undefined
)

Source from the content-addressed store, hash-verified

595): value is Record<T[number], any>;
596export function isRecord(value: unknown): value is Record<string, any>;
597export function isRecord(
598 value: unknown,
599 requiredKeys: string[] | undefined = undefined
600): value is Record<string, any> {
601 if (!isObject(value)) {
602 return false;
603 }
604
605 const ctor = (value as any).constructor;
606 if (ctor && ctor.prototype) {
607 if (!isObject(ctor.prototype)) {
608 return false;
609 }
610
611 // Check to see if some method exists from the Object exists
612 if (!HAS_OWN(ctor.prototype, 'isPrototypeOf')) {
613 return false;
614 }
615 }
616
617 if (requiredKeys) {
618 const keys = Object.keys(value as Record<string, any>);
619 return isSuperset(keys, requiredKeys);
620 }
621
622 return true;
623}
624
625type ListNode<T> = {
626 value: T;

Callers 4

setOptionFunction · 0.90
transformFunction · 0.90
extractCrudResultFunction · 0.85
collectTestsFunction · 0.85

Calls 3

isObjectFunction · 0.85
HAS_OWNFunction · 0.85
isSupersetFunction · 0.85

Tested by 1

collectTestsFunction · 0.68