npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details


  • User packages



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.


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




A simple utility function, and command line utility, for calculating an aspect ratio based on width and height.




📐 calculate-aspect-ratio

A simple utility function, and command line utility, for calculating an aspect ratio based on width and height.



npm install --save calculate-aspect-ratio

Via Yarn

yarn add calculate-aspect-ratio


npm install -g calculate-aspect-ratio

How to use

There are two ways you can use this module. You can use it directly in your Javascript by importing it and calculating various aspect ratios where you need them.

I’ve also included a handy command line utility that you can use to determine the aspect ratio by calling it and providing a width and height.


The import is useful in scenarios where you need to calculate the aspect ratio when you have access to an assets width and height.

I’m currently using this to determine the aspect ratio of videos accessed via a CMS and passing the aspect ratio to react-video-players so they scale nicely in fluid layouts.

import calculateAspectRatios from 'calculate-aspect-ratio';

In addition to the method used to calculate the aspect ratio, I’ve also exposed the method used to get the greatest common divisor. You can access that via the gcd export.

import { gcd } from 'calculate-aspect-ratio';


import calculateAspectRatio from 'calculate-aspect-ratio';

const aspectRatio = calculateAspectRatio(2880, 1800);   // '8:5'


A simple utility command that you can run via the command line to return the aspect ratio for a provided width and height.

$ aspectratio [options] [width] [height]


| Option | Description | | ------------------- | ------------------------- | | -V, --version | output the version number | | -h, --help | output usage information |


| Argument | Type | Default | | ------------------- | ----------- | ----------- | | width | Number | 1920 | | height | Number | 1080 |


$ aspectratio 2880 1800    // Output -> Aspect ratio: 8:5

Need an easy way to calculate aspect ratios?

After making calculate-aspect-ratio, I realized that in addition to the CLI tool, it might be nice to make a site that makes it easy for non-developers –  and developers alike – to review and calculate various aspect ratios, as well as reference common device resolutions. So, I made a handy tool that does just that, offering a visual way to calculate and reference aspect ratios. I hope you find it useful 😀

Check out:


MIT © Ryan Hefner