MCPcopy
hub / github.com/redis/node-redis / getMapValue

Function getMapValue

packages/client/lib/commands/reply-utils.ts:82–107  ·  view source on GitHub ↗
(value: unknown, keys: Array<string>)

Source from the content-addressed store, hash-verified

80}
81
82export function getMapValue(value: unknown, keys: Array<string>): unknown {
83 const object = mapLikeToObject(value);
84
85 for (const key of keys) {
86 if (Object.hasOwn(object, key)) {
87 return object[key];
88 }
89 }
90
91 const lowerCaseKeyToOriginal = new Map<string, string>();
92 for (const key of Object.keys(object)) {
93 const lowerCaseKey = key.toLowerCase();
94 if (!lowerCaseKeyToOriginal.has(lowerCaseKey)) {
95 lowerCaseKeyToOriginal.set(lowerCaseKey, key);
96 }
97 }
98
99 for (const key of keys) {
100 const original = lowerCaseKeyToOriginal.get(key.toLowerCase());
101 if (original !== undefined) {
102 return object[original];
103 }
104 }
105
106 return undefined;
107}

Callers 12

normalizeInfoLabelsFunction · 0.90
normalizeInfoRulesFunction · 0.90
parseSearchResultRowFunction · 0.90
parseAggregateResultRowFunction · 0.90
transformProfileReplyFunction · 0.85

Calls 5

mapLikeToObjectFunction · 0.85
keysMethod · 0.80
hasMethod · 0.80
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected