{"library":"number-format.js","title":"Javascript Number Formatter","description":"number-format.js is a lightweight and performant JavaScript library designed for formatting numerical values using mask patterns. Currently at stable version 2.0.9, it focuses on providing a small footprint (under 2KB production size) and fast execution. It supports a wide array of masking symbols for forced and optional digits, positive/negative signs, and flexible thousands/decimal separators, accommodating various international numbering conventions. A key feature is its ability to automatically round numbers. Unlike more comprehensive internationalization libraries such as `Intl.NumberFormat`, `number-format.js` intentionally limits its scope, specifically not handling scientific/engineering notation, dates, or phone numbers. Its primary differentiator is its simplicity and speed for number mask formatting, making it suitable for scenarios where bundle size and performance are critical.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install number-format.js"],"cli":null},"imports":["import format from 'number-format.js';","const format = require('number-format.js');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import format from 'number-format.js';\n\n// Basic number formatting\nconsole.log(`Formatted 1234567.890 with '#,##0.####': ${format(\"#,##0.####\", 1234567.890)}`);\n// Expected: \"1,234,567.89\"\n\n// Currency formatting with prefix\nconsole.log(`Formatted -1234567.890 with '$ #,###.00': ${format(\"$ #,###.00\", -1234567.890)}`);\n// Expected: \"$ -1,234,567.89\"\n\n// Using enforceMaskSign option (added in v2.0.0)\nconsole.log(`Formatted -1234567.890 with '$ #,###.00' and enforceMaskSign: ${format(\"$ #,###.00\", -1234567.890, { enforceMaskSign: true })}`);\n// Expected: \"$ 1,234,567.89\"\n\n// Forcing positive sign\nconsole.log(`Formatted 1234567.890 with '$ +#,###.00' and enforceMaskSign: ${format(\"$ +#,###.00\", 1234567.890, { enforceMaskSign: true })}`);\n// Expected: \"$ +1,234,567.89\"\n\n// Custom decimal and thousands separators\nconsole.log(`Formatted 98765.432 with '#.##0,00': ${format(\"#.##0,00\", 98765.432)}`);\n// Expected: \"98.765,43\"","lang":"typescript","description":"Demonstrates basic number formatting, currency handling, the `enforceMaskSign` option, and custom separators.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}