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

@particle-academy/fancy-mlm

v0.2.0

Published

Framework-agnostic multi-level referral / network-marketing engine — Node/TS mirror of particle-academy/fancy-mlm (PHP). Same plan JSON, identical rewards.

Readme

Fancy MLM (Node / TypeScript)

@particle-academy/fancy-mlm — the Node mirror of particle-academy/fancy-mlm (PHP). A framework-agnostic multi-level referral / network-marketing engine: isomorphic, zero-dependency, same CompensationPlan JSON, identical rewards.

v0.2: Configurable downline treesunilevel (unlimited frontline, up the sponsor tree), binary (two legs, up the placement tree), and matrix (forced W×depth, up the placement tree). A reward flows up the chosen tree, decaying per level and scaling by each upline member's tier, with dynamic compression. Ledgers and catalog/fms adapters are on the roadmap.

Install

npm install @particle-academy/fancy-mlm

Use

import {
  CompensationPlan,
  ReferralEngine,
  ArrayMemberRepository,
  CollectingRewardSink,
} from "@particle-academy/fancy-mlm";

const plan = CompensationPlan.fromJSON({
  metric: "referral-bonus",
  levelFactors: [1.0, 0.5, 0.25],          // L1 100%, L2 50%, L3 25%
  tiers: { default: 1.0, silver: 1.25, gold: 1.5 },
  compression: true,
});

const members = new ArrayMemberRepository([
  { id: "origin", sponsorId: "s1" },
  { id: "s1", sponsorId: "s2", tier: "gold" },
  { id: "s2", sponsorId: null, tier: "silver" },
]);
const sink = new CollectingRewardSink();

const rewards = new ReferralEngine(plan, members, sink).distribute("origin", 100);
// s1 (gold, L1) earns 150; s2 (silver, L2) earns 62.5

Implement MemberRepository (find(id)) and RewardSink (pay(reward)) against your own store — award points, write a commission ledger, enqueue a job. The engine never knows which.

Downline trees

tree selects the parent chain the reward climbs — the walk is identical, only the pointer differs:

const unilevel = CompensationPlan.fromJSON({ tree: "unilevel", levelFactors: [1.0, 0.5, 0.25] });
const binary   = CompensationPlan.fromJSON({ tree: "binary",   levelFactors: [1.0, 0.5, 0.25] });
const matrix   = CompensationPlan.fromJSON({ tree: "matrix", width: 3, levelFactors: [1.0, 0.5, 0.25] });

| tree | climbs | frontline | |---|---|---| | unilevel | sponsor tree (sponsorId) | unlimited | | binary | placement tree (placementId, falls back to sponsorId) | 2 | | matrix | placement tree (placementId, falls back to sponsorId) | width |

Parity with PHP

The same plan JSON + the same tree yields the same rewards as the PHP package — the test suites assert identical numbers on both sides. CompensationPlan is the shared artifact; load the same file into either engine.

Develop

npm install
npm test       # vitest (mirrors the PHP test vectors)
npm run build  # tsup -> dist (ESM + CJS + types)

License

MIT.