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

dm4js

v0.2.51

Published

Decision Making library for Javascript

Readme

dm4js

This library is a library for customer to make better decision.

  • Currently the linear scalarization multi objective optimization is added to the library. This technique score chices based on pre-defined wiegth vector and the minimize a linear function and select the lowest score. Each value can be select to be maximize or minize.

    • The chooseLinear(.,.) function first normalize the choices vector and then select the best. To know how algorithm find best choice use this link.
  • and Bayesian inference for diagnosis

Adding library

npm library > here

npm i --save dm4js

Dependency

Currently there is only one dependecy for optimization algoritm. The library is 'genetic-js' witch can be find here. To install dependency use command below :

npm install genetic-js

Usage example

See test file for more examples !.

A simple usage of 'chooseLinear' is as below :

let dmjs = require('dm4js');

let model = [
    {
        label: 'price',
        weight: .5,
        shouldbe: 'min',
        type: 'numerical'
    },
    {
        label: 'capacity',
        weight: .4,
        shouldbe: 'max',
        type: 'numerical'
    },
    {
        label: 'lifetime',
        weight: .6,
        shouldbe: 'max',
        type: 'numerical'
    },
    {
        label: 'flashtype',
        weight: .3,
        shouldbe: 'max',
        type: 'ordered',
        categories: ['', 'TLC', '3D NAND', 'MLC', 'SLC'] // latest is the best
    }
];
let choices = [
    [361000, 240, 1000000, 'TLC'], // SSD Panther AS330
    [425000, 240, 1750000, 'MLC'], // SSD San Disk SSD PLUS
    [300000, 240, 1500000, 'TLC'], // SSD Pioneer APS-SL2
    [395000, 240, 2000000, '3D NAND']  // SSD Adata SU650
];

let bestChoice = dmjs.chooseLinear(model, choices).BestIndex;

bestChoice is 2 which means SSD Pioneer APS-SL2 is the best.

Extracting a Model

We use genetic algorithm to find desired model. The genetic algorithm is a global optimizer that means if there is a solution it can find it, and the result model is global optimum if the algorithm runs enough iterations. To find a model that fits on an ordered choices is as below :

let model = [
    {
        label: 'price',
        // weight: .5,
        weight: .0,
        shouldbe: 'min',
        type: 'numerical'
    },
    {
        label: 'capacity',
        // weight: .4,
        weight: .0,
        shouldbe: 'max',
        type: 'numerical'
    },
    {
        label: 'lifetime',
        // weight: .6,
        weight: .0,
        shouldbe: 'max',
        type: 'numerical'
    },
    {
        label: 'flashtype',
        // weight: .3,
        weight: .0,
        shouldbe: 'max',
        type: 'ordered',
        categories: ['', 'TLC', '3D NAND', 'MLC', 'SLC'] // latest is the best
    }
];
let choices = [
    [300000, 240, 1500000, 'TLC'], // SSD Pioneer APS-SL2
    [425000, 240, 1750000, 'MLC'], // SSD San Disk SSD PLUS
    [395000, 240, 2000000, '3D NAND'],  // SSD Adata SU650
    [361000, 240, 1000000, 'TLC'], // SSD Panther AS330
];
let themodel = dm4js.findLinearModelWeights(model, choices, 1000);

This function map our oppinion in prioritising products, it means that if we create a list of our faivorit products and this list will be ordered from best to worst, in fact we have an oppinion in our mind that make us to create these list. This oppinion can be modeled linearly as a weights of a linear model. The function : findLinearModelWeights can find this model.

Other Functions

There are more functions in the library as below :

/*
 Note : The diffrence of this function with 'findLinearModelWeights' is that this function find a model such that
 the score of choices in ordered list be as largest as possible. But it take long time to converge, although may not
 be efficient
*/
findLinearModelWeights(ZeroWeightModel, OrderedBestChoices, iteration)

My steps to Publish

code => test => publish => revise code => test => publish new version ...