Skip to the content

Capsid menu

app/lib/projects-page.mjs

34 lines and 2 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of projects-page.mjs
FunctionLinesComplexityCoveredCRAPMutation
<anonymous:16>16 to 161No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
metricValue26 to 373No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports no other module of this repo. No module of this repo imports it.

Source

/**
 * Roster metrics for content/projects.json. The public Software pages are markdown in
 * content/pages/, and their search records come from the content-page indexer. check:features
 * computes a derived metric through metricValue, so the roster and the gate share one derivation.
 */

export const PROJECTS_URL = "/software";

/**
 * A derived metric carries no date: a date on a value recomputed every build would be a claim
 * about when a human last looked.
 *
 * @type {Record<string, (inputs: any) => string>}
 */
export const METRIC_DERIVATIONS = {
  "gate-count": (inputs) => String(inputs.stack.gates.length),
};

/**
 * Called by the gate, so the gate never computes the expected value its own way.
 *
 * @param {any} metric
 * @param {{ stack: any }} inputs
 * @returns {string}
 */
export function metricValue(metric, inputs) {
  if (!metric.derived) return metric.value;
  const derive = METRIC_DERIVATIONS[metric.derived];
  if (!derive) {
    throw new Error(
      `content/projects.json names the derivation "${metric.derived}", which ` +
        `METRIC_DERIVATIONS in app/lib/projects-page.mjs does not implement. ` +
        `Known: ${Object.keys(METRIC_DERIVATIONS).join(", ")}.`,
    );
  }
  return derive(inputs);
}