npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dimah-form/scoring

v0.6.0

Published

Official scoring plugin for dimah-form (Likert and option keying)

Downloads

361

Readme

@dimah-form/scoring

Official scoring plugin. Named variables accumulate points from selected options (and mapped number / boolean fields). Likert items map a field to one variable; keying items list { variable, points } on each option. Scores are computed from the response definition snapshot and stored answers — never the live questionnaire.

Not a field type. Scores are not stored in answers. Persistence is compute-on-read plus an optional onScore callback for your own database. The plugin does not add tables.

Install

pnpm add @dimah-form/scoring

Peer-depends on @dimah-form/core. The server entry also needs @dimah-form/server. Browser modules should import from @dimah-form/scoring/client so the server package stays off the client bundle. Other packages import the document readers from @dimah-form/scoring/document (readScoringFormMeta, tryScoreResponse) — that entry does not load the server plugin.

import { scoringPlugin } from "@dimah-form/scoring";
import { scoringClientPlugin, scoreResponse } from "@dimah-form/scoring/client";

export const form = dimahForm({
  database,
  plugins: [
    scoringPlugin({
      onScore: ({ response, scores }) => {
        /* your table */
      },
    }),
  ],
});

const clientPlugins = [scoringClientPlugin()] as const;
export const formClient = createFormClient<Form, typeof clientPlugins>({
  plugins: clientPlugins,
});

const live = scoreResponse(session.snapshot, session.answers);
const stored = await formClient.getResponseScores({ responseId });

Author with createDefineForm({ plugins }) so meta.scoring autocompletes. Guard operation for GET /scoring/response is getResponseScores.

Document

Form:

meta: {
  scoring: {
    variables: [{ id: "gad7", label: "GAD-7", min: 0, max: 21 }],
    bands: [
      { variable: "gad7", from: 0, to: 4, label: "Minimal" },
      { variable: "gad7", from: 5, to: 9, label: "Mild" },
    ],
  },
}

Field (select / multiSelect / number / boolean) — Likert:

meta: { scoring: { variable: "gad7", reverse?: true } }

Option — Likert points, or keying add (not both; keying omits field.variable):

meta: {
  scoring: {
    points: 0;
  }
}

meta: {
  scoring: {
    add: [
      { variable: "extraversion", points: 2 },
      { variable: "openness", points: 1 },
    ];
  }
}

Use built-in select plus meta.widget: "radio" for Likert items. Do not add a likert field type.

Every variables[].id must appear on a field (meta.scoring.variable) or an option (meta.scoring.add). Unmapped ids fail validateDefinition.

Optional typed sums (not a formula language). vars must be unique variable ids, not other formulas:

formulas: [{ id: "total", op: "sum", vars: ["subscaleA", "subscaleB"] }];

Missing items

variables[].missing is "incomplete" (default), "zero", or "omit".

| Policy | Unanswered visible items | | ---------------------- | ----------------------------------------------------------- | | incomplete (default) | raw is null, complete is false | | zero | count as 0 (running Likert total) | | omit | drop from the sum; raw is null only when nothing scored |

Hidden showWhen fields do not contribute and do not count as missing. If every contributing item for a variable is hidden, incomplete (and omit) yield raw: null; zero stays 0. Prefer incomplete for clinical totals; set zero when a running quiz total is the product.

Reverse scoring

reversed = min + max - points.

  • select — min/max are that field's option meta.scoring.points (so a 0–3 item on a 0–21 scale reverses as 3 - points, not 21 - points). option.add is not reversed.
  • number — min is field.min ?? 0; field.max is required when reverse is true (not the variable's scale range).
  • boolean1 - value.
  • multiSelect — not supported.

Output

{
  complete: boolean,
  variables: {
    gad7: {
      raw: number | null,
      min?: number,
      max?: number,
      missing: number,
      band?: string,
      complete: boolean,
      label?: string,
    },
  },
}

Bands are interpretation, not scoring. The first matching band in document order wins (from / to are inclusive; omit either for an open end).

License

MIT