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

@emaarco/dmn-js-simulation

v0.7.0

Published

Simulate DMN decision tables directly in a dmn-js modeler — see which rules match and what the decision returns.

Readme

@emaarco/dmn-js-simulation

npm version license live demo

Simulate DMN decision tables directly in a dmn-js modeler — feed in concrete inputs and instantly see which rules match, which don't, and what the decision returns.

Drilling from the DRD into the Recommend Bike table, entering Road and 2500, then simulating highlights rule 3 and shows Model = Road Pro

The idea behind this project

@emaarco/dmn-js-simulation is to DMN what bpmn-js-token-simulation is to BPMN: it lets you validate decision logic while you model it, instead of discovering mistakes later in process code, tests, or production. It supports all DMN hit policies (UNIQUE, FIRST, ANY, PRIORITY, COLLECT with SUM/MIN/MAX/COUNT, RULE ORDER, OUTPUT ORDER) and multi-decision DRD chaining.

Features

  • Decision-table simulation — an input form appears above the table; run it to highlight the matched rule(s) and read off the result. Rules dropped by the hit policy (e.g. under FIRST/PRIORITY) are shown as dimmed candidates, so the policy's effect is visible.
  • All hit policies, including COLLECT aggregations and policy-violation warnings (e.g. UNIQUE matched twice).
  • DRD chaining — simulate a whole decision requirement graph, down to a single decision with its input data: set the input-data leaves once, and every decision is evaluated in dependency order. Fired decisions are highlighted and annotated with their result; drilling into a decision reflects that run's row highlights.
  • Drop-in — installs like any dmn-js module via additionalModules; dmn-js is a peer dependency, so it drives the modeler you already use.
  • Fits your host — switch it on and off, render it into your own container as one live row, and theme it through CSS variables that default to dmn-js's own tokens.

Installation

npm install @emaarco/dmn-js-simulation

dmn-js (>= 17) is a peer dependency — install it if you haven't already.

Usage

import DmnModeler from 'dmn-js/lib/Modeler'
import DmnSimulationModule from '@emaarco/dmn-js-simulation'
import '@emaarco/dmn-js-simulation/assets/dmn-js-simulation.css'

const modeler = new DmnModeler({
  container: '#canvas',
  decisionTable: { additionalModules: [DmnSimulationModule.decisionTable] },
  drd: { additionalModules: [DmnSimulationModule.decisionRequirementsDiagram] },
})

await modeler.importXML(dmnXml)

Register only the view(s) you need. The modules are also exported individually:

import { DmnSimulationTableModule, DmnSimulationDecisionRequirementsDiagramModule } from '@emaarco/dmn-js-simulation'

DRD view: make sure your app imports dmn-js's icon font (dmn-js/dist/assets/dmn-font/css/dmn-embedded.css) alongside its other stylesheets — otherwise the DRD editor palette icons render blank.

Switch it on and off, and place it yourself

Every view registers a dmnSimulation service. Its options go under dmnSimulation; put them in dmn-js's common options to reach every view:

const modeler = new DmnModeler({
  container: '#canvas',
  common: {
    dmnSimulation: {
      active: false, // start switched off
      container: bottomBar, // render into your own element
      layout: 'inline', // one row that wraps
      evaluateOn: 'input', // evaluate as the user types
    },
  },
  decisionTable: { additionalModules: [DmnSimulationModule.decisionTable] },
  drd: { additionalModules: [DmnSimulationModule.decisionRequirementsDiagram] },
})

const simulation = modeler.getActiveViewer().get('dmnSimulation')
simulation.toggle() // flip it; toggle(true) or toggle(false) to set it
simulation.isActive()
simulation.isAvailable() // can this view be simulated at all?
modeler.getActiveViewer().on('dmnSimulation.toggle', ({ active }) => updateButton(active))
modeler.getActiveViewer().on('dmnSimulation.availability', ({ available }) => showButton(available))

| Option | Default | What it does | | ------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | active | true | Whether the simulation starts on. While off, no form, panel, row highlight or DRD badge is shown; the entered values and the last result stay. | | container | — | An element, or (viewType: 'drd' \| 'decisionTable') => HTMLElement \| null. The form and the DRD panel render there instead of above the table and in the DRD's corner; null leaves a view without UI. | | layout | 'stacked' | 'inline' puts inputs, Simulate, result and Reset in one row that wraps; the DRD panel drops its title. | | evaluateOn | 'run' | 'input' evaluates once the user pauses typing and leaves out the Simulate button. |

The on/off state belongs to the modeler, not to a view: switching between the DRD and a decision table keeps it. Whether a view can be simulated belongs to the view: isAvailable() is always true in a decision table, and in the DRD once the diagram has a decision and an input data. The DRD announces a change, after an edit or an import, as dmnSimulation.availability; on a view switch, ask the new view. With a container, only the view dmn-js shows renders into it, so the DRD and the tables can share one element. The add-on appends an element of its own and leaves the rest of your container alone; there the UI has no card or position of its own, your container owns them. The types are exported: DmnSimulation, DmnSimulationConfig, DmnSimulationContainer, DmnSimulationLayout, DmnSimulationEvaluateOn, DmnSimulationViewType, DmnSimulationToggleEvent and DmnSimulationAvailabilityEvent.

Theming

The add-on takes its colours, radii and font from the dmn-js it runs in: unset, every --dmn-sim-* variable falls back to the bpmn-io tokens dmn-js ships (--bio-surface, --bio-text, --bio-primary, …), and the text inherits the host's font. A host that switches --bio-* for dark mode gets a readable simulation without overrides. To set a look of your own, set any --dmn-sim-* variable, on :root or on a container:

:root {
  --dmn-sim-accent: #0a7d4f;
  --dmn-sim-font: 'Inter', sans-serif;
}

The variables: --dmn-sim-font, --dmn-sim-font-mono, --dmn-sim-surface, --dmn-sim-ink, --dmn-sim-muted, --dmn-sim-line, --dmn-sim-disabled-ink, --dmn-sim-output-bg, --dmn-sim-panel-bg, --dmn-sim-accent, --dmn-sim-accent-ink, --dmn-sim-accent-soft, --dmn-sim-on-accent, --dmn-sim-success(-soft), --dmn-sim-warning(-soft), --dmn-sim-danger(-soft), --dmn-sim-match-bg, --dmn-sim-match-accent, --dmn-sim-candidate-bg, --dmn-sim-fired, --dmn-sim-space-1…3, --dmn-sim-radius-sm|md|lg|pill, --dmn-sim-shadow-1…3, --dmn-sim-motion-fast and --dmn-sim-ease.

Evaluate without a modeler

The framework-free evaluation core is exported too, for tests or headless use:

import { DmnXmlReader, DecisionTableEvaluator } from '@emaarco/dmn-js-simulation'

const model = new DmnXmlReader().readDecisionTable(dmnXml)
const result = new DecisionTableEvaluator(model).evaluate(['Fall', 8])
// → { matchedRuleIndices, reportedRuleIndices, outputs, aggregation?, violation? }

new DmnModdleReader().readDecisionRequirementsDiagram(definitions) + new DecisionRequirementsDiagramEvaluator(model).evaluate(inputValues) do the same for a whole DRD graph.

Contributing

Contributions are welcome — see CONTRIBUTING.md for the monorepo layout, scripts, and how to build, test and run the example locally.

Credits

License

MIT © Marco Schäck