@chopkola/common 1.0.51 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,2 @@
1
1
  export declare const convertStringDurationToMs: (value: string) => number;
2
+ export declare const abbreviateNumber: (number: number | null | undefined, decimals?: number) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertStringDurationToMs = void 0;
3
+ exports.abbreviateNumber = exports.convertStringDurationToMs = void 0;
4
4
  const validators_1 = require("../validators");
5
5
  const convertStringDurationToMs = (value) => {
6
6
  const match = value.match(validators_1.stringDurationToMsRegex);
@@ -21,3 +21,14 @@ const convertStringDurationToMs = (value) => {
21
21
  return amount * unitMap[unit];
22
22
  };
23
23
  exports.convertStringDurationToMs = convertStringDurationToMs;
24
+ const abbreviateNumber = (number, decimals = 1) => {
25
+ if (number == null || isNaN(number))
26
+ return '0'; // fallback for null/undefined/NaN
27
+ // Reusable formatter with dynamic decimals
28
+ const formatter = new Intl.NumberFormat('en', {
29
+ notation: 'compact',
30
+ maximumFractionDigits: decimals,
31
+ });
32
+ return formatter.format(number);
33
+ };
34
+ exports.abbreviateNumber = abbreviateNumber;
@@ -10,7 +10,7 @@ export interface RoleI {
10
10
  id: string;
11
11
  name: string;
12
12
  slug: string;
13
- description: Text;
13
+ description: string;
14
14
  permissions?: PermissionI[];
15
15
  }
16
16
  export interface RolePermissionI {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chopkola/common",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "akrosoft technology ltd",