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

javlin-pure

v0.0.1

Published

Just Another Vector Library in Node - Pure

Readme

javlin-pure (pronounced "javelin pure")

Just Another Vector Library In Node - Pure

Pure, stateless, modular vector manipulation functions written in Javascript. Designed for Node.js.

Key Attributes

Vector Types are Simple Arrays

All vectors are simple arrays of numbers. The vector "dimension" is just the length of the array (number of elements). "n-dimensional" means the function can act on vectors (arrays) of any length.

Pure functions

All vector functions are pure functions - they return a new array as the result instead of mutating an existing array.

Stateless

All vector functions are stateless - they are not methods of a class instance prototype

Module pattern

Each function resides in its own individual file and is designed to run in Node.js. They can be run in a browser using Browserify. Dependencies are included with 'require()' and each function is exported via "module.exports"

Unit Testing

Full unit testing suite implemented using Tape (TAP output) for node, npm and Testling. Easily configurable for Travis-ci. Includes "pretty-print" tests using tap-spec for Windows and Linux.

APIs

The following are the API descriptions. The file name is the API (function) name followed by ".js"

add(vec1, vec2)

Adds two n-dimensional vectors, returning the result in a new vector

var vec = add([1, 2], [3, 4]); // vec === [4, 6]

sub(vec1, vec2)

Subtracts two n-dimensional vectors (subtracts vec2 from vec1), returning the result in a new vector

var vec = sub([1, 2], [3, -4]); // vec === [-2, 6]

scale(vec, scalar)

Scales an n-dimensional vector by scalar (just a number), returning the result in a new vector

var vec = scale([1, 2], 3); // vec === [3, 6]

dot(vec1, vec2)

Computes the dot (inner) product of two n-dimensional vectors

var value = dot([1, 2], [3, 4]); // value === 11

mag(vec)

Computes the magnitude (length) of an n-dimensional vector

var value = mag([3, 4]); // value === 5

norm(vec)

Normalizes an n-dimensional vector (returns vector of magnitude 1, or unit vector, retaining direction)

var vec = norm([3, 4]); // vec === [.6, .8]

proj(vec1, vec2)

Returns the projection of n-dimensional vector vec1 along vec2

var vec = proj([3, 4, 5], [6, 8, 0]); // vec === [3, 4, 0]

angle(vec)

Returns the angle in radians from 0 to PI of an n-dimensional vector. Angle is 0 along the positive x axis and positive counterclockwise. NOTE: This function does not retain angle sign information

var value = angleN([5, 5, 0, 0, 0]); // value === 0.785

angle2d(vec)

Returns the angle in radians from -PI to PI of a 2-dimensional vector. Angle is 0 along the positive x axis and positive counterclockwise. This is a simple wrapper for Math.atan2(y, x)

var value = angle2d([3, 4]); // value === 0.927

fromPolar2d(mag, angle)

Given a magnitude and angle in radians positive counterclockwise from the x axis returns a 2-dimensional vector

var vec = fromPolar2d(5, 0.927); // vec === [3, 4] (very close approximations)