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

qft-wasm

v1.0.0

Published

Production-grade WebAssembly bindings for Quantum File Type (.qft) format

Downloads

4

Readme

qft-wasm - Quantum File Type WebAssembly SDK

Production-grade WebAssembly bindings for the Quantum File Type (.qft) format.

Installation

npm

npm install qft-wasm

From Source

# Requires wasm-pack
cargo install wasm-pack
cd crates/qft-wasm
wasm-pack build --target web --release

Quick Start

Browser (ES Modules)

import init, { QftFile, createBellState, version } from 'qft-wasm';

async function main() {
  await init();
  
  console.log(`QFT WASM v${version()}`);
  
  // Create a 4-qubit state
  const file = new QftFile(4);
  console.log(`Qubits: ${file.numQubits}`);
  console.log(`Dimension: ${file.dimension}`);
  
  // Set Bell-like state |0000⟩ + |1111⟩
  const real = new Float64Array(16);
  const imag = new Float64Array(16);
  real[0] = 1 / Math.sqrt(2);
  real[15] = 1 / Math.sqrt(2);
  file.setAmplitudes(real, imag);
  
  // Serialize to bytes
  const bytes = file.toBytes();
  console.log(`Serialized: ${bytes.length} bytes`);
  
  // Download as file
  downloadQft(bytes, 'state.qft');
}

function downloadQft(bytes, filename) {
  const blob = new Blob([bytes], { type: 'application/octet-stream' });
  const url = URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = filename;
  a.click();
  URL.revokeObjectURL(url);
}

main();

Node.js

const { QftFile, version } = require('qft-wasm');

// Create state
const file = new QftFile(4);
console.log(`Version: ${version()}`);

// Export to JSON
const json = file.toJson();
console.log(json);

// Save to file
const fs = require('fs');
fs.writeFileSync('state.qft', Buffer.from(file.toBytes()));

TypeScript

import init, { QftFile, Encoding, StreamingConverter } from 'qft-wasm';

async function processLargeFile(file: File): Promise<void> {
  await init();
  
  const converter = new StreamingConverter(
    file.size,
    1024 * 1024,  // 1MB chunks
    Encoding.Amplitude
  );
  
  const reader = file.stream().getReader();
  
  while (!converter.isComplete) {
    const { done, value } = await reader.read();
    if (done) break;
    
    const chunk = new Uint8Array(value);
    const state = converter.processChunk(chunk);
    console.log(`Progress: ${(converter.progress * 100).toFixed(1)}%`);
    
    // Process state...
  }
}

API Reference

QftFile Class

class QftFile {
  constructor(numQubits: number);
  
  // Properties
  readonly numQubits: number;
  readonly dimension: number;
  bondDimension: number;
  golayEnabled: boolean;
  
  // Amplitude access
  getAmplitudesReal(): Float64Array;
  getAmplitudesImag(): Float64Array;
  setAmplitudes(real: Float64Array, imag: Float64Array): void;
  getAmplitude(index: number): { real: number; imag: number };
  setAmplitude(index: number, real: number, imag: number): void;
  
  // Validation
  isNormalized(tolerance?: number): boolean;
  normalize(): void;
  normSquared(): number;
  fidelity(other: QftFile): number;
  
  // Metadata
  setMetadata(key: string, value: string): void;
  getMetadata(key: string): string | undefined;
  getMetadataObject(): Record<string, string>;
  
  // Serialization
  toBytes(): Uint8Array;
  static fromBytes(data: Uint8Array): QftFile;
  toJson(): string;
  static fromJson(json: string): QftFile;
}

StreamingConverter Class

class StreamingConverter {
  constructor(
    totalSize: number,
    chunkSize?: number,
    encoding?: Encoding
  );
  
  processChunk(data: Uint8Array): QftFile;
  
  readonly progress: number;
  readonly isComplete: boolean;
  readonly chunkSize: number;
}

Encoding Enum

enum Encoding {
  Amplitude = 0,
  BasisState = 1,
  Qram = 2,
  Angle = 3,
  Block = 4,
}

Utility Functions

function version(): string;
function verify(data: Uint8Array): boolean;
function fidelityFromBytes(data1: Uint8Array, data2: Uint8Array): number;
function createBellState(): QftFile;
function createGhzState(numQubits: number): QftFile;
function createUniformState(numQubits: number): QftFile;

Examples

Create Bell State

import { createBellState } from 'qft-wasm';

const bell = createBellState();
console.log(bell.getAmplitudesReal());
// Float64Array [0.707..., 0, 0, 0.707...]

Calculate Fidelity

import { QftFile } from 'qft-wasm';

const state1 = new QftFile(2);
const state2 = new QftFile(2);

// Both initialized to |00⟩
const fidelity = state1.fidelity(state2);
console.log(`Fidelity: ${fidelity}`);  // 1.0

File Upload Handler

async function handleFileUpload(event) {
  const file = event.target.files[0];
  const buffer = await file.arrayBuffer();
  const bytes = new Uint8Array(buffer);
  
  try {
    const qft = QftFile.fromBytes(bytes);
    console.log(`Loaded ${qft.numQubits}-qubit state`);
    console.log(`Normalized: ${qft.isNormalized()}`);
  } catch (e) {
    console.error('Invalid QFT file:', e.message);
  }
}

React Component

import React, { useState, useEffect } from 'react';
import init, { QftFile, createBellState } from 'qft-wasm';

export function QuantumStateViewer() {
  const [state, setState] = useState<QftFile | null>(null);
  const [ready, setReady] = useState(false);
  
  useEffect(() => {
    init().then(() => setReady(true));
  }, []);
  
  const createBell = () => {
    const bell = createBellState();
    setState(bell);
  };
  
  if (!ready) return <div>Loading WASM...</div>;
  
  return (
    <div>
      <button onClick={createBell}>Create Bell State</button>
      {state && (
        <div>
          <p>Qubits: {state.numQubits}</p>
          <p>Dimension: {state.dimension}</p>
          <p>Normalized: {state.isNormalized() ? 'Yes' : 'No'}</p>
        </div>
      )}
    </div>
  );
}

Bundle Size

| Build | Size (gzip) | |-------|-------------| | Web | ~45 KB | | Node.js | ~50 KB |

Browser Support

  • Chrome 89+
  • Firefox 89+
  • Safari 15+
  • Edge 89+

Performance

| Operation | 10 qubits | 20 qubits | |-----------|-----------|-----------| | Create | 0.1 ms | 2 ms | | Serialize | 0.2 ms | 20 ms | | Deserialize | 0.1 ms | 15 ms | | Fidelity | 0.1 ms | 10 ms |

License

MIT OR Apache-2.0