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

@saferinsulin/core

v2.0.2

Published

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/saferinsulin/core/test.yml) [![codecov](https://codecov.io/gh/saferinsulin/core/branch/main/graph/badge.svg?token=4N5SRRV61X)](https://codecov.io/gh/saferinsulin/core) ![GitHu

Downloads

75

Readme

@saferinsulin/core

GitHub Workflow Status codecov GitHub

Core calculation module for Safer Insulin, a critical care insulin infusion rate calculator.

This module provides the clinical decision logic for calculating intravenous insulin infusion rates based on blood glucose readings. It is used by the Safer Insulin website and is available as a standalone npm package.

It is provided to medical professionals for use at their own discretion: preparing the requirements for CE marking is underway and the tool has been used successfully in the Greater Manchester Critical Care Network.

Installation

npm install @saferinsulin/core

Usage

import Calc from '@saferinsulin/core'

/* Instantiate a calculator object (defaults to latest algorithm version) */
const calc = new Calc()

/* Get a starting rate of insulin infusion */
const glucose = 17.2    // current glucose reading in mmol/L
const result = calc.startingRate(glucose)
console.log('New rate:', result.rate)
console.log('Advice:', result.advice)
console.log('Governance hex code:', result.hex)

/* Get a new rate of infusion when patient is already on insulin infusion */
const current = 12.1    // current glucose reading in mmol/L
const previous = 14.2   // previous glucose reading in mmol/L
const rate = 3          // current insulin infusion rate in ml/hr
const adjusted = calc.ongoingRate(current, previous, rate)
console.log('New rate:', adjusted.rate)
console.log('Advice:', adjusted.advice)
console.log('Governance hex code:', adjusted.hex)

/* Check a governance code */
const gov = calc.governance('0d7-a82820')
console.log('Function ID used:', gov.function)
console.log('Date generated:', gov.date)
console.log('Parameter passed:', gov.current)

API

new Calc(version?)

Creates a calculator instance. The optional version parameter selects the algorithm version:

| Version | Description | |---------|-------------| | '2.0.0' | Current algorithm (default) | | '1.0.0' | Legacy algorithm (deprecated) |

calc.startingRate(glucose)

Determines the initial insulin infusion rate for a patient not currently on insulin.

  • glucose (number): Blood glucose reading in mmol/L (must be in 0.1 increments, non-negative)
  • Returns an object with rate, rateNum, advice, and hex fields, or false on invalid input

calc.ongoingRate(current, previous, rate)

Adjusts an existing insulin infusion rate based on the latest blood glucose reading.

  • current (number): Current blood glucose in mmol/L (must be in 0.1 increments, non-negative)
  • previous (number): Previous blood glucose in mmol/L (must be in 0.1 increments, non-negative)
  • rate (number): Current infusion rate in ml/hr (must be in 0.1 increments, non-negative)
  • Returns an object with rate, rateNum, advice, and hex fields, or false on invalid input

calc.governance(hex)

Decodes a governance hex string back into the clinical decision data for audit purposes.

  • hex (string): Governance code to decode
  • Returns an object with function, current, last, rate, date, and version fields, or null on invalid input

Governance Codes

Each calculation generates a hex-encoded governance code that captures the algorithm version, input values, and timestamp for audit traceability. The function IDs are:

| Function | Version | Description | |----------|---------|-------------| | a | 1.x.x | startingRate (legacy) | | b | 1.x.x | ongoingRate (legacy) | | c | 2.x.x | ongoingRate | | d | 2.x.x | startingRate |

Previous versions of the algorithm are preserved to ensure governance codes can always be decoded.

Input Validation

All numeric inputs to startingRate and ongoingRate must be:

  • Valid numbers (not NaN)
  • Non-negative
  • In 0.1 increments (e.g., 8.0, 8.1, 8.2 — not 8.15)

Invalid inputs return false.

Development

npm install       # Install dependencies
npm test          # Run tests with coverage
npm run build     # Compile and bundle (CJS + ESM)
npm run lint      # Lint

License

MIT