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

@jetta/item-stability

v2.1.0

Published

Library to calculate per-item stability scores for allocated cargo items.

Readme

Item Stability

Library that calculates a stability index (0–1) for each allocated item inside a container, combining weighted geometric factors.

Sources are written in TypeScript and compile to CommonJS under build/. The public API is exposed through build/main.js (with .d.ts types).

Requirements

  • Node.js 18 or later
  • npm 9 or later (for npm ci)

How to install

From npm (after publish):

npm install @jetta/item-stability

Local development:

npm ci
npm run build

The published package ships build/main.js, build/main.d.ts, and build/core/ only. The full build/ folder (including compiled tests) is generated locally and is not committed.

Usage

After building, require the compiled entry point:

const calculate_item_stability = require('./build/main')
// or, when installed as a dependency:
// const calculate_item_stability = require('@jetta/item-stability')

const input_data = {
    container: {w: 10, h: 10, l: 10},
    item_list: [
        {x: 0, y: 0, z: 0, w: 2, h: 2, l: 2}
    ]
}

const stability_index = calculate_item_stability(input_data)
// [0.742] — one score per item, same order as item_list

Factor weights default to ITEM_STABILITY_FACTOR_WEIGHT in core/constants/ItemStabilityFactorWeights.ts. Pass config.item_stability_factor_weight to override them. All four keys are required when that object is present. CompletelyStable stays at coefficient 1.

| Factor | Default weight | |--------|----------------| | measure_relation | 0.30 | | covered_sides | 0.75 | | closest_object_distance | 0.05 | | tip_over_angle | 0.10 |

Optional timing logs for local debugging:

calculate_item_stability(input_data, {log_timing: true})

Project layout

| Path | Purpose | |------|---------| | main.ts | Public entry point | | core/ | Domain models, spatial indexing, factor strategies | | core/validation/ | Zod input schemas | | core/types/ | Shared TypeScript types (AppData, InputData, etc.) | | test/src/ | Mocha test suites (compiled with production code) | | test/data/ | JSON fixtures for data-driven tests | | debug/ | Local debug scripts (run via tsx) | | build/ | Compiled output (main.js, core/ for publish; test/src/ for local/CI tests) |

Dependencies

Runtime

| Package | Purpose | |---------|---------| | zod | Input validation at the API boundary |

Development

| Package | Purpose | |---------|---------| | typescript | Type checking and compilation | | tsx | Run benchmark and debug scripts | | mocha / chai | Tests and assertions | | eslint / typescript-eslint | Linting | | c8 | Code coverage | | publint | npm package manifest validation | | @types/node, @types/mocha, @types/chai | Type definitions |

Scripts

| Script | Description | |--------|-------------| | npm run build | Compile production TypeScript to build/ (main.js, core/) | | npm run build:test | Compile tests to build/test/ (used by npm test) | | npm run typecheck | Type-check without emitting files | | npm test | build:test, then run Mocha on build/test/src/**/*.js | | npm run lint | ESLint on .ts sources | | npm run lint:fix | ESLint with auto-fix | | npm run lint:package | Validate npm publish manifest with publint (run after build) | | npm run coverage | Tests with c8 (HTML + text reports) | | npm run coverage:ci | Same tests under c8 with coverage thresholds (used in CI) | | npm run benchmark | Benchmark spatial setup (tsx test/benchmark/...) | | npm run publish:alpha / publish:stable | Bump version and tag for npm publish via CI | | npm run prerelease:alpha | Bump alpha prerelease version |

Test plan

Full verification:

npm run typecheck
npm run lint
npm run build
npm run lint:package
npm run coverage:ci
npm run benchmark

Run a subset:

npm test -- --grep "ItemStability integration"
npm test -- --grep "TipOverAngle"

Documentation

Contract

Input

  • Ordered set of allocated items (x, y, z, w, h, l; coordinates may be zero at floor/walls)
  • Container dimensions (w, h, l)

Optional config.item_stability_factor_weight with measure_relation, covered_sides, closest_object_distance, and tip_over_angle. Omitted weights use the defaults in Usage.

Output

  • Ordered array of floats in [0, 1], one stability score per item

Invalid payloads throw InvalidInputException.