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

bunkmate

v2.0.0

Published

BunkMate attendance calculation utilities

Readme

BunkMate

Attendance calculation utilities for students.

BunkMate provides simple utility functions for calculating current attendance, predicting attendance after planned absences, and determining the number of recovery classes required to reach a target attendance percentage.

Features

  • Calculate current attendance percentage.
  • Predict attendance after missing additional classes.
  • Calculate recovery classes required to reach a target attendance percentage.
  • Predicted attendance is rounded up using Math.ceil().
  • Handles zero or non-positive class totals.
  • Handles target-attendance edge cases.
  • Uses CommonJS and can be imported with require().

Installation

Install bunkmate using npm:

npm install bunkmate

Usage

const {
    calculateAttendance,
    calculatePredictedAttendance,
    calculateRecoveryClasses
} = require("bunkmate");

API Reference

calculateAttendance(classAttended, totalClasses)

Calculates the current attendance percentage.

Parameters

| Parameter | Type | Description | |---|---|---| | classAttended | number | Number of classes attended | | totalClasses | number | Total number of classes |

Formula

Attendance = (Classes Attended / Total Classes) × 100

Example

const { calculateAttendance } = require("bunkmate");

const attendance = calculateAttendance(8, 10);

console.log(attendance);
// 80

If totalClasses is 0 or less, the function returns 0.

calculateAttendance(8, 0);
// 0

calculatePredictedAttendance(classAttended, totalClasses, missClasses)

Calculates the predicted attendance percentage after missing a specified number of additional classes.

The result is always rounded up using Math.ceil().

Parameters

| Parameter | Type | Description | |---|---|---| | classAttended | number | Number of classes attended | | totalClasses | number | Current total number of classes | | missClasses | number | Number of additional classes that will be missed |

Formula

Predicted Attendance =
(Classes Attended / (Total Classes + Missed Classes)) × 100

The result is rounded upward.

Example

const { calculatePredictedAttendance } = require("bunkmate");

const predicted = calculatePredictedAttendance(8, 10, 2);

console.log(predicted);
// 67

The mathematical result is approximately 66.67, which is rounded up to 67.

If the future total number of classes is 0 or less, the function returns 0.


calculateRecoveryClasses(classAttended, totalClasses, missClasses, targetAttendance)

Calculates the number of classes required to recover to the target attendance percentage after the planned missed classes.

The returned number of classes is rounded up because a fraction of a class cannot be attended.

Parameters

| Parameter | Type | Description | |---|---|---| | classAttended | number | Number of classes attended | | totalClasses | number | Current total number of classes | | missClasses | number | Number of classes that will be missed | | targetAttendance | number | Target attendance percentage |

Formula

Recovery Classes =
(
  (Target Attendance × (Total Classes + Missed Classes))
  - (Classes Attended × 100)
)
/
(100 - Target Attendance)

Example

const { calculateRecoveryClasses } = require("bunkmate");

const recovery = calculateRecoveryClasses(8, 10, 2, 75);

console.log(recovery);
// 4

This means that after attending 8 out of 10 classes and then missing 2 additional classes, 4 further classes are required to reach the 75% target.

If the predicted attendance is already at or above the target, the function returns 0.

calculateRecoveryClasses(8, 10, 0, 75);
// 0

A target attendance of 100% or higher returns 0 based on the package's current implementation.


Complete Example

const {
    calculateAttendance,
    calculatePredictedAttendance,
    calculateRecoveryClasses
} = require("bunkmate");

const classAttended = 8;
const totalClasses = 10;
const missClasses = 2;
const targetAttendance = 75;

const currentAttendance = calculateAttendance(
    classAttended,
    totalClasses
);

const predictedAttendance = calculatePredictedAttendance(
    classAttended,
    totalClasses,
    missClasses
);

const recoveryClasses = calculateRecoveryClasses(
    classAttended,
    totalClasses,
    missClasses,
    targetAttendance
);

console.log("Current Attendance:", currentAttendance);
// Current Attendance: 80

console.log("Predicted Attendance:", predictedAttendance);
// Predicted Attendance: 67

console.log("Recovery Classes:", recoveryClasses);
// Recovery Classes: 4

API Summary

| Function | Description | |---|---| | calculateAttendance() | Calculates current attendance percentage | | calculatePredictedAttendance() | Calculates predicted attendance after missing classes | | calculateRecoveryClasses() | Calculates classes required to reach the target attendance |

CommonJS

bunkmate uses the CommonJS module system.

Import the package using:

const bunkmate = require("bunkmate");

Or destructure the functions:

const {
    calculateAttendance,
    calculatePredictedAttendance,
    calculateRecoveryClasses
} = require("bunkmate");

Development

Clone the repository:

git clone https://github.com/Adhyatm2717/BunkMate_npm.git

Navigate into the project:

cd BunkMate_npm

Install dependencies:

npm install

Package Information

  • Package: bunkmate
  • Version: 1.0.0
  • License: ISC
  • Author: Adhyatm Mudgal

Repository

GitHub:

https://github.com/Adhyatm2717/BunkMate_npm

Issues

Report bugs or request changes through the GitHub Issues page:

https://github.com/Adhyatm2717/BunkMate_npm/issues

Author

Adhyatm Mudgal

GitHub:

https://github.com/Adhyatm2717