CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/licenses/purchase/utils.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
export function money(n: number, hideCurrency: boolean = false): string {
7
let s = new Intl.NumberFormat(undefined, {
8
style: "currency",
9
currency: "USD",
10
minimumFractionDigits: 0,
11
}).format(n);
12
const i = s.indexOf(".");
13
if (i == s.length - 2) {
14
s += "0";
15
}
16
return (hideCurrency ? "" : "USD ") + s;
17
}
18
19