MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / promiseMapDict

Function promiseMapDict

packages/@contentlayer/utils/src/promise.ts:5–11  ·  view source on GitHub ↗
(
  dict: Record<string, T>,
  map: (el: T, index?: number) => Res | Promise<Res>,
)

Source from the content-addressed store, hash-verified

3 Promise.all(arr.map(map))
4
5export const promiseMapDict = async <T, Res>(
6 dict: Record<string, T>,
7 map: (el: T, index?: number) => Res | Promise<Res>,
8): Promise<Record<string, Res>> => {
9 const mappedEntries = await Promise.all(Object.entries(dict).map(async ([key, val]) => [key, await map(val)]))
10 return Object.fromEntries(mappedEntries)
11}
12
13export const promiseMapToDict = async <T, Res>(
14 arr: T[],

Callers

nothing calls this directly

Calls 2

mapFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…