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

@pixpilot/credit-allocation-calculator-ui

v0.1.0

Published

React UI for @pixpilot/credit-allocation-calculator.

Downloads

324

Readme

@pixpilot/credit-allocation-calculator-ui

React editor for @pixpilot/credit-allocation-calculator, in the same relationship @pixpilot/cost-calculator-ui has to @pixpilot/cost-calculator: every number on screen is produced by the calculation package, and no financial arithmetic happens inside a component.

import { CreditAllocationCalculator } from '@pixpilot/credit-allocation-calculator-ui';

<CreditAllocationCalculator
  defaultValue={operations}
  model={{ inputPricePerMillionTokens: 0.15, outputPricePerMillionTokens: 0.6 }}
/>;

The table is both the editor and the simulation result — each row carries the operation's two sliders and every figure they produce, so there is no second results table to scroll to. The totals stay pinned above it.

PROVIDER COST / CREDIT is what one allocated credit costs the business to honour. It is not the price of a credit; that comes from a pricing scenario.

Pricing the allocation against a plan or credit pack

Pass pricingScenarios and the summary gains a scenario picker, and each row gains what the customer pays and the margin it earns:

<CreditAllocationCalculator
  defaultValue={operations}
  model={model}
  pricingScenarios={[
    {
      id: 'starter',
      label: 'Starter plan',
      packagePrice: { amount: '20', currency: 'USD' },
      includedCredits: 10_000,
    },
    {
      id: 'promotional',
      label: 'Launch promotion',
      packagePrice: { amount: '20', currency: 'USD' },
      includedCredits: 10_000,
      bonusCredits: 2_000,
    },
  ]}
/>

Switching scenarios reprices what the allocation earns and leaves what it costs to run exactly where it was — which is the comparison the screen exists to make. With no scenarios the calculator shows provider cost alone, as it did before pricing existed.

Pricing an allocation from a cost scenario

useCostBackedCreditAllocation derives the allocation from cost batches the host is still editing, keeping only the administrator's decisions — runs and credits per execution — as state:

const allocation = useCostBackedCreditAllocation(costBatches);

<CreditAllocationCalculator
  defaultValue={allocation.value}
  model={selectedModel}
  value={allocation.value}
  onChange={allocation.onChange}
/>;

Updating the model prop reprices the allocation immediately, while the runs and credits already set survive it — they are keyed by operation id rather than by position.

Props

  • defaultValue / value / onChange — controlled or self-contained, matching CostCalculator.
  • model — the one model whose token rates price every operation.
  • maxCreditsPerExecution — upper bound of the credits slider.
  • maxRuns — upper bound of each operation's runs slider.
  • pricingScenarios — the plans and credit packs to read the allocation against; omit for provider cost alone.
  • title — null when the host page already names the calculator.