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

norm.js

v0.1.3

Published

Array and object normalization

Readme

norm.js

Build Status Coverage Status npm version

A small collection of methods for array and object normalization, standardization, and simple statistics.

Usage

$ npm install norm.js
var n = require("norm.js");

All of norm.js's methods accept both arrays and objects as inputs. If an object is used, then calculations are done on the object's values. The adjusted (normalized) values remain associated with the same key.

n.norm calculates the norm (length) of the input array/object. It accepts an optional second argument, which specifies the length type. This can take the following values: Euclidean, L1, max, min. If no second argument is supplied, then a simple sum is used.

n.norm([0.1, 3, 1.21, -1, 0.2], "Euclidean"); // 3.393243286297049

n.normalize divides all elements of the input array/object by a constant value (the norm). It accepts an optional second argument, the same as n.norm. If no second argument is supplied, then normalization simply divides by the sum (so that elements of the array/object will sum to 1).

n.normalize({a: 0.1, b: 0.2});
// outputs:
{
    a: 0.3333333333333333,
    b: 0.6666666666666666
}

n.standardize divides all elements of the input array/object by their standard deviation. It accepts an optional second argument, which specifies whether Bessel's correction is used; this should be set to true if the inputs are sample values. (If left blank, elements are assumed to be population values.)

n.standardize({a: 0.1, b: 3, c: 1.21, d: -1, e: 0.2}, true);
// outputs:
{
    a: 0.06648195568920466,
    b: 1.9944586706761396,
    c: 0.8044316638393763,
    d: -0.6648195568920465,
    e: 0.13296391137840932
}

norm.js also includes n.variance, n.std, n.rescale, n.mean, and n.sum methods. Examples (and function signatures, etc.) can be found in test/norm.js.

Tests

Unit tests are included in test/, and can be run using npm:

$ npm test