MCPcopy Index your code
hub / github.com/coder/coder / dollarsToMicros

Function dollarsToMicros

site/src/utils/currency.ts:23–30  ·  view source on GitHub ↗
(dollars: string | number)

Source from the content-addressed store, hash-verified

21}
22
23export function dollarsToMicros(dollars: string | number): number {
24 if (typeof dollars === "string" && dollars.trim() === "") {
25 return 0;
26 }
27
28 const micros = Math.round(Number(dollars) * MICROS_PER_DOLLAR);
29 return Number.isFinite(micros) && micros > 0 ? micros : 0;
30}
31
32export function isPositiveFiniteDollarAmount(dollars: string): boolean {
33 return dollars.trim() !== "" && dollarsToMicros(dollars) > 0;

Callers 5

currency.test.tsFile · 0.90
handleSaveDefaultFunction · 0.90
handleAddGroupOverrideFunction · 0.90
handleAddOverrideFunction · 0.90

Calls 1

NumberFunction · 0.85

Tested by

no test coverage detected