Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@qit.tools/number-to-words
Advanced tools
This tiny library (🪶 1.4 KB) converts numbers to English words, supporting both general numeric values and monetary values with customizable currency and minor units.
This tiny library (🪶 1.4 KB) converts numbers to English words, supporting both general numeric values and monetary values with customizable currency and minor units.
👀 DEMO
npm i @qit.tools/number-to-words
bun add @qit.tools/number-to-words
pnpm add @qit.tools/number-to-words
yarn add @qit.tools/number-to-words
import { numberToWords } from "@qit.tools/number-to-words";
const words = numberToWords(123);
console.log(words); // "one hundred twenty-three"
const words = numberToWords(123.45);
console.log(words); // "one hundred twenty-three point four five"
const options = {
money: {
currency: ["dollar", "dollars"],
minor: ["cent", "cents"]
}
};
const words = numberToWords(123.45, options);
console.log(words); // "one hundred twenty-three dollars and forty-five cents"
numberToWords
Converts a number to its corresponding words representation.
num
(number): The number to be converted.options
(Options, optional): An optional object to specify formatting options.string
: The words representation of the number.type MoneyOptions = {
currency: [string, string];
minor?: [string, string];
};
currency
(required): An array of two strings representing the singular and plural forms of the currency.minor
(optional): An array of two strings representing the singular and plural forms of the minor currency unit.type Options = {
money?: MoneyOptions;
};
money
(optional): An object specifying the money formatting options.Here is an example of how you can use the library in your project:
import { numberToWords } from "number-to-words";
const number = 1234;
const words = numberToWords(number);
console.log(words); // "one thousand two hundred thirty-four"
const moneyOptions = {
money: {
currency: ["euro", "euros"],
minor: ["cent", "cents"]
}
};
const moneyWords = numberToWords(1234.56, moneyOptions);
console.log(moneyWords); // "one thousand two hundred thirty-four euros and fifty-six cents"
MIT
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Developed by Qit.tools.
Feel free to explore the source code and contribute to this library on GitHub.
FAQs
This tiny library (🪶 1.4 KB) converts numbers to English words, supporting both general numeric values and monetary values with customizable currency and minor units.
The npm package @qit.tools/number-to-words receives a total of 4 weekly downloads. As such, @qit.tools/number-to-words popularity was classified as not popular.
We found that @qit.tools/number-to-words demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.