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

cat-age-calculator

v1.0.6

Published

Returns the calculated cat age from a human equivalent age.

Downloads

17

Readme

Reverse cat age calculator 🐈

Returns the calculated cat age from a human equivalent age.

For eg. a 33 year old human is a 4 years and 3 months old cat.

Install

npm install cat-age-calculator --save

The entry file for this package is setup as an UMD module, allowing it to be used as a Node module and in the browser side too.

Usage

Pass an integer between 1 and 116 to one of the following functions...

1. Returns an object


getCatAgeObject(33);
 
// { years: 4, months: 3}

2. Returns a formatted string


getCatAgeString(33);

// '4 years and 3 months'

What it does behind the scenes

The known human to cat age data (see table below) were captured in an array of objects and the following functionality calculates the cat age:

  1. It first checks to see if the inputted value exists in the data array and returns the corresponding cat age if it finds a match.
  2. If the human age is below 28, it finds both the human and cat values before and after the inputted age within the data and uses them in a calculation.
  3. If the human age is above 28, it uses the last human and cat values in the data plus the logic that there are 4 human years to every 1 cat year in a calculation.
  4. Using the calculations above, a build script loops over a set of human years and generates an object containing every human year and it's equivalent cat age (the human years are the property keys and the cat ages are the property value).
  5. The public functions simply return the calculated cat age in different formats using the human age passed in as a key to lookup a property value.

What's up with cat ages

Cats age rapidly in the first two years of their life at a few different rates (see table below), after their second year of life each additional year is equal to about four human years.

| Human equivalent age | Actual cat age | |----------------------|-----------------| | 1 year | 1 month | | 4 years | 3 months | | 10 years | 6 months | | 12 years | 7 months | | 15 years | 1 year | | 21 years | 1 year 6 months | | 24 years | 2 years | | 28 years | 3 years | | + 4 years... | + 1 year... |