UNPKG

@prestamype/financial-functions

Version:
28 lines (21 loc) • 463 B
import { bisection, newton } from '../_lib/tir.js' function wrapFun(fn) { return function(...args) { return new Promise(resolve => setTimeout(() => { return resolve(fn(...args)) }, 0)) } } function tcea(tir) { return Math.pow(1 + tir, 12) - 1 } const tir_async_fn = wrapFun(bisection) async function main(flow) { const tir = await tir_async_fn(flow) return { tir, tcea: tcea(tir), tcem: tir } } export { main, tcea, tir_async_fn as tir }