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

@open-decision/js-interpreter

v0.0.1

Published

Open Decision is an Open-Source Decision Automation System, that is optimized for legal processes. The system will be used to build a platform to provide free legal advice for consumers.

Downloads

12

Readme

Open Decision - JavaScript Interpreter

Open Decision is an Open-Source Decision Automation System, that is optimized for legal processes. The system will be used to build a platform to provide free legal advice for consumers.

This is the JavaScript Interpreter to display decision trees generated by the Open Decision builder. For the main project, go here.

Further information about the project on www.open-decision.org

Table of content

Getting Started

Take a look at index.html in the demo folder.

Embed a decision tree

You need to to include the interpreter and JSON-logic. If you need compatibility with old browsers, use the non-ES6 version.

<script type="text/javascript" src="logic.js"></script>
<script type="text/javascript" src="../od-js-interpreter-es6.js"></script>
<script type="text/javascript" src="test.json"></script>`

The default styling currrently uses bootstrap. Load it by using:

<link rel="stylesheet" type="text/css" href="bootstrap.min.css">

Let's use the demo tree for testing. At the moment, trees exported by the builder must be assigned to a variable. Click here for more information. To do so, simply open the exported .json file with any plain text editor (don't use word :D) and add "tree =" before the rest.

<script type="text/javascript" src="test.json"></script>

Now call the init-Function. There are two mandatory arguments, the first one is the variable containing the tree, the second one is the id of the div-container, where the tree will be shown.

openDecision.init (tree, "publish-div");

Use your own styles

You can also use your own styling for most of the UI elements. Just provide a object containing the classes you want to apply. Providing a custom style for an element will override the default styling completely. Don't forget to load your stylesheet in the HTML document.

let customStyles = {
  container: {
     headingContainer: "", // A div-container wrapping the heading
     questionContainer: "", // A div-container wrapping the question
     inputContainer: "", // A div-container wrapping all input elements
     controlsContainer: "", // A div-container wrapping all control elements
  },
  heading: "", // The heading where the tree name is displayed

  // Input elements
  answerButton: "btn btn-primary ml-2", // The buttons to answer a question
  answerList: "", //The select-list
  numberInput: "", // The number input field
  dateInput: "", // The date input field

  // Free text inputs (the data is saved but no logic is performed)
  freeText: {
    short: "", // A textfield to store user data
    long: "", // A textarea to store user data
    number: "", // A numberfield to store user data
  },
  controls: {
    submitButton: "btn btn-primary ml-2 mt-3", // The button to submit a list, number or date input
    restartButton: "btn btn-primary ml-2 mt-3", // The button to restart the query
    backButton: "btn btn-primary ml-2 mt-3", // The button to go back to the last question
    saveProgressButton: "btn btn-primary ml-2 mt-3", // The button to go back to the last question
    saveDataInputField: "" // Input field to load saved data
  }
};

openDecision.init (tree, "publish-div", customStyles);

You don't need to override all elements, just select the ones you want to modify.

openDecision.init (tree, "publish-div", {backButton: "hide-el", restartButton: "btn-warning"});

Disable saving

By default, the user is allowed to save her progress and continue the query later. You can disable the save function by passing 'false' as fourth argument. If you don't use custom styles, pass empty curly braces as the third argument.

openDecision.init (tree, "publish-div", {}, false);

Known Issues

  • Storing trees in a variable: Before you can use a tree exported by the builder, you need to store it in a variable. Simply open the exported .json file with any plain text editor (just don't use word...) and add "tree =" before the rest. It should look like this:
tree =  {
  "header": {
    "version": 0.1,
    "build_date": "2020-04-03",
    "tree_name": "Test",
    "tree_slug": "test",
    "start_node": "begruung",
    "vars": {}
  },
  "ausprobieren": {

   ...


   }
  • No validation: Currently no validation is carried out on the number input field. Will be fixed soon.

Built with

  • JavaScript
  • JSONlogic
  • Bootstrap

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links