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

@step-wise/input-interpretation

v0.1.1

Published

Convert editable learner input representations to and from application domain values.

Readme

@step-wise/input-interpretation

Convert stored learner input into usable domain values and convert domain values back into editable input representations.

Input values are plain objects with a stable type and value. Their contents reflect what an input field needs to display and edit, which may differ from the general storage representation produced by @step-wise/serialization.

Installation

npm install @step-wise/input-interpretation

Adapter registries

This package does not hard-code input domains. Every recognized input type is supplied through an adapter registry, keeping input interpretation independent of exercise orchestration and domain engines.

The fundamental Integer and MultipleChoice adapters are defined by @step-wise/value-types. @step-wise/input-exercises includes them automatically and captures the resulting registry behind each built exercise's interpretInput operation. Direct callers can still extract and pass adapters themselves.

Custom input types

Pass an adapter registry as the second argument:

import { isString } from '@step-wise/js-utils'
import {
	type InputValue,
	type InputValueAdapter,
	isInputValueOfType,
	interpretInputValue,
	toInputValue,
} from '@step-wise/input-interpretation'

type LabelInputValue = InputValue<'Label', string>

const labelAdapter = {
	isInputValue: (value: unknown): value is LabelInputValue =>
		isInputValueOfType(value, 'Label', isString),
	isDomainValue: isString,
	interpret: inputValue => inputValue.value.trim(),
	toInputValue: label => ({ type: 'Label', value: label }),
} satisfies InputValueAdapter<LabelInputValue, string>

const adapters = { Label: labelAdapter }

interpretInputValue({ type: 'Label', value: ' answer ' }, adapters) // 'answer'
toInputValue('answer', 'Label', adapters) // { type: 'Label', value: 'answer' }

Public conversion functions validate input before calling a typed conversion and validate the adapter's output afterward. Registry composition and duplicate-name validation are handled by @step-wise/value-types.

Domain packages commonly bundle these registries through @step-wise/value-types.

Interpreting nested input data

interpretInputData(value, adapters) recursively processes arrays and plain objects. Registered input values are interpreted; objects with unknown type names remain ordinary data while their contents are processed.

A malformed value for a recognized type throws. Sparse arrays, circular structures, unsupported class instances, functions, symbols, and bigints are rejected. Repeated non-circular references are allowed, although shared identity is not preserved.

Because arbitrary nested input data cannot statically describe the domain values that will be created, interpretInputData returns unknown. Narrow untrusted data or assert the expected shape when reading input produced by your own application.

TypeScript types

The main public types are:

  • InputValue<TType, TValue> for a plain { type, value } input representation.
  • InputValueMap for input values keyed by their input-field identifiers.
  • isInputValue and isInputValueMap for validating their generic runtime structures.
  • InputValueAdapter<TInputValue, TDomainValue> for one input type's guards and conversions.
  • InputValueAdapters for a registry keyed by input type.
  • isInputValueAdapter for runtime adapter validation.
  • isInputValueOfType for checking an exact simple input-value envelope.