
Security News
Node.js Moves Toward Stable TypeScript Support with Amaro 1.0
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
A versatile library for extracting and converting numerical values, units, currency, and mathematical expressions into their spoken word equivalents.
Quantible is a versatile JavaScript library designed to convert numbers, quantities, and simple mathematical expressions into easily understandable spoken words. Whether you're building applications that require text-to-speech functionality, accessibility enhancements, or simply need to present numerical data in a more human-readable format, Quantible provides a robust and flexible solution.
Quantible excels at transforming various numerical expressions into their spoken word equivalents:
5 - 10
-> "five minus ten"-5 + 10
-> "negative five plus ten"10m/s
-> "ten meters per second"15m/s²
-> "fifteen meters per second squared"15²
or 15^2
-> "fifteen to the power of two"2^2m^2
-> "two to the power of two meters squared"2^2m²
-> "two to the power of two square meters"5E-10
-> "five times ten to the power of negative ten"-5E10
-> "negative five times ten to the power of ten"5E10
-> "five times ten to the power of ten"5 USD
-> "five dollars"$5
-> "five dollars"5.25 USD
-> "five dollars and twenty-five cents"$5.25
-> "five dollars and twenty-five cents"The autoReplaceAllMatches
function demonstrates the power of Quantible by converting all quantities within a text:
Input Sentence:
"We made $500 more this year than last years projections of 25%"
Output Sentence (after autoReplaceAllMatches
):
"We made five hundred dollars more this year than last years projections of twenty-five percent"
For projects using npm or yarn:
npm install quantible
Quantible is designed to be versatile and easily integrated into various JavaScript environments. You can consume it in three primary ways: directly in HTML via CDN, using CommonJS require
, or with modern ECMAScript import
statements.
For the quickest integration into web pages, you can use a Content Delivery Network (CDN) to include Quantible directly in your HTML file. This method is ideal for simple projects or when you want to avoid complex build processes.
<!DOCTYPE html>
<html>
<head>
<title>Quantible Example</title>
</head>
<body>
<div id="output"></div>
<script src="https://unpkg.com/quantible@latest/dist/index.iife.min.js"></script>
<script>
const inputString = "The price is $12.50 USD.";
const spokenText = Quantible.convertQuantities.autoReplaceAllMatches(inputString);
document.getElementById('output').textContent = spokenText;
</script>
</body>
</html>
In this example:
https://unpkg.com/quantible@latest/dist/index.iife.min.js
.Quantible
.Quantible.convertQuantities.autoReplaceAllMatches
to process a string and display the spoken word output in the div#output
element.require
For Node.js environments or projects using CommonJS modules, you can import Quantible using require
.
const { convertQuantities, extractQuantities } = require('quantible');
const input = "25 EUR";
const extractedData = extractQuantities.firstMatch(input);
const spokenWord = convertQuantities.translateMatch(extractedData);
console.log(spokenWord); // Output: twenty-five euros
import
For modern JavaScript projects and applications using ECMAScript modules, you can import Quantible using the import
statement. This is the recommended approach for most modern JavaScript development.
import { convertQuantities, extractQuantities } from 'quantible';
const input = "100 km/h";
const extractedData = extractQuantities.firstMatch(input);
const spokenWord = convertQuantities.translateMatch(extractedData);
console.log(spokenWord); // Output: one hundred kilometers per hour
Choose the consumption method that best fits your project's environment and build process. Quantible is designed to be flexible and adaptable to your needs.
The following examples demonstrate key functions of Quantible.
import { convertQuantities, extractQuantities } from 'quantible';
const input = "123.45 USD";
const extractedData = extractQuantities.firstMatch(input);
const spokenWord = convertQuantities.translateMatch(extractedData);
console.log(spokenWord);
// Output: one hundred twenty-three dollars and forty-five cents
This example shows how to extract and translate the first quantity found in a string.
import { convertQuantities } from 'quantible';
const inputReplaceAllMatches = "I have 5 USD and 10 EUR.";
const replacedString = convertQuantities.autoReplaceAllMatches(inputReplaceAllMatches);
console.log(replacedString); // Output: I have five dollars and ten euros.
This example demonstrates automatically replacing all quantities within a string.
We welcome contributions to Quantible! Please see CONTRIBUTING.md for details on how to contribute.
MIT License
Copyright (c) 2025 rinaldowouterson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A versatile library for extracting and converting numerical values, units, currency, and mathematical expressions into their spoken word equivalents.
We found that quantible 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
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.