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

@zenuinebit/attendance-leave

v0.1.0

Published

Holiday calendars, working days, leave balances and rules, year-end rollover, and monthly attendance that feeds payroll.

Readme

@zenuinebit/attendance-leave

Holiday calendars and working days, leave balances and rules, year-end rollover, and monthly attendance that gives payroll its working days and days paid. No dependencies. Dates are "YYYY-MM-DD"; leave days may be fractional (0.5 is a half day).

No leave policy or holiday list is built in. Leave types, quotas, carry-forward and holidays differ by company, state and law, so you define them. The names and numbers in the example are made up.

import {
  workingDaysInMonth, checkLeave, leaveEntry, accrual, annualGrant, rollover, balance, summarizeMonth, marksFromLeave,
} from "@zenuinebit/attendance-leave";
import { computePayslip } from "@zenuinebit/payroll-basics";

const calendar = { weeklyOff: [0], holidays: [{ date: "2025-04-14", name: "Holiday" }] };   // 0 = Sunday
const CL = { code: "CL", annualQuota: 12, carryForwardMax: 5, minNoticeDays: 2 };

let ledger = [annualGrant(CL, "2025-01-01")!];                  // keep your own list of entries

// A request: how many days, paid or unpaid?
const req = { leaveType: "CL", from: "2025-04-15", to: "2025-04-17", appliedOn: "2025-04-10" };
const check = checkLeave(req, { type: CL, calendar, entries: ledger, existing: [] });
check;   // { ok, days, paidDays, lossOfPayDays, balance, problems: [] }
if (check.ok) ledger.push(leaveEntry(req, check)!);             // record it once approved

balance(ledger, "CL", "2025-12-31");
ledger.push(...rollover(ledger, [CL], { closingDate: "2025-12-31", openingDate: "2026-01-01" }));   // lapse the excess, grant the new year

// A month of attendance for payroll
const marks = [...marksFromLeave(req, check, calendar, CL), { date: "2025-04-22", status: "absent" as const }];
const month = summarizeMonth({ year: 2025, month: 4, calendar, marks, unmarked: "present" });
month.lossOfPayDays;
month.payroll;     // { workingDays, paidDays } -> straight into computePayslip({ ..., ...month.payroll })

How it works

  • A working day is neither a weekly off nor a holiday. workingDaysInMonth and workingDaysBetween count them.
  • A leave request uses its working days (plus weekly offs and holidays inside it if the type has countNonWorkingDays), less half days. checkLeave reports problems (too little notice, too long, overlap, no working days, too little balance) and splits the days into paid and loss-of-pay. If the balance is short the request is refused, or with onInsufficient: "lop" the shortfall becomes loss of pay. Unpaid types are always loss of pay.
  • The ledger is a list of entries (grant, accrual, leave, lapse, adjustment) with signed days; the balance is derived from it on any date. accrual handles monthly earning (with pro-rata for a mid-month joiner) and maxBalance.
  • rollover lapses what exceeds carryForwardMax (default none) and grants the next year's quota, reduced to fit maxBalance.
  • summarizeMonth: weekly offs and holidays are paid and never cause loss of pay. A working day with no mark counts as absent unless you say unmarked: "present". basis: "calendar-days" gives payroll the days in the month instead of working days, for pay rules that work that way.

Not included: shift rosters, clock-in and clock-out hours, late-mark rules, leave encashment, optional or restricted holidays, and approval workflows (see @zenuinebit/expense-claims for a pattern).