JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 119
  • Score
    100M100P100Q72818F
  • License ISC

A lightweight number abbreviator

Package Exports

  • @rbxts/abbreviate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rbxts/abbreviate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@rbxts/rotatedregion3

NPM

Installation:

npm i @rbxts/abbreviate

Example Usage

import abbreviate from "@rbxts/abbreviate";

const abbreviator = abbreviate();
abbreviator.setSetting('suffixTable', ['k', 'm', 'b']);
abbreviator.setSetting('decimalPlaces', 2);

print(abbreviator.stringToNumber('500')) // 500
print(abbreviator.stringToNumber('5k')) // 5000
print(abbreviator.stringToNumber('5m')) // 5000000
print(abbreviator.stringToNumber('1.23456m')) // 1234560

print(abbreviator.numberToString(999)) // 999
print(abbreviator.numberToString(1000)) // 1.00k
print(abbreviator.numberToString(1000000)) // 1.00m
print(abbreviator.numberToString(1234567)) // 1.23m

Why make me call the function?

You may want multiple abbreviators throughout your game with different settings, i.e. one module may want only 2 d.p. while another may want 0 d.p To solve this, abbreviate requires you to construct a new "app" These settings are independent of other "apps"