MCPcopy Index your code
hub / github.com/immutable-js/immutable-js / getIn

Function getIn

src/functional/getIn.ts:18–33  ·  view source on GitHub ↗
(
  collection: CollectionType,
  searchKeyPath: KeyPath<Key>,
  notSetValue?: GetTypeParameters[2]
)

Source from the content-addressed store, hash-verified

16 * work with plain Objects and Arrays.
17 */
18export function getIn(
19 collection: CollectionType,
20 searchKeyPath: KeyPath<Key>,
21 notSetValue?: GetTypeParameters[2]
22): ReturnType<GetType> {
23 const keyPath = coerceKeyPath(searchKeyPath);
24 let i = 0;
25 while (i !== keyPath.length) {
26 // @ts-expect-error keyPath[i++] can not be undefined by design
27 collection = get(collection, keyPath[i++], NOT_SET);
28 if (collection === NOT_SET) {
29 return notSetValue;
30 }
31 }
32 return collection;
33}

Callers 1

hasInFunction · 0.90

Calls 2

getFunction · 0.90
coerceKeyPathFunction · 0.85

Tested by

no test coverage detected