MCPcopy
hub / github.com/npmx-dev/npmx.dev / fetchPackageDownloadEvolution

Function fetchPackageDownloadEvolution

app/composables/useCharts.ts:339–361  ·  view source on GitHub ↗
(
    packageName: MaybeRefOrGetter<string>,
    createdIso: MaybeRefOrGetter<string | null | undefined>,
    evolutionOptions: MaybeRefOrGetter<EvolutionOptions>,
  )

Source from the content-addressed store, hash-verified

337 }
338
339 async function fetchPackageDownloadEvolution(
340 packageName: MaybeRefOrGetter<string>,
341 createdIso: MaybeRefOrGetter<string | null | undefined>,
342 evolutionOptions: MaybeRefOrGetter<EvolutionOptions>,
343 ): Promise<DailyDataPoint[] | WeeklyDataPoint[] | MonthlyDataPoint[] | YearlyDataPoint[]> {
344 const resolvedPackageName = toValue(packageName)
345 const resolvedCreatedIso = toValue(createdIso) ?? null
346 const resolvedOptions = toValue(evolutionOptions)
347
348 const { start, end } = resolveDateRange(resolvedOptions, resolvedCreatedIso)
349
350 const startIso = toIsoDate(start)
351 const endIso = toIsoDate(end)
352
353 const sortedDaily = await fetchDailyRangeChunked(resolvedPackageName, startIso, endIso)
354
355 if (resolvedOptions.granularity === 'day') return buildDailyEvolution(sortedDaily)
356 if (resolvedOptions.granularity === 'week')
357 return buildWeeklyEvolution(sortedDaily, startIso, endIso)
358 if (resolvedOptions.granularity === 'month')
359 return buildMonthlyEvolution(sortedDaily, startIso, endIso)
360 return buildYearlyEvolution(sortedDaily, startIso, endIso)
361 }
362
363 async function fetchPackageLikesEvolution(
364 packageName: MaybeRefOrGetter<string>,

Callers

nothing calls this directly

Calls 7

resolveDateRangeFunction · 0.85
toIsoDateFunction · 0.85
fetchDailyRangeChunkedFunction · 0.85
buildDailyEvolutionFunction · 0.85
buildWeeklyEvolutionFunction · 0.85
buildMonthlyEvolutionFunction · 0.85
buildYearlyEvolutionFunction · 0.85

Tested by

no test coverage detected