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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cross3d

v1.1.1

Published

High-performance 3D cross product library for JavaScript/TypeScript (ESM, CJS, IIFE)

Readme

cross3d

A high-performance 3D cross product library for JavaScript/TypeScript, supporting ESM, CommonJS, and IIFE formats. Optimized for both regular arrays and Float64Array with zero memory allocation in critical paths.

Features

  • Dual APIs: cross (for regular arrays) and cross64 (for Float64Array).
  • Zero Allocation: Reuses output vectors to avoid garbage collection.
  • Multi-Format Support: ESM, CommonJS, and IIFE (global variable: crossproduct).
  • Type Safety: Strict TypeScript types (included in distribution).

Installation

via npm

npm install cross3d

via CDN (IIFE)

<script src="https://unpkg.com/cross3d@latest/dist/iife/cross3d.min.js"></script>
<!-- Exposes global variable: crossproduct -->

Usage

1. ESM (ES Modules)

// Import both functions
import { cross, cross64 } from 'cross3d';

// Regular array usage
const outArray: [number, number, number] = [0, 0, 0];
cross(outArray, [1, 2, 3], [4, 5, 6]);
console.log(outArray); // [-3, 6, -3]

// Float64Array usage (high performance)
const out64 = new Float64Array(3);
cross64(out64, new Float64Array([1, 2, 3]), new Float64Array([4, 5, 6]));
console.log(Array.from(out64)); // [-3, 6, -3]

2. CommonJS

const { cross, cross64 } = require('cross3d');

// Regular array example
const out = [0, 0, 0];
cross(out, [1, 0, 0], [0, 1, 0]);
console.log(out); // [0, 0, 1]

3. IIFE (Global Variable)

<script src="https://unpkg.com/cross3d@latest/dist/iife/cross3d.min.js"></script>
<script>
  // Use via global variable "cross3d"
  const out = [0, 0, 0];
  cross3d.cross(out, [3, 4, 5], [6, 7, 8]);
  console.log(out); // [4*8 - 5*7, 5*6 - 3*8, 3*7 - 4*6] → [-3, 6, -3]
</script>

API

cross(out, a, b)

Computes the cross product of two 3D arrays.

  • Parameters:
    • out: [number, number, number] — Output array (will be overwritten, required).
    • a: [number, number, number] — First input vector.
    • b: [number, number, number] — Second input vector.
  • Returns: The out array (same reference as input).

cross64(out, a, b)

Computes the cross product of two 3D Float64Array vectors (optimized for performance).

  • Parameters:
    • out: Float64Array — Output buffer (length 3, will be overwritten, required).
    • a: Float64Array — First input vector (length 3).
    • b: Float64Array — Second input vector (length 3).
  • Returns: The out buffer (same reference as input).

Module Formats

  • ESM: dist/esm/index.js (for modern bundlers like Webpack, Rollup).
  • CommonJS: dist/cjs/index.js (for Node.js).
  • IIFE: dist/iife/cross3d.js (global variable: crossproduct).
    Minified version: dist/iife/cross3d.min.js.

Performance

  • Operations per Second: ~180 million (for cross64 in Node.js 20+).
  • Memory Efficiency: cross64 uses 50% less memory than array-based approaches (24 bytes per vector vs. ~48 bytes).
  • GC Friendly: No temporary allocations when reusing out vectors.