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

supplex_chain

v1.0.1

Published

Optimize a supply chain using a simplex solver.

Readme

Supplex Chain

Publish Status Test Status

Supplex Chain is a TypeScript project designed to optimize production lines using a simplex solver. It allows you to calculate the most efficient way to produce items given a set of resources, recipes, and production constraints. Perfect for simulation, manufacturing planning, or resource optimization in games and industrial scenarios.


Features

  • Computes the optimal resource allocation for complex production chains.
  • Supports multiple production methods per resource, selecting the most efficient one automatically.
  • Handles feedback loops where intermediate products are reused.
  • Accounts for limited resources, respecting maximum availability.
  • Returns detailed breakdowns of:
    • Base resources consumed
    • Production cycles for each recipe
    • Intermediate products produced and consumed

Installation

npm install supplex_chain

or using Yarn:

yarn add supplex_chain

Usage

import { optimize, type Recipe } from 'supplex_chain';

const resources: Recipe[] = [
  { name: 'Iron Ore', input: [], output: [{ resourceName: 'Iron Ore', quantity: 1 }] },
  { name: 'Copper Ore', input: [], output: [{ resourceName: 'Copper Ore', quantity: 1 }] },
];

const recipes: Recipe[] = [
  { name: 'Iron Ingot', input: [{ resourceName: 'Iron Ore', quantity: 30 }], output: [{ resourceName: 'Iron Ingot', quantity: 30 }] },
  { name: 'Copper Ingot', input: [{ resourceName: 'Copper Ore', quantity: 30 }], output: [{ resourceName: 'Copper Ingot', quantity: 30 }] },
];

const result = optimize([...resources, ...recipes], [
  { name: 'Iron Ingot', quantity: 60 },
  { name: 'Copper Ingot', quantity: 30 },
]);

console.log(result);

The output will provide:

  • Base resources required
  • Number of cycles for each production step
  • Consumed and produced quantities per recipe

Example Output

[
  {
    "name": "Iron Ore",
    "cycles": 60,
    "consumes": [],
    "produces": [{ "resourceName": "Iron Ore", "quantity": 60 }]
  },
  {
    "name": "Iron Ingot",
    "cycles": 2,
    "consumes": [{ "resourceName": "Iron Ore", "quantity": 60 }],
    "produces": [{ "resourceName": "Iron Ingot", "quantity": 60 }]
  },
  {
    "name": "Copper Ore",
    "cycles": 30,
    "consumes": [],
    "produces": [{ "resourceName": "Copper Ore", "quantity": 30 }]
  },
  {
    "name": "Copper Ingot",
    "cycles": 1,
    "consumes": [{ "resourceName": "Copper Ore", "quantity": 30 }],
    "produces": [{ "resourceName": "Copper Ingot", "quantity": 30 }]
  }
]

Features in Depth

  • Automatic recipe selection: Finds the combination of recipes that minimizes resource usage.
  • Feedback loops: Handles intermediate products being recycled, such as using outputs as inputs for other recipes.
  • Resource limits: If a resource is capped, the solver uses alternative recipes or returns no result if production is impossible.

License

MIT License


Summary

Supplex Chain simplifies complex production line planning by combining linear programming optimization with resource-aware recipes. Whether for industrial simulations or game-based resource management, it ensures the most efficient production path for any set of inputs and goals.