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

quantumscript

v1.1.0

Published

Quantum theory emulated onto Javascript objects.

Downloads

10

Readme

QuantumScript

What it is

This repo attempts to emulate some of the parts of the mechanics in quantum theory.

Because quantum physics cannot reasonably be translated into JavaScript, a lot of how this library works is based on randomly choosing a set of superpositions when observing the object.

You should also provide a set of known states to be used as the superposition of the object.

Basic Usage

You can install QuantumScript with npm i quantumscript

Now let's setup a quantum dice, it will have 6 sides. This will mean that in 6 different worlds the die is facing every possible way. So the die at the time of creation is in a superposition, and is as far as you know, rolled to every possible solution. Schrödinger's die, if you will.

const dice = new Quantum(
    [1, 2, 3, 4, 5, 6]
);

Now we'd like to observe the die and thus collapse it's superposition into one possible state. Which is made simple by running .observe().

dice.observe(); // 4

Great, so our die is 4 right? Let's check again.

dice.observe(); // 4

Sweet, let's see if the number is even.

dice.interact(die => !die % 2); // true

Awesome, 4 is even... it was 4 right? Let's be sure.

dice.observe(); // 6

Because we've interacted with the die it has returned to a superposition.

Functional Usage

You may pass functions in as the possible state, along with anything else, if the quantum object collapses into a functional state, it will then run the previous value on that function. You can set this up as shown below, passing the known state as you fist observe as the second argument. This is necessary if you expect any results from your functions.

new Quantum(
    [Math.sqrt, Math.abs, Math.floor, Math.tan, 56, 'Oak Tree'],
    -6.8431234
);

Some closing remarks

Many things this repo offers may be incorrect, and may need changing. I've been building this as a way to try to understand the world at a nanoscopic scale. If you're an expert at this sort of thing, please submit ideas via issues, or improvements via pull requests! Enjoy this useless but interesting repo.

rm