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

abschreibung

v0.1.0

Published

Deferred cost allocation utilities for inclusive date ranges.

Readme

abschreibung

Deferred cost allocation utilities for inclusive date ranges.

Install

npm install abschreibung

Date Behavior

All date ranges are inclusive. A range from 2020-01-01 to 2020-01-01 has 1 day; a range from 2020-01-01 to 2020-01-02 has 2 days.

The package works with JavaScript Date values and normalizes calculations to calendar days.

Types

type DeferredCostAllocationMode = "monthly" | "yearly";

interface DeferredCostInput {
  startDate: Date;
  endDate: Date;
  totalCost: number;
}

interface DeferredCostPeriod {
  timeStart: string;
  timeEnd: string;
  days: number;
  costs: number;
}

DeferredCostPeriod.timeStart and DeferredCostPeriod.timeEnd are formatted as YYYY-MM-DD.

calculateDeferredCostAllocation

Calculates deferred cost periods by month or year. The default mode is yearly.

import { calculateDeferredCostAllocation } from "abschreibung";

const periods = calculateDeferredCostAllocation(
  {
    startDate: new Date("2020-01-01"),
    endDate: new Date("2020-02-01"),
    totalCost: 1000,
  },
  "monthly",
);

Returns:

[
  { timeStart: "2020-01-01", timeEnd: "2020-01-31", days: 31, costs: 968.75 },
  { timeStart: "2020-02-01", timeEnd: "2020-02-01", days: 1, costs: 31.25 },
];

calculateMonthlyDeferredCostAllocation

Calculates deferred cost periods split by calendar month.

import { calculateMonthlyDeferredCostAllocation } from "abschreibung";

const periods = calculateMonthlyDeferredCostAllocation({
  startDate: new Date("2020-01-31"),
  endDate: new Date("2020-02-02"),
  totalCost: 1000,
});

Returns:

[
  { timeStart: "2020-01-31", timeEnd: "2020-01-31", days: 1, costs: 333.3333333333333 },
  { timeStart: "2020-02-01", timeEnd: "2020-02-02", days: 2, costs: 666.6666666666666 },
];

If the full range is inside one calendar month, the function returns one period with the full totalCost.

calculateYearlyDeferredCostAllocation

Calculates deferred cost periods split by calendar year.

import { calculateYearlyDeferredCostAllocation } from "abschreibung";

const periods = calculateYearlyDeferredCostAllocation({
  startDate: new Date("2020-12-31"),
  endDate: new Date("2021-01-01"),
  totalCost: 1000,
});

Returns:

[
  { timeStart: "2020-12-31", timeEnd: "2020-12-31", days: 1, costs: 500 },
  { timeStart: "2021-01-01", timeEnd: "2021-01-01", days: 1, costs: 500 },
];

If the full range is inside one calendar year, the function returns one period with the full totalCost.

calculateDailyDeferredCost

Calculates the daily cost for an inclusive date range.

import { calculateDailyDeferredCost } from "abschreibung";

const costPerDay = calculateDailyDeferredCost({
  startDate: new Date("2020-01-01"),
  endDate: new Date("2020-01-03"),
  totalCost: 1000,
});

Returns:

333.3333333333333;

calculateInclusiveDayCount

Counts calendar days between two dates, including both the start and end date.

import { calculateInclusiveDayCount } from "abschreibung";

const days = calculateInclusiveDayCount(new Date("2020-02-01"), new Date("2020-03-01"));

Returns:

30;

Publishing

Pushing to the main branch publishes the package to npm through GitHub Actions.

Required repository secret:

  • NPM_TOKEN: npm automation token with publish access for abschreibung.

The workflow checks whether the current package.json version already exists on npm. If it does, it bumps the patch version until it finds an unpublished version, commits the updated package.json and package-lock.json back to main, and publishes that version.