
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@builtwithjavascript/formatters
Advanced tools
DateTime and Number formatters based on Intl API1
TypeScript
Contains hooks:
These are wrappers around Intl API NumberFormat and DateTimeFormat that allow to access the formatting function in a more concise way and avoid code cluttering.
npm install --save @builtwithjavascript/formatters
Note: these are just some of the possible parameter combinations:
import { useNumberFormatters } from '@builtwithjavascript/formatters'
const lcid = 'en-US' // or return it from your i18n current locale
const numberFormatters = useNumberFormatters(lcid)
// whole number
const wholeNumberFormatter = numberFormatters.whole()
wholeNumberFormatter().format(123456789.321654) // outputs: 12,345,654,322
// decimal number (default options)
const decimalNumberFormatter = numberFormatters.decimal()
decimalNumberFormatter().format(123456789.321654) // outputs: 12,345,654,321.89
// decimal number (with min/max fraction digits parameters)
const decimalNumberFormatter = numberFormatters.decimal(3, 5) // params are (minimumFractionDigits, maximumFractionDigits)
decimalNumberFormatter().format(123456789.321654) // outputs 12,345,654,321.89235
// percent number (default options)
const percentNumberFormatter = numberFormatters.percent()
percentNumberFormatter().format(4.892345) // outputs: 489.23%
// decimal number (with min/max fraction digits parameters)
const percentNumberFormatter = numberFormatters.percent(3, 5) // params are (minimumFractionDigits, maximumFractionDigits)
percentNumberFormatter().format(4.892345) // outputs 489.2345%
// currency ('USD' with default options)
const currencyNumberFormatter = numberFormatters.currency('USD')
currencyNumberFormatter().format(12345654321.892345) // outputs: $12,345,654,321.89
// currency ('EUR' with default options)
const currencyNumberFormatter = numberFormatters.currency('EUR')
currencyNumberFormatter().format(12345654321.892345) // outputs: €12,345,654,321.89
// currency ('USD' with params currencyDisplay, minimumFractionDigits, maximumFractionDigits)
const currencyNumberFormatter = numberFormatters.currency('USD', 'code', 1, 3)
currencyNumberFormatter().format(12345654321.892345) // outputs: USD12,345,654,321.892
Note: these are just some of the possible parameter combinations:
import { useDatetimeFormatters } from '@builtwithjavascript/formatters'
const lcid = 'en-US' // or return it from your i18n current locale
const datetimeFormatters = useDatetimeFormatters(lcid)
// datetime (default options)
datetimeFormatters.dateTime().format(inputValue) // outputs: "3/24/70"
// datetime (with dateStyle param)
datetimeFormatters.dateTime('long').format(inputValue) // outputs: "March 24, 1970"
// datetime (with dateStyle and timeStyle param)
datetimeFormatters.dateTime('short', 'short').format(inputValue) // outputs: "3/25/70, 12:11 AM"
import { useDatetimeFormatters } from '@builtwithjavascript/formatters'
const lcid = 'en-US' // or return it from your i18n current locale
const { dayNames, monthNames } = useDatetimeFormatters(lcid)
// dayNames
dayNames().map((o) => o.name)
// outputs: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
// monthNames
monthNames().map((o) => o.name)
// outputs: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
// dayNames
dayNames()
/* outputs:
[
{ id: 0, name: 'Sunday' },
{ id: 1, name: 'Monday' },
{ id: 2, name: 'Tuesday' },
{ id: 3, name: 'Wednesday' },
{ id: 4, name: 'Thursday' },
{ id: 5, name: 'Friday' },
{ id: 6, name: 'Saturday' }
]
*/
// monthNames
monthNames()
/* outputs:
[
{ id: 0, name: 'January' },
{ id: 1, name: 'February' },
{ id: 2, name: 'March' },
{ id: 3, name: 'April' },
{ id: 4, name: 'May' },
{ id: 5, name: 'June' },
{ id: 6, name: 'July' },
{ id: 7, name: 'August' },
{ id: 8, name: 'September' },
{ id: 9, name: 'October' },
{ id: 10, name: 'November' },
{ id: 11, name: 'December' }
]
*/
@types/jest @types/node husky jsdom prettier pretty-quick ts-node typescript vite vitest
Intl API https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl ↩
for 'currencyDisplay' the options are 'symbol', 'narrowSymbol', 'code', 'name' - Reference https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat ↩
FAQs
Datetime and Number formatters based on Intl API
We found that @builtwithjavascript/formatters 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.