MCPcopy Index your code
hub / github.com/github/docs / createMapFromArray

Function createMapFromArray

lib/page-data.js:274–283  ·  view source on GitHub ↗
(pageList)

Source from the content-addressed store, hash-verified

272
273// Create an object from the list of all pages with permalinks as keys for fast lookup.
274export function createMapFromArray(pageList) {
275 const pageMap = pageList.reduce((pageMap, page) => {
276 for (const permalink of page.permalinks) {
277 pageMap[permalink.href] = page
278 }
279 return pageMap
280 }, {})
281
282 return pageMap
283}
284
285export async function loadPageMap(pageList) {
286 const pages = pageList || (await loadPageList())

Callers 1

loadPageMapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected