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 🙏

© 2024 – Pkg Stats / Ryan Hefner

vector-tools

v0.1.0

Published

A set of pure functions that perform common calculations on JavaScript TypedArrays

Downloads

4

Readme

vector-tools

A set of pure functions that perform common calculations on JavaScript TypedArrays.

Warning: This library is not production-ready.

This is not a particularly complete or optimised library, I just made it for my personal use as I was tired of writing the same for loops over and over. But it's super lightweight and ES6 ready so someone may enjoy it.

Installation

node
npm install vector-tools
web

Include dist/web/vector-tools.js in a <script> tag in your HTML head.

Usage

  • in node, you can import specific functions from the library:
import { vscale } from 'vector-tools';
  • or import the entire library:
import * as VectorTools from 'vector-tools';
  • in the Web, you get the VectorTools object on the window.

API

Functions starting with v always return a TypedArray vector. Return types of other functions and utilities are indicated below.

Number sum(a)

calculates the sum of components in vector a

Number dot(a, b)

calculates the dot product of a and b

Array<TypedArray> segment(a, seq_len)

segments the vector into ceil(a/seq_len) segments of length seq_len. The last segment may be smaller than seq_len. Returns a list of segments.

vsum(a, b)

returns component-wise sum vector of a and b.

vadd(a, x)

returns a copy of a with components increased by x.

vscale(a, x)

returns a copy of a with components scaled (multiplied) by x.

vconcat(a, b)

returns a concatenated vector of a and b.

vnormalize(a[, scale])

returns a normalized copy of a, optionally scaled by scale.

utils

  • Array typed_to_array(a) – converts TypedArray to Array
  • TypedArray array_to_typed(a, type) – converts Array to TypedArray of type type.
  • Number randint(range) - returns a random integer between 0 and range.
  • TypedArrayConstructor get_type(a) – returns the constructor (and therefore type) of the passed TypedArray. If argument is not TypedArray, throws TypeError.

Development

cd vector-tools
npm install

Tests are written with Jasmine, run with npm test.

To build for node, run npm run node-compile. For web (webpack), npm run web-compile. For everything, npm run build.