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

@anephenix/measure

v0.1.18

Published

A measurement framework from Anephenix

Downloads

332

Readme

Measure

A measurement framework from Anephenix

npm version example workflow Socket Badge

Install

npm i @anephenix/measure

Dependencies

  • Node.js (version 22+)

Usage

// Setting up your Measure instance
const measure = new Measure({
  // Can be 'sample', 'population', or 'date' - default value is sample
  type: 'sample',
});

// I want to record some measurements locally
const value = 2;
measure.record(value);

// Or pass more values
const moreValues = [3, 4, 5];
measure.record(moreValues);

// Get all of the recordings
measure.recordings;

// Calculate the mean, median, and modal values
measure.mean();
measure.median();
measure.mode();

// Get the standard deviation of the measurements
measure.stdev();

// Get the variance of the measurements
measure.variance();

// Get an object detailing how many times each value occurs
measure.counts();

// Calculate the standard score (z-score) of a value
measure.zscore(3);

// Calculate the simple moving average over the last N recordings
measure.simpleMovingAverage(3); // Returns the average of the last 3 recordings

// Defining a target and checking whether it has been achieved
// Pass a target when creating the Measure instance. A target has three fields:
//   stat     - which statistic to evaluate: 'mean', 'median', 'mode', 'variance', 'stdev', or 'zscore'
//   operator - comparison to apply: '>', '<', '>=', '<=', or '='
//   value    - the threshold to compare against
//   input    - (zscore only) the value whose z-score is computed
const targetMeasure = new Measure({
  target: { stat: 'mean', operator: '>', value: 80 },
});
targetMeasure.record([72, 85, 91, 78, 88]);

// Returns true/false once there are recordings, or null if there are none yet
targetMeasure.targetAchieved(); // true  (mean is 82.8, which is > 80)

// Returns the full status object
targetMeasure.targetStatus();
// {
//   target:   { stat: 'mean', operator: '>', value: 80 },
//   actual:   82.8,
//   achieved: true,
// }

// Targeting other stats works the same way:
new Measure({ target: { stat: 'median',   operator: '>=', value: 85  } });
new Measure({ target: { stat: 'mode',     operator: '=',  value: 3   } }); // checks mode array includes 3
new Measure({ target: { stat: 'variance', operator: '<',  value: 2   } });
new Measure({ target: { stat: 'stdev',    operator: '<=', value: 1.5 } });
new Measure({ target: { stat: 'zscore',   operator: '>',  value: 0.5, input: 4 } });

// Measuring dates
// Use type 'date' to record Date objects and analyse them by time unit
const dateMeasure = new Measure({ type: 'date' });
dateMeasure.record(new Date('2024-01-15T10:30:45'));
dateMeasure.record(new Date('2024-03-20T14:00:00'));
dateMeasure.record(new Date('2025-01-15T10:45:00'));

// Count recordings by a date unit - returns an object of unit-value → count
// Supported units: 'year', 'month', 'date', 'dayOfWeek', 'hour', 'minute', 'second', 'millisecond'
// month uses 0-based indexing (0 = January, 11 = December)
// dayOfWeek uses 0-based indexing (0 = Sunday, 6 = Saturday)
dateMeasure.countBy('year');      // { '2024': 2, '2025': 1 }
dateMeasure.countBy('month');     // { '0': 2, '2': 1 }
dateMeasure.countBy('dayOfWeek'); // { '1': 1, '3': 2 }
dateMeasure.countBy('hour');      // { '10': 2, '14': 1 }

Tests

npm t

License and Credits.

© 2026 Anephenix Ltd. Measure is licensed under the MIT license.