Skip to main content

JavaScript implementation of the XIRR LibreOffice Calc function.

This package works with Bun, Cloudflare Workers, Node.js, Deno, Browsers
JSR Score
100%
Published
2 weeks ago (3.0.0)

@webcarrot/xirr · GitHub license npm version

JavaScript implementation of the XIRR LibreOffice function. It should give the same results as equivalents from LibreOffice Calc, MS Excel, Google Spreadsheet etc.

Instalation

npm i @webcarrot/xirr

Usage

import { xirr, CashFlow } from "@webcarrot/xirr";

const flows: Array<CashFlow> = [
  {
    amount: 100,
    date: new Date("2019-02-02"),
  },
  {
    amount: -120,
    date: new Date("2019-03-02"),
  },
];

try {
  console.log("XIRR:", xirr(flows), "of", flows);
} catch (err) {
  console.log(err);
}

Methods and types

export type CashFlow = {
  readonly amount: number;
  readonly date: Date;
};
export declare function xirr(
  flows: ReadonlyArray<CashFlow>,
  guessRate?: number,
  maxEpsilon?: number,
  maxScans?: number,
  maxIterations?: number
): number;

Add Package

deno add @webcarrot/xirr

Import symbol

import * as mod from "@webcarrot/xirr";

Add Package

npx jsr add @webcarrot/xirr

Import symbol

import * as mod from "@webcarrot/xirr";

Add Package

yarn dlx jsr add @webcarrot/xirr

Import symbol

import * as mod from "@webcarrot/xirr";

Add Package

pnpm dlx jsr add @webcarrot/xirr

Import symbol

import * as mod from "@webcarrot/xirr";

Add Package

bunx jsr add @webcarrot/xirr

Import symbol

import * as mod from "@webcarrot/xirr";