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

@papit/vector

v0.0.1

Published

A high‑performance vector math library for games, graphics, physics, and real‑time simulations.

Downloads

157

Readme

@papit/vector

A high‑performance vector math library for games, graphics, physics, and real‑time simulations.

Logo

It provides arbitrary‑dimension vectors plus specialized Vector2 and Vector3 classes, with a clean, chainable API suitable for graphics pipelines, linear algebra, and engine‑level computations.

The library is intentionally low‑level, allocation‑aware, and predictable — ideal for hot paths in physics loops or rendering.


Type Tests NPM version


Features

  • Float32Array-backed vectors for speed
  • ✅ General N‑dimensional vectors via Vector
  • ✅ Specialized Vector2 and Vector3 classes
  • ✅ Chainable mutating instance API
  • ✅ Functional static helpers (immutable style)
  • ✅ Common vector operations: dot, cross, distance, normalize
  • ✅ Vector rotation (rotateX/Y/Z) for 3D
  • ✅ Perpendicular and angle helpers for 2D
  • ✅ Zero dependencies

Installation

npm install @papit/vector

Quick Start

import { Vector3 } from "@papit/vector";

const v = new Vector3(1, 2, 3);

v.add([1, 0, -1]).normalize().multiply(5);

console.log(v.magnitude); // 5

All instance methods mutate the vector and return this for chaining.


Vector Types

Vector

General-purpose N-dimensional vector:

const v = new Vector(4); // 4D vector
v.add([1, 2, 3, 4]);

Useful for:

  • Arbitrary linear algebra
  • Physics simulations
  • Data transformations

Vector2

Specialized 2D vector:

const v = new Vector2(3, 4);
console.log(v.angle); // angle in radians
v.angle = Math.PI / 2; // rotate vector

Includes:

  • 2D rotation helpers
  • Perpendicular computation
  • Angle calculation

Vector3

Specialized 3D vector:

const v = new Vector3(1, 0, 0);
v.rotateY(Math.PI / 2).cross([0, 1, 0]);

Includes:

  • 3D rotations (rotateX, rotateY, rotateZ)
  • Cross product
  • Vector arithmetic

Vector Operations

Arithmetic

v.add([1, 2, 3]);
v.subtract([0, 1, 0]);
v.multiply(2);
v.divide([2, 2, 2]);

Normalization & Magnitude

v.normalize(); // unit vector
v.magnitude; // length
v.magnitude = 10; // scale to new length

Dot & Cross Products

Vector3.dot(a, b);
Vector3.cross(a, b);
Vector2.cross(a, b); // scalar in 2D

Distance

Vector.distance(a, b);

Mutating vs Functional Style

Mutating (fast, no allocations)

v.add([1, 0, 0]).rotateY(Math.PI / 4);

Functional (immutable)

const v2 = Vector3.add(a, b);

Static helpers automatically clone vectors.


Design Philosophy

  • Performance first
  • 🧠 Explicit math (no hidden magic)
  • 🔁 Predictable mutation
  • 🎮 Game-engine friendly

This library is a math primitive, not a scene graph or engine.


Related Packages

Contributing

Contributions are welcome! Please follow the development guidelines above and ensure all tests pass before submitting a pull request.

License

Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)

Key points:

  • ✅ Free to use in commercial projects
  • ✅ Free to modify and distribute
  • ✅ Attribution required
  • ❌ Cannot resell the component itself as a standalone product

See the LICENSE file for full details.

Support

For issues, questions, or contributions, please visit the GitHub repository.