Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/airgead-investment-calculator/llms.txt
Use this file to discover all available pages before exploring further.
js/lib/calculator.js is the core shared library. It exports the compound interest calculation function, a currency formatter, localStorage helpers for the current calculation and saved plans, and the CSV download utility. Every page that needs calculation or storage imports from this module.
Import
calculateCompoundInterest(inputs)
Runs a monthly compound interest projection for two parallel scenarios — one that includes monthly deposits and one that does not. The simulation steps through each month of every year, compounding at the given annual rate, and records a snapshot at the end of each year. Returns an array of year rows from year 0 to year N.
An object containing the four projection parameters.
The initial balance at year 0. Coerced to a number and clamped to ≥ 0.
The fixed amount added each month. Coerced to a number and clamped to ≥ 0.
The annual interest rate expressed as a percentage (e.g.
"5" for 5%). Coerced to a number and clamped to ≥ 0.The projection length in years. Coerced to a number, rounded to the nearest integer, and clamped to the range 0–80.
The year index.
0 is the starting snapshot; subsequent values are 1, 2, … N.The rounded projected balance when monthly deposits are included.
The rounded projected balance when no monthly deposits are made (interest-only growth).
The rounded cumulative total of the starting balance plus all monthly deposits made up to this year.
The rounded difference between
withDeposits and totalDeposits — i.e. the interest earned so far. Always 0 in the year-0 row.years is capped at 80 regardless of the value passed in. Values above 80 are silently clamped.money(value)
Formats a numeric value as a US dollar string with locale-separated thousands. Useful anywhere a human-readable currency display is needed.
The amount to format. Coerced to a number via
Number(value). Non-numeric values (including null and undefined) default to 0.string — the value rounded to the nearest integer and formatted as '$' + Math.round(Number(value)||0).toLocaleString().
saveCurrentCalculation(inputs, results)
Serializes inputs and results to localStorage under the key airgead_current_calc, alongside a UTC timestamp in ISO 8601 format. This is how the Calculator page passes data to the Results page.
The raw form inputs object (the same shape passed to
calculateCompoundInterest).The rows array returned by
calculateCompoundInterest.Calling this function overwrites any previously stored current calculation. Only the most recent calculation is retained.
getCurrentCalculation()
Reads and parses airgead_current_calc from localStorage. Returns null if no calculation has been stored yet, or if the stored value cannot be parsed as JSON.
Returns: { inputs, results, updatedAt } | null
The raw form inputs that were passed to
saveCurrentCalculation.The year rows that were passed to
saveCurrentCalculation.An ISO 8601 UTC timestamp recording when the calculation was saved.
The Results page redirects to the Calculator page if this function returns
null.getSavedPlans()
Reads and parses airgead_saved_plans from localStorage. Returns an empty array if the key is missing or if parsing fails — it never throws.
Returns: array — the array of saved plan objects, or [] if none exist.
setSavedPlans(plans)
Serializes a plans array and writes it to airgead_saved_plans in localStorage. This is the single write path for the saved plans list — used both when appending a new plan (from the Results page) and when removing a plan (from the Saved Plans page).
The full, updated array of plan objects to persist. Pass the complete array, not a diff.
downloadCsv(filename, rows)
Creates a CSV file entirely in the browser using the Blob API and triggers an immediate download without any server interaction. Values are quoted, and any double-quote characters within a value are escaped by doubling them.
The suggested filename for the downloaded file, including the
.csv extension (e.g. "airgead-20-year-plan.csv").A two-dimensional array where each inner array represents one row in the CSV. Every value is converted to a string, wrapped in double-quotes, and escaped before writing.
downloadCsv uses URL.createObjectURL and programmatic anchor click — both require a browser environment. It will not work in Node.js or other non-browser runtimes.