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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@antisoftwareclub/numbers

v1.0.0

Published

Initial public release of [Numbers™ from cohost](https://cohost.org/staff/post/1254822-introducing-numbers).

Downloads

3

Readme

cohost Numbers™

Initial public release of Numbers™ from cohost.

There are minor differences between the code as released and what we were running in production. These differences are:

  • remove some logic to pick a correct publish date and post ID when given a specific post; finding the correct publish date is the responsibility of whatever includes <Numbers /> now.
    • this change is because we would have to release typedefs for the actual Post object, which is irrelevant for anyone other than us.
  • change the Numbers™ display to use a style attribute instead of a tailwind class
    • adding a tailwind dependency would be silly. we are sparing y'all of that.

"Algorithm" details

for those who don't want to read the code

The Numbers™ algorithm is very simple:

  1. seed a random number generator off a post ID.
  2. roll the dice four times
    • Numbers™ score
    • Negative score
    • Fractional score
    • Exponent score
  3. Multiply the Numbers™ score by the number of seconds since/until the selected date.
    • For posts created before April 1 at midnight UTC, this date is April 1 at midnight UTC.
    • For posts created after April 1 at midnight UTC, this date is the post publish date.
  4. Check the Fractional score against a threshold
    • There is a 2% chance for a given post to have a decimal
    • If this check passes, normalize the roll from 0-0.02 to 0-1, lerp with this against our fraction digit range, floor the result. (1-5)
    • Use this when calling toLocaleString later.
  5. Check the Exponent score against a threshold
    • There is a 50% chance for a given post to see exponential growth
    • If this check passes, normalize the roll from 0-0.5 to 0-1, lerp with this against our exponent range (1 - 1.42).
    • 1.42 was chosen solely because jae liked the aesthetics of the range that got us.
  6. Check the Negative score against a threshold.
    • The Negative threshold shifts throughout the weekend, starting at 5% and capping at 60%.
    • Posts have a chance of becoming Negative at any time, although some rolls (>=0.6) will never go negative.
    • If this check passes, multiply the Number by -1.
  7. Turn that shit into a locale string
    • This is where we actually use the fraction result.
  8. Render it
    • When the user clicks the Number, we run all this again. Clicking DOES NOT increase the number, the number increases on its own by virtue of time having passed since you last clicked it.

Use

You shouldn't use this. Reference dates are all hardcoded to April 1 because that's when we released it. This release provided mostly for reference, but if you really want to use it:

import {Numbers} from "@antisoftwareclub/numbers";

// your actual code goes here

<>
    <Numbers postId={69420} publishedAt="2022-02-03T08:30:00.000Z" />
</>

Notes

  • This does not include tests. If you want to write tests for it, knock yourself out.
  • jae wrote this over the course of about two hours. set your code quality expectations accordingly.

License

This release is licensed under an MIT license.

PLEASE NOTE: this license ONLY covers this release of Numbers.tsx. It DOES NOT apply to any other part of the cohost code base.

Note for us specifically

jae was too tired to get github actions to publish the package to npm so we've gotta publish manually. this does not actually matter.