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

@masabando/quantum-gates

v0.1.6

Published

A JavaScript library for simulating 1-qubit quantum gates and Composite Gates.

Readme

version
last-commit page-build-status

hits npm
license stars

quantum-gates

 Documentation

A JavaScript library for simulating 1-qubit quantum gates and Composite Gates.

see quantum states in 3D

See how quantum states move on the Bloch sphere.
Drag, rotate, and explore them in 3D.

import { init } from "@masabando/easy-three";
import { QTool, QState } from "@masabando/quantum-gates";
QTool.createAnimation({
  init,
  target: "#bloch",
  pulseName: "reduced CORPSE/BB1",
  angle: Math.PI / 2,
  phi: 0,
  initState: new QState([1, 0]),
  speed: 4,
})

quantify gate quality

Visualize gate robustness with a fidelity map.
Scan pulse-length and off-resonance errors in one view.

import { QTool } from "@masabando/quantum-gates";
QTool.createFidelityMap({
  target: "#target",
  gateName: "reduced CORPSE/BB1",
  theta: Math.PI,
  phi: 0,
  width: 400,
  height: 400,
  // [ optional ]
  // threshold: 0.9999,
  // error: {
  //   ple: { min: -0.1, max: 0.1, step: 0.005 },
  //   ore: { min: -0.1, max: 0.1, step: 0.005 }
  // },
  // fillStyle: (val) => `rgb(${val}, ${val}, ${val})`,
});

stop fightingquantum gateswith math

Quantum gates can be defined directly as rotations.
You don’t need to write matrices to simulate their behavior.

import { QGate, QState } from "@masabando/quantum-gates";
// Not Gate (with global phase)
// rotation around X-axis by PI
const gate = new QGate(Math.PI, [1, 0, 0])
// Initial State |0>
const state = new QState([1, 0])
// Bloch Vector (0, 0, 1)
console.log(state.xyz);
// X|0> = |1>
const finalState = gate.apply(state);
// Bloch Vector (0, 0, -1)
console.log(finalState.xyz);

simple pulses becomerobust gates

Composite pulses are just sequences of simple rotations.
They can be built directly from individual gates.

import { QGate, QState } from "@masabando/quantum-gates";
// Pulse Length Error
const ple = 0.1; // 10% pulse length error
// up spin (0, 0, 1)
const initialState = new QState([1, 0]);
console.log(initialState.xyz);
// ple-affected 180y pulse (-0.31, 0, -0.95)
const pulse = new QGate(Math.PI * (1 + ple), [0, 1, 0]);
console.log(pulse.apply(initialState).xyz);
// composite pulse
// 90x
const p1 = new QGate(Math.PI / 2 * (1 + ple), [1, 0, 0])
// 180y
const p2 = new QGate(Math.PI * (1 + ple), [0, 1, 0])
// 90x
const p3 = new QGate(Math.PI / 2 * (1 + ple), [1, 0, 0])
const compositePulse = p3.multiply(p2).multiply(p1);
// (0.05, 0.01, -1)
console.log(compositePulse.apply(initialState).xyz);

composite gatesjust work

Composite quantum gates can be used just like single gates.
You can also evaluate them numerically by computing fidelity.

import { QGate, QTool, CPList } from "@masabando/quantum-gates";
// error values for testing
// 10% pulse length error and 10% off-resonance error
const ple = 0.1;
const ore = 0.1;
// ideal 180x gate
const idealGate = new QGate(Math.PI, [1, 0, 0]);
// erroneous simple gate
const plain = QTool.evalGate(CPList["plain"].pulse, Math.PI, 0, ple, ore);
// erroneous composite gate
const corpse = QTool.evalGate(CPList["CORPSE"].pulse, Math.PI, 0, ple, ore);
// erroneous concatenated composite gate
const cccp = QTool.evalGate(CPList["reduced CORPSE/SK1"].pulse, Math.PI, 0, 
// fidelities
// 0.983
console.log(plain.fidelity(idealGate))
// 0.987
console.log(corpse.fidelity(idealGate))
// 0.995
console.log(cccp.fidelity(idealGate))

How to Use

Using npm

npm install @masabando/quantum-gates @masabando/easy-three