1.0.3 • Published 1 year ago

@rbxts/formatting v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@rbxts/formatting

Utility functions for formatting numbers and parsing strings back into numbers for Roblox

commaFormat

Places commas between every three decimal points in n

Parameters

Examples

commaFormat(1000000) // 1,000,000

Returns string

abbreviate

Abbreviates numbers larger than or equal to threshold

Parameters

  • n number
  • threshold (optional, default 100_000)
  • suffixes (optional, default baseSuffixes)

Examples

abbreviate(1000000) // 1M
abbreviate(1000000000000000000000) // 1Sx

Returns string

parseAbbreviatedNumber

Parses a number formatted by abbreviate() back into a number type

Parameters

  • suffixed string
  • suffixes (optional, default baseSuffixes)

Examples

parseAbbreviatedNumber("1B") // 1000000000

Returns number

toSeconds

Takes a remaining time string and converts it to the amount of time it represents in seconds.

Parameters

Examples

toSeconds("10m 20s") // 620

Returns number

toRemainingTime

Takes a time in seconds and converts it to a remaining time string

Parameters

  • seconds number
  • secondsFormat (optional, default "%ds")
  • minutesFormat (optional, default "%dm")
  • hoursFormat (optional, default "%dh")
  • daysFormat (optional, default "%dd")

Examples

toRemainingTime(310) // 5m 10s

Returns string

toLongRemainingTime

Takes a time in seconds and converts it to a long remaining time string

Parameters

Examples

toLongRemainingTime(3690) // 01:01:30

Returns string

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago