MCPcopy Create free account
hub / github.com/PrivacySafe/sticktock / findObjectWithKey

Function findObjectWithKey

backend-api/utils/objects.ts:3–21  ·  view source on GitHub ↗
(
  obj: AnyObject,
  key: string
)

Source from the content-addressed store, hash-verified

1type AnyObject = { [key: string]: any };
2
3export const findObjectWithKey = (
4 obj: AnyObject,
5 key: string
6): AnyObject | null => {
7 if (obj.hasOwnProperty(key)) {
8 return obj[key];
9 }
10
11 for (const k in obj) {
12 if (typeof obj[k] === 'object' && obj[k] !== null) {
13 const result = findObjectWithKey(obj[k], key);
14 if (result !== null) {
15 return result;
16 }
17 }
18 }
19
20 return null;
21};

Callers 2

extractDataFromJsonFunction · 0.90
pullVideoDataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected