
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Few examples:
import { Money, $ } from 'quaney'
// Money = $; $ is just an alias for the Money class
const amount1 = $(42, 'USD')
const amount2 = amount1.add(10) // returns a new Money class instance with amount = 52 and currency = USD
const amount3 = amount1.sub(2, 'USD') // return a new Money class instance with amunt = 44 and currency = USD
amount1.format() // returns a string: $42
amount1.format({ symbol: false }) // returns a string without the symbol: 42
The Money class is a JavaScript/TypeScript class designed for handling monetary values. It provides various methods for performing arithmetic operations, formatting, and currency conversion. Below is the documentation for the Money class:
constructor(amount: MoneyAmount, currency: string, precision?: number)
Parameters:
amount (MoneyAmount): The amount of money, which can be a number, string, bigint, or BigInt.currency (string): The currency code (e.g., 'USD', 'EUR').precision (optional, number): The precision (number of decimal places) for the money amount. Defaults to 0.Throws:
Error if the precision is a negative number or if the currency is not a valid string.addadd(addends: Array<number | string | Money>): Money
add(...addends: Array<number | string | Money>): Money
add(...addends: Array<number | string | Money>[]): Money
Parameters:
addends (array or variadic): An array or variadic list of values to add to the current Money instance.Returns:
Throws:
TypeError if the provided addends have different currencies.subsub(subtractors: Array<number | string | Money>): Money
sub(...subtractors: Array<number | string | Money>): Money
sub(...subtractors: Array<number | string | Money>[]): Money
Parameters:
subtractors (array or variadic): An array or variadic list of values to subtract from the current Money instance.Returns:
Throws:
TypeError if the provided subtractors have different currencies.mulmul(scalar: number | string | bigint): Money
Parameters:
scalar (number | string | bigint): The scalar value to multiply the current Money instance by.Returns:
divdiv(scalar: number | string | bigint): Money
Parameters:
scalar (number | string | bigint): The scalar value to divide the current Money instance by.Returns:
roundround(precision: number, roundType: RoundType = 'HALF_AWAY_FROM_ZERO'): Money
Parameters:
precision (number): The precision (number of decimal places) to round the Money instance to.roundType (optional, enum 'HALF_AWAY_FROM_ZERO'): The rounding method to use. Defaults to 'HALF_AWAY_FROM_ZERO'.Returns:
comparecompare(money2: number | string | Money): -1 | 0 | 1
Parameters:
money2 (number | string | Money): The value to compare to the current Money instance.Returns:
money2.money2.money2.Throws:
TypeError if the currencies of the two Money instances are different.The following methods return a boolean value indicating the result of the respective comparison operation:
lesserThan(rightHandSide: number | string | Money): booleanlesserThanOrEqual(rightHandSide: number | string | Money): booleanequal(rightHandSide: number | string | Money): booleannotEqual(rightHandSide: number | string | Money): booleangreaterThan(rightHandSide: number | string | Money): booleangreaterThanOrEqual(rightHandSide: number | string | Money): booleancloneclone(): Money
formatformat(params: { precision?: number; symbol?: boolean; commas?: boolean; commaSeparated?: boolean } = {}): string
Parameters:
params (optional, object): Formatting options.
precision (optional, number): The precision (number of decimal places) for formatting. Defaults to the precision of the Money instance.symbol (optional, boolean): Whether to include the currency symbol. Defaults to false.commas (optional, boolean): Whether to use commas as thousands separators. Defaults to false.commaSeparated (optional, boolean): Whether to use a comma as the decimal separator. Defaults to false.Returns:
toStringtoString(): string
toJSONtoJSON(): string
setGlobalConversionRateFetcherstatic setGlobalConversionRateFetcher(conversionRateFetcher: ConversionRateFetcher | null)
conversionRateFetcher (ConversionRateFetcher | null): A function for fetching conversion rates or null to unset the global fetcher.convertstatic async convert(money: Money, targetCurrency: string, conversionRateFetcher?: ConversionRateFetcher): Promise<Money>
Parameters:
money (Money): The Money instance to convert.targetCurrency (string): The target currency code to convert to.conversionRateFetcher (optional, ConversionRateFetcher): A function for fetching conversion rates.Returns:
Throws:
Error if targetCurrency is not a valid string or if a conversion rate fetcher is not provided.exchangestatic async exchange(money: Money, currency: string): Promise<Money>
Parameters:
money (Money): The Money instance to exchange.currency (string): The target currency code to exchange to.Returns:
getExchangeRatestatic async getExchangeRate(fromCurrency: string, toCurrency: string, conversionRateFetcher?: ConversionRateFetcher): Promise
FAQs
Money
We found that quaney demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.