Comparing version 2.0.3 to 2.0.5
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./irr")); | ||
__export(require("./polynomial")); | ||
__export(require("./root-finder")); | ||
__export(require("./utils")); | ||
__exportStar(require("./irr"), exports); | ||
__exportStar(require("./polynomial"), exports); | ||
__exportStar(require("./root-finder"), exports); | ||
__exportStar(require("./utils"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertRate = exports.RateInterval = void 0; | ||
var RateInterval; | ||
@@ -24,4 +25,5 @@ (function (RateInterval) { | ||
function convertRate(rate, toInterval, fromInterval = RateInterval.Day) { | ||
return (1 + rate) ** (parseInterval(toInterval) / parseInterval(fromInterval)) - 1; | ||
return ((1 + rate) ** (parseInterval(toInterval) / parseInterval(fromInterval)) - 1); | ||
} | ||
exports.convertRate = convertRate; | ||
//# sourceMappingURL=convert-rate.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./convert-rate")); | ||
__exportStar(require("./convert-rate"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,8 +0,8 @@ | ||
export declare type XirrInput = { | ||
export type XirrInput = { | ||
amount: number; | ||
date: string | Date; | ||
}; | ||
export declare type InternalXirrInput = { | ||
export type InternalXirrInput = { | ||
amount: number; | ||
day: number; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=definition.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./convert-rate")); | ||
__export(require("./irr")); | ||
__export(require("./transform")); | ||
__export(require("./xirr")); | ||
__exportStar(require("./convert-rate"), exports); | ||
__exportStar(require("./definition"), exports); | ||
__exportStar(require("./irr"), exports); | ||
__exportStar(require("./transform"), exports); | ||
__exportStar(require("./xirr"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./irr")); | ||
__exportStar(require("./irr"), exports); | ||
//# sourceMappingURL=index.js.map |
import { RootFinderOptions } from '../../root-finder'; | ||
export declare function irr(values: number[], options?: RootFinderOptions): number; | ||
export declare function irr(values: number[], options?: Partial<RootFinderOptions>): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.irr = void 0; | ||
const polynomial_1 = require("../../polynomial"); | ||
const root_finder_1 = require("../../root-finder"); | ||
function irr(values, options = root_finder_1.DEFAULT_ROOT_FINDER_OPTIONS) { | ||
function irr(values, options = {}) { | ||
const polynomial = new polynomial_1.Polynomial(values); | ||
const root = polynomial.findRoot(options); | ||
const root = polynomial.findRoot((0, root_finder_1.getRootFinderOptionsWithDefaults)(options)); | ||
if (!root.converged) { | ||
@@ -14,1 +15,2 @@ return NaN; | ||
exports.irr = irr; | ||
//# sourceMappingURL=irr.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./transform")); | ||
__exportStar(require("./transform"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const DATE_PATTERNS = [ | ||
/^(\d{4})[-/]?(\d{2})[-/]?(\d{2})$/, | ||
]; | ||
exports.transform = void 0; | ||
const DATE_PATTERNS = [/^(\d{4})[-/]?(\d{2})[-/]?(\d{2})$/]; | ||
const DAYS_TO_MS = 24 * 60 * 60 * 1000; | ||
function calculateDaysBetweenStrict(_from, _to) { | ||
const fromDays = Math.floor(_from.valueOf() / DAYS_TO_MS); | ||
const toDays = Math.floor(_to.valueOf() / DAYS_TO_MS); | ||
function calculateDaysBetweenStrict(from, to) { | ||
const fromDays = Math.floor(from.valueOf() / DAYS_TO_MS); | ||
const toDays = Math.floor(to.valueOf() / DAYS_TO_MS); | ||
return toDays - fromDays; | ||
@@ -20,2 +19,3 @@ } | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const [, year, month, day] = date.match(pattern); | ||
@@ -36,8 +36,5 @@ return new Date(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10)); | ||
})); | ||
const firstDay = Math.min(...transformedInputs.map(({ day }) => day)); | ||
if (firstDay !== 0) { | ||
transformedInputs.forEach((_, index) => transformedInputs[index].day -= firstDay); | ||
} | ||
return transformedInputs; | ||
} | ||
exports.transform = transform; | ||
//# sourceMappingURL=transform.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./xirr")); | ||
__exportStar(require("./xirr"), exports); | ||
//# sourceMappingURL=index.js.map |
import { RootFinderOptions } from '../../root-finder'; | ||
import { XirrInput } from '../definition'; | ||
export declare function xirr(inputs: XirrInput[], options?: RootFinderOptions): { | ||
export declare function xirr(inputs: XirrInput[], options?: Partial<RootFinderOptions>): { | ||
days: number; | ||
rate: number; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.xirr = void 0; | ||
const irr_1 = require("../irr"); | ||
const root_finder_1 = require("../../root-finder"); | ||
const transform_1 = require("../transform"); | ||
const utils_1 = require("../../utils"); | ||
function xirr(inputs, options = root_finder_1.DEFAULT_ROOT_FINDER_OPTIONS) { | ||
const transformedInputs = transform_1.transform(inputs); | ||
function xirr(inputs, options = {}) { | ||
const transformedInputs = (0, transform_1.transform)(inputs); | ||
const days = transformedInputs.map(input => input.day); | ||
@@ -13,9 +13,10 @@ const firstDay = Math.min(...days); | ||
const totalDays = lastDay - firstDay + 1; | ||
const coefficients = utils_1.zeros(totalDays); | ||
transformedInputs.forEach(({ amount, day }) => coefficients[day] += amount); | ||
const coefficients = (0, utils_1.zeros)(totalDays); | ||
transformedInputs.forEach(({ amount, day }) => (coefficients[day] += amount)); | ||
return { | ||
days: totalDays, | ||
rate: irr_1.irr(coefficients, options), | ||
rate: (0, irr_1.irr)(coefficients, options), | ||
}; | ||
} | ||
exports.xirr = xirr; | ||
//# sourceMappingURL=xirr.js.map |
import { RootFinderOptions, Root } from '../root-finder'; | ||
export interface IPolynomial { | ||
calculate(x: number): number; | ||
findRoot(options?: RootFinderOptions): Root; | ||
findRoot(options?: Partial<RootFinderOptions>): Root; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=definition.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./line")); | ||
__export(require("./polynomial")); | ||
__exportStar(require("./definition"), exports); | ||
__exportStar(require("./line"), exports); | ||
__exportStar(require("./polynomial"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./line")); | ||
__exportStar(require("./line"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Line = void 0; | ||
class Line { | ||
@@ -26,1 +27,2 @@ constructor(m, k) { | ||
exports.Line = Line; | ||
//# sourceMappingURL=line.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./polynomial")); | ||
__exportStar(require("./polynomial"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Polynomial = void 0; | ||
const root_finder_1 = require("../../root-finder"); | ||
@@ -35,12 +36,11 @@ const line_1 = require("../line"); | ||
}); | ||
return this.derivative = new Polynomial(coefficients); | ||
return (this.derivative = new Polynomial(coefficients)); | ||
} | ||
findRoot(options) { | ||
options = Object.assign({}, root_finder_1.DEFAULT_ROOT_FINDER_OPTIONS, options); | ||
const factory = new root_finder_1.RootFinderFactory(options); | ||
const finder = factory.make(options.method); | ||
const root = finder.findRoot(this); | ||
if (options.fallbackMethod | ||
&& !root.converged | ||
&& options.method !== options.fallbackMethod) { | ||
if (options.fallbackMethod && | ||
!root.converged && | ||
options.method !== options.fallbackMethod) { | ||
const fallbackFinder = factory.make(options.fallbackMethod); | ||
@@ -62,1 +62,2 @@ return fallbackFinder.findRoot(this); | ||
exports.Polynomial = Polynomial; | ||
//# sourceMappingURL=polynomial.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BisectionRootFinder = void 0; | ||
const utils_1 = require("../../utils"); | ||
@@ -23,3 +24,3 @@ class BisectionRootFinder { | ||
const upperLimit = this.findUpperLimit(polynomial); | ||
if (!utils_1.isValidRoot(upperLimit)) { | ||
if (!(0, utils_1.isValidRoot)(upperLimit)) { | ||
return { | ||
@@ -62,1 +63,2 @@ converged: false, | ||
exports.BisectionRootFinder = BisectionRootFinder; | ||
//# sourceMappingURL=bisection.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./bisection")); | ||
__exportStar(require("./bisection"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -6,10 +6,10 @@ import { Polynomial } from '../polynomial'; | ||
} | ||
export declare type RootFinderOptions = { | ||
epsilon?: number; | ||
estimate?: number | 'auto'; | ||
fallbackMethod?: RootFinderMethod | null; | ||
maxIterations?: number; | ||
method?: RootFinderMethod; | ||
export type RootFinderOptions = { | ||
epsilon: number; | ||
estimate: number | 'auto'; | ||
fallbackMethod: RootFinderMethod | null; | ||
maxIterations: number; | ||
method: RootFinderMethod; | ||
}; | ||
export declare type Root = { | ||
export type Root = { | ||
converged: boolean; | ||
@@ -23,1 +23,2 @@ iterations: number; | ||
export declare const DEFAULT_ROOT_FINDER_OPTIONS: RootFinderOptions; | ||
export declare function getRootFinderOptionsWithDefaults(options: Partial<RootFinderOptions>): RootFinderOptions; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRootFinderOptionsWithDefaults = exports.DEFAULT_ROOT_FINDER_OPTIONS = exports.RootFinderMethod = void 0; | ||
var RootFinderMethod; | ||
@@ -15,1 +16,6 @@ (function (RootFinderMethod) { | ||
}; | ||
function getRootFinderOptionsWithDefaults(options) { | ||
return Object.assign({}, exports.DEFAULT_ROOT_FINDER_OPTIONS, options); | ||
} | ||
exports.getRootFinderOptionsWithDefaults = getRootFinderOptionsWithDefaults; | ||
//# sourceMappingURL=definition.js.map |
import { RootFinderMethod, IRootFinder, RootFinderOptions } from '../definition'; | ||
export interface IRootFinderConstructor { | ||
new (options: RootFinderOptions): IRootFinder; | ||
} | ||
export declare class RootFinderFactory { | ||
protected readonly options: RootFinderOptions; | ||
private readonly options; | ||
constructor(options: RootFinderOptions); | ||
make(method: RootFinderMethod): IRootFinder; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RootFinderFactory = void 0; | ||
const definition_1 = require("../definition"); | ||
@@ -22,1 +23,2 @@ const bisection_1 = require("../bisection"); | ||
exports.RootFinderFactory = RootFinderFactory; | ||
//# sourceMappingURL=factory.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./factory")); | ||
__exportStar(require("./factory"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./bisection")); | ||
__export(require("./definition")); | ||
__export(require("./factory")); | ||
__export(require("./newton")); | ||
__exportStar(require("./bisection"), exports); | ||
__exportStar(require("./definition"), exports); | ||
__exportStar(require("./factory"), exports); | ||
__exportStar(require("./newton"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./newton")); | ||
__exportStar(require("./newton"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NewtonRootFinder = void 0; | ||
const utils_1 = require("../../utils"); | ||
@@ -21,3 +22,3 @@ class NewtonRootFinder { | ||
}); | ||
return ((positive / negative) - 1) / length + 1; | ||
return (positive / negative - 1) / length + 1; | ||
} | ||
@@ -29,5 +30,3 @@ findRoot(polynomial) { | ||
let iteration = 0; | ||
let root = estimate === 'auto' | ||
? this.autoEstimate(polynomial) | ||
: estimate; | ||
let root = estimate === 'auto' ? this.autoEstimate(polynomial) : estimate; | ||
while (iteration++ < maxIterations) { | ||
@@ -45,3 +44,3 @@ const tangent = polynomial.getTangentAt(root); | ||
} | ||
if (!utils_1.isValidRoot(root)) { | ||
if (!(0, utils_1.isValidRoot)(root)) { | ||
return { | ||
@@ -62,1 +61,2 @@ converged: false, | ||
exports.NewtonRootFinder = NewtonRootFinder; | ||
//# sourceMappingURL=newton.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./is-valid-root")); | ||
__export(require("./zeros")); | ||
__exportStar(require("./is-valid-root"), exports); | ||
__exportStar(require("./zeros"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./is-valid-root")); | ||
__exportStar(require("./is-valid-root"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isValidRoot = void 0; | ||
function isValidRoot(value) { | ||
@@ -7,1 +8,2 @@ return !isNaN(value) && isFinite(value) && value >= 0; | ||
exports.isValidRoot = isValidRoot; | ||
//# sourceMappingURL=is-valid-root.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./zeros")); | ||
__exportStar(require("./zeros"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.zeros = void 0; | ||
function zeros(length) { | ||
@@ -7,1 +8,2 @@ return new Array(length).fill(0); | ||
exports.zeros = zeros; | ||
//# sourceMappingURL=zeros.js.map |
{ | ||
"name": "node-irr", | ||
"version": "2.0.3", | ||
"version": "2.0.5", | ||
"description": "A Node.js package that provides an easy and customizable way to calculate internal rate of return.", | ||
@@ -20,25 +20,31 @@ "author": "Eric Malachias", | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.9", | ||
"@types/sinon": "^5.0.7", | ||
"chai": "^4.2.0", | ||
"mocha": "^5.2.0", | ||
"nodemon": "^1.19.2", | ||
"sinon": "^7.1.1", | ||
"ts-node": "^7.0.1", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.6" | ||
}, | ||
"scripts": { | ||
"build": "rm -rf ./dist && tsc", | ||
"test": "mocha -r ts-node/register ./**/*.test.ts", | ||
"dev": "nodemon -e ts,json --exec 'mocha -r ts-node/register ./**/*.test.ts'" | ||
"test": "jest", | ||
"test:coverage": "jest --coverage --collectCoverageFrom=src/**/*.ts", | ||
"test:watch": "jest --watchAll", | ||
"dev": "npm run test:watch", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "eslint . --ext .ts --fix" | ||
}, | ||
"dependencies": {}, | ||
"bugs": { | ||
"url": "https://github.com/eric-malachias/irr/issues" | ||
}, | ||
"homepage": "https://github.com/eric-malachias/irr#readme" | ||
"homepage": "https://github.com/eric-malachias/irr#readme", | ||
"devDependencies": { | ||
"@types/jest": "29.2.4", | ||
"@types/node": "18.11.17", | ||
"@typescript-eslint/eslint-plugin": "5.46.1", | ||
"@typescript-eslint/parser": "5.46.1", | ||
"eslint": "8.30.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"jest": "29.3.1", | ||
"nodemon": "2.0.20", | ||
"prettier": "2.8.1", | ||
"ts-jest": "29.0.3", | ||
"ts-node": "10.9.1", | ||
"tsconfig-paths": "4.1.1", | ||
"typescript": "4.9.4" | ||
} | ||
} |
# node-irr | ||
![](https://github.com/eric-malachias/irr/actions/workflows/nodejs.yml/badge.svg) | ||
[![Downloads](https://img.shields.io/npm/dm/node-irr.svg)](https://www.npmjs.com/package/node-irr) | ||
A Node.js package that provides an easy and customizable way to calculate internal rate of return. | ||
@@ -76,3 +79,3 @@ | ||
#### options.fallbackMethod | ||
#### options.method | ||
@@ -89,3 +92,3 @@ - type: RootFinderMethod | ||
##### options.method | ||
#### options.fallbackMethod | ||
@@ -92,0 +95,0 @@ - type: RootFinderMethod |
@@ -6,3 +6,3 @@ { | ||
"lib": ["es2017"], | ||
"sourceMap": false, | ||
"sourceMap": true, | ||
"strict": true, | ||
@@ -9,0 +9,0 @@ "noUnusedLocals": true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
390534
157
1505
123
14